Line | Count | Source |
1 | // Licensed to the Apache Software Foundation (ASF) under one | |
2 | // or more contributor license agreements. See the NOTICE file | |
3 | // distributed with this work for additional information | |
4 | // regarding copyright ownership. The ASF licenses this file | |
5 | // to you under the Apache License, Version 2.0 (the | |
6 | // "License"); you may not use this file except in compliance | |
7 | // with the License. You may obtain a copy of the License at | |
8 | // | |
9 | // http://www.apache.org/licenses/LICENSE-2.0 | |
10 | // | |
11 | // Unless required by applicable law or agreed to in writing, | |
12 | // software distributed under the License is distributed on an | |
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
14 | // KIND, either express or implied. See the License for the | |
15 | // specific language governing permissions and limitations | |
16 | // under the License. | |
17 | // This file is copied from | |
18 | // https://github.com/apache/arrow/blob/main/cpp/src/arrow/flight/sql/example/sqlite_sql_info.cc | |
19 | // and modified by Doris | |
20 | ||
21 | #include "service/arrow_flight/flight_sql_info.h" | |
22 | ||
23 | #include "arrow/flight/sql/types.h" | |
24 | #include "arrow/util/config.h" | |
25 | ||
26 | namespace doris { | |
27 | namespace flight { | |
28 | /// \brief Gets the mapping from SQL info ids to arrow::flight::sql::SqlInfoResult instances. | |
29 | /// \return the cache. | |
30 | 0 | arrow::flight::sql::SqlInfoResultMap GetSqlInfoResultMap() { |
31 | 0 | return {{arrow::flight::sql::SqlInfoOptions::SqlInfo::FLIGHT_SQL_SERVER_NAME, |
32 | 0 | arrow::flight::sql::SqlInfoResult(std::string("DorisBE"))}, |
33 | 0 | {arrow::flight::sql::SqlInfoOptions::SqlInfo::FLIGHT_SQL_SERVER_VERSION, |
34 | 0 | arrow::flight::sql::SqlInfoResult(std::string("1.0"))}, |
35 | 0 | {arrow::flight::sql::SqlInfoOptions::SqlInfo::FLIGHT_SQL_SERVER_ARROW_VERSION, |
36 | arrow::flight::sql::SqlInfoResult(std::string(ARROW_VERSION_STRING))}, | |
37 | 0 | {arrow::flight::sql::SqlInfoOptions::SqlInfo::FLIGHT_SQL_SERVER_READ_ONLY, |
38 | 0 | arrow::flight::sql::SqlInfoResult(true)}, |
39 | 0 | {arrow::flight::sql::SqlInfoOptions::SqlInfo::FLIGHT_SQL_SERVER_SQL, |
40 | 0 | arrow::flight::sql::SqlInfoResult(true)}, |
41 | 0 | {arrow::flight::sql::SqlInfoOptions::SqlInfo::FLIGHT_SQL_SERVER_SUBSTRAIT, |
42 | 0 | arrow::flight::sql::SqlInfoResult(false)}, |
43 | 0 | {arrow::flight::sql::SqlInfoOptions::SqlInfo::FLIGHT_SQL_SERVER_TRANSACTION, |
44 | 0 | arrow::flight::sql::SqlInfoResult( |
45 | 0 | arrow::flight::sql::SqlInfoOptions::SqlSupportedTransaction:: |
46 | 0 | SQL_SUPPORTED_TRANSACTION_NONE)}, |
47 | 0 | {arrow::flight::sql::SqlInfoOptions::SqlInfo::FLIGHT_SQL_SERVER_CANCEL, |
48 | 0 | arrow::flight::sql::SqlInfoResult(false)}, |
49 | 0 | {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_DDL_CATALOG, |
50 | 0 | arrow::flight::sql::SqlInfoResult(false)}, |
51 | 0 | {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_DDL_SCHEMA, |
52 | 0 | arrow::flight::sql::SqlInfoResult(false)}, |
53 | 0 | {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_DDL_TABLE, |
54 | 0 | arrow::flight::sql::SqlInfoResult(false)}, |
55 | 0 | {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_IDENTIFIER_CASE, |
56 | 0 | arrow::flight::sql::SqlInfoResult( |
57 | 0 | int64_t(arrow::flight::sql::SqlInfoOptions::SqlSupportedCaseSensitivity:: |
58 | 0 | SQL_CASE_SENSITIVITY_CASE_INSENSITIVE))}, |
59 | 0 | {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_IDENTIFIER_QUOTE_CHAR, |
60 | 0 | arrow::flight::sql::SqlInfoResult(std::string("\""))}, |
61 | 0 | {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_QUOTED_IDENTIFIER_CASE, |
62 | 0 | arrow::flight::sql::SqlInfoResult( |
63 | 0 | int64_t(arrow::flight::sql::SqlInfoOptions::SqlSupportedCaseSensitivity:: |
64 | 0 | SQL_CASE_SENSITIVITY_CASE_INSENSITIVE))}, |
65 | 0 | {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_ALL_TABLES_ARE_SELECTABLE, |
66 | 0 | arrow::flight::sql::SqlInfoResult(true)}, |
67 | 0 | {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_NULL_ORDERING, |
68 | 0 | arrow::flight::sql::SqlInfoResult( |
69 | 0 | int64_t(arrow::flight::sql::SqlInfoOptions::SqlNullOrdering:: |
70 | 0 | SQL_NULLS_SORTED_AT_START))}, |
71 | 0 | {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_KEYWORDS, |
72 | 0 | arrow::flight::sql::SqlInfoResult(std::vector<std::string>({"ABORT", |
73 | 0 | "ACTION", |
74 | 0 | "ADD", |
75 | 0 | "AFTER", |
76 | 0 | "ALL", |
77 | 0 | "ALTER", |
78 | 0 | "ALWAYS", |
79 | 0 | "ANALYZE", |
80 | 0 | "AND", |
81 | 0 | "AS", |
82 | 0 | "ASC", |
83 | 0 | "ATTACH", |
84 | 0 | "AUTOINCREMENT", |
85 | 0 | "BEFORE", |
86 | 0 | "BEGIN", |
87 | 0 | "BETWEEN", |
88 | 0 | "BY", |
89 | 0 | "CASCADE", |
90 | 0 | "CASE", |
91 | 0 | "CAST", |
92 | 0 | "CHECK", |
93 | 0 | "COLLATE", |
94 | 0 | "COLUMN", |
95 | 0 | "COMMIT", |
96 | 0 | "CONFLICT", |
97 | 0 | "CONSTRAINT", |
98 | 0 | "CREATE", |
99 | 0 | "CROSS", |
100 | 0 | "CURRENT", |
101 | 0 | "CURRENT_DATE", |
102 | 0 | "CURRENT_TIME", |
103 | 0 | "CURRENT_TIMESTAMP", |
104 | 0 | "DATABASE", |
105 | 0 | "DEFAULT", |
106 | 0 | "DEFERRABLE", |
107 | 0 | "DEFERRED", |
108 | 0 | "DELETE", |
109 | 0 | "DESC", |
110 | 0 | "DETACH", |
111 | 0 | "DISTINCT", |
112 | 0 | "DO", |
113 | 0 | "DROP", |
114 | 0 | "EACH", |
115 | 0 | "ELSE", |
116 | 0 | "END", |
117 | 0 | "ESCAPE", |
118 | 0 | "EXCEPT", |
119 | 0 | "EXCLUDE", |
120 | 0 | "EXCLUSIVE", |
121 | 0 | "EXISTS", |
122 | 0 | "EXPLAIN", |
123 | 0 | "FAIL", |
124 | 0 | "FILTER", |
125 | 0 | "FIRST", |
126 | 0 | "FOLLOWING", |
127 | 0 | "FOR", |
128 | 0 | "FOREIGN", |
129 | 0 | "FROM", |
130 | 0 | "FULL", |
131 | 0 | "GENERATED", |
132 | 0 | "GLOB", |
133 | 0 | "GROUP", |
134 | 0 | "GROUPS", |
135 | 0 | "HAVING", |
136 | 0 | "IF", |
137 | 0 | "IGNORE", |
138 | 0 | "IMMEDIATE", |
139 | 0 | "IN", |
140 | 0 | "INDEX", |
141 | 0 | "INDEXED", |
142 | 0 | "INITIALLY", |
143 | 0 | "INNER", |
144 | 0 | "INSERT", |
145 | 0 | "INSTEAD", |
146 | 0 | "INTERSECT", |
147 | 0 | "INTO", |
148 | 0 | "IS", |
149 | 0 | "ISNULL", |
150 | 0 | "JOIN", |
151 | 0 | "KEY", |
152 | 0 | "LAST", |
153 | 0 | "LEFT", |
154 | 0 | "LIKE", |
155 | 0 | "LIMIT", |
156 | 0 | "MATCH", |
157 | 0 | "MATERIALIZED", |
158 | 0 | "NATURAL", |
159 | 0 | "NO", |
160 | 0 | "NOT", |
161 | 0 | "NOTHING", |
162 | 0 | "NOTNULL", |
163 | 0 | "NULL", |
164 | 0 | "NULLS", |
165 | 0 | "OF", |
166 | 0 | "OFFSET", |
167 | 0 | "ON", |
168 | 0 | "OR", |
169 | 0 | "ORDER", |
170 | 0 | "OTHERS", |
171 | 0 | "OUTER", |
172 | 0 | "OVER", |
173 | 0 | "PARTITION", |
174 | 0 | "PLAN", |
175 | 0 | "PRAGMA", |
176 | 0 | "PRECEDING", |
177 | 0 | "PRIMARY", |
178 | 0 | "QUERY", |
179 | 0 | "RAISE", |
180 | 0 | "RANGE", |
181 | 0 | "RECURSIVE", |
182 | 0 | "REFERENCES", |
183 | 0 | "REGEXP", |
184 | 0 | "REINDEX", |
185 | 0 | "RELEASE", |
186 | 0 | "RENAME", |
187 | 0 | "REPLACE", |
188 | 0 | "RESTRICT", |
189 | 0 | "RETURNING", |
190 | 0 | "RIGHT", |
191 | 0 | "ROLLBACK", |
192 | 0 | "ROW", |
193 | 0 | "ROWS", |
194 | 0 | "SAVEPOINT", |
195 | 0 | "SELECT", |
196 | 0 | "SET", |
197 | 0 | "TABLE", |
198 | 0 | "TEMP", |
199 | 0 | "TEMPORARY", |
200 | 0 | "THEN", |
201 | 0 | "TIES", |
202 | 0 | "TO", |
203 | 0 | "TRANSACTION", |
204 | 0 | "TRIGGER", |
205 | 0 | "UNBOUNDED", |
206 | 0 | "UNION", |
207 | 0 | "UNIQUE", |
208 | 0 | "UPDATE", |
209 | 0 | "USING", |
210 | 0 | "VACUUM", |
211 | 0 | "VALUES", |
212 | 0 | "VIEW", |
213 | 0 | "VIRTUAL", |
214 | 0 | "WHEN", |
215 | 0 | "WHERE", |
216 | 0 | "WINDOW", |
217 | 0 | "WITH", |
218 | 0 | "WITHOUT"}))}, |
219 | 0 | {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_NUMERIC_FUNCTIONS, |
220 | 0 | arrow::flight::sql::SqlInfoResult(std::vector<std::string>( |
221 | 0 | {"ACOS", "ACOSH", "ASIN", "ASINH", "ATAN", "ATAN2", "ATANH", "CEIL", |
222 | 0 | "CEILING", "COS", "COSH", "DEGREES", "EXP", "FLOOR", "LN", "LOG", |
223 | 0 | "LOG", "LOG10", "LOG2", "MOD", "PI", "POW", "POWER", "RADIANS", |
224 | 0 | "SIN", "SINH", "SQRT", "TAN", "TANH", "TRUNC"}))}, |
225 | 0 | {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_STRING_FUNCTIONS, |
226 | 0 | arrow::flight::sql::SqlInfoResult( |
227 | 0 | std::vector<std::string>({"SUBSTR", "TRIM", "LTRIM", "RTRIM", "LENGTH", |
228 | 0 | "REPLACE", "UPPER", "LOWER", "INSTR"}))}, |
229 | 0 | {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_SUPPORTS_CONVERT, |
230 | 0 | arrow::flight::sql::SqlInfoResult(std::unordered_map<int32_t, std::vector<int32_t>>( |
231 | 0 | {{arrow::flight::sql::SqlInfoOptions::SqlSupportsConvert::SQL_CONVERT_BIGINT, |
232 | 0 | std::vector<int32_t>( |
233 | 0 | {arrow::flight::sql::SqlInfoOptions::SqlSupportsConvert:: |
234 | 0 | SQL_CONVERT_INTEGER})}}))}}; |
235 | 0 | } |
236 | ||
237 | } // namespace flight | |
238 | } // namespace doris |