Coverage Report

Created: 2026-11-04 13:56

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/service/arrow_flight/flight_sql_info.cpp
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
1
arrow::flight::sql::SqlInfoResultMap GetSqlInfoResultMap() {
31
1
    return {{arrow::flight::sql::SqlInfoOptions::SqlInfo::FLIGHT_SQL_SERVER_NAME,
32
1
             arrow::flight::sql::SqlInfoResult(std::string("DorisBE"))},
33
1
            {arrow::flight::sql::SqlInfoOptions::SqlInfo::FLIGHT_SQL_SERVER_VERSION,
34
1
             arrow::flight::sql::SqlInfoResult(std::string("1.0"))},
35
1
            {arrow::flight::sql::SqlInfoOptions::SqlInfo::FLIGHT_SQL_SERVER_ARROW_VERSION,
36
             arrow::flight::sql::SqlInfoResult(std::string(ARROW_VERSION_STRING))},
37
1
            {arrow::flight::sql::SqlInfoOptions::SqlInfo::FLIGHT_SQL_SERVER_READ_ONLY,
38
1
             arrow::flight::sql::SqlInfoResult(true)},
39
1
            {arrow::flight::sql::SqlInfoOptions::SqlInfo::FLIGHT_SQL_SERVER_SQL,
40
1
             arrow::flight::sql::SqlInfoResult(true)},
41
1
            {arrow::flight::sql::SqlInfoOptions::SqlInfo::FLIGHT_SQL_SERVER_SUBSTRAIT,
42
1
             arrow::flight::sql::SqlInfoResult(false)},
43
1
            {arrow::flight::sql::SqlInfoOptions::SqlInfo::FLIGHT_SQL_SERVER_TRANSACTION,
44
1
             arrow::flight::sql::SqlInfoResult(
45
1
                     arrow::flight::sql::SqlInfoOptions::SqlSupportedTransaction::
46
1
                             SQL_SUPPORTED_TRANSACTION_NONE)},
47
1
            {arrow::flight::sql::SqlInfoOptions::SqlInfo::FLIGHT_SQL_SERVER_CANCEL,
48
1
             arrow::flight::sql::SqlInfoResult(false)},
49
1
            {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_DDL_CATALOG,
50
1
             arrow::flight::sql::SqlInfoResult(false)},
51
1
            {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_DDL_SCHEMA,
52
1
             arrow::flight::sql::SqlInfoResult(false)},
53
1
            {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_DDL_TABLE,
54
1
             arrow::flight::sql::SqlInfoResult(false)},
55
1
            {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_IDENTIFIER_CASE,
56
1
             arrow::flight::sql::SqlInfoResult(
57
1
                     int64_t(arrow::flight::sql::SqlInfoOptions::SqlSupportedCaseSensitivity::
58
1
                                     SQL_CASE_SENSITIVITY_CASE_INSENSITIVE))},
59
1
            {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_IDENTIFIER_QUOTE_CHAR,
60
1
             arrow::flight::sql::SqlInfoResult(std::string("\""))},
61
1
            {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_QUOTED_IDENTIFIER_CASE,
62
1
             arrow::flight::sql::SqlInfoResult(
63
1
                     int64_t(arrow::flight::sql::SqlInfoOptions::SqlSupportedCaseSensitivity::
64
1
                                     SQL_CASE_SENSITIVITY_CASE_INSENSITIVE))},
65
1
            {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_ALL_TABLES_ARE_SELECTABLE,
66
1
             arrow::flight::sql::SqlInfoResult(true)},
67
1
            {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_NULL_ORDERING,
68
1
             arrow::flight::sql::SqlInfoResult(
69
1
                     int64_t(arrow::flight::sql::SqlInfoOptions::SqlNullOrdering::
70
1
                                     SQL_NULLS_SORTED_AT_START))},
71
1
            {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_KEYWORDS,
72
1
             arrow::flight::sql::SqlInfoResult(std::vector<std::string>({"ABORT",
73
1
                                                                         "ACTION",
74
1
                                                                         "ADD",
75
1
                                                                         "AFTER",
76
1
                                                                         "ALL",
77
1
                                                                         "ALTER",
78
1
                                                                         "ALWAYS",
79
1
                                                                         "ANALYZE",
80
1
                                                                         "AND",
81
1
                                                                         "AS",
82
1
                                                                         "ASC",
83
1
                                                                         "ATTACH",
84
1
                                                                         "AUTOINCREMENT",
85
1
                                                                         "BEFORE",
86
1
                                                                         "BEGIN",
87
1
                                                                         "BETWEEN",
88
1
                                                                         "BY",
89
1
                                                                         "CASCADE",
90
1
                                                                         "CASE",
91
1
                                                                         "CAST",
92
1
                                                                         "CHECK",
93
1
                                                                         "COLLATE",
94
1
                                                                         "COLUMN",
95
1
                                                                         "COMMIT",
96
1
                                                                         "CONFLICT",
97
1
                                                                         "CONSTRAINT",
98
1
                                                                         "CREATE",
99
1
                                                                         "CROSS",
100
1
                                                                         "CURRENT",
101
1
                                                                         "CURRENT_DATE",
102
1
                                                                         "CURRENT_TIME",
103
1
                                                                         "CURRENT_TIMESTAMP",
104
1
                                                                         "DATABASE",
105
1
                                                                         "DEFAULT",
106
1
                                                                         "DEFERRABLE",
107
1
                                                                         "DEFERRED",
108
1
                                                                         "DELETE",
109
1
                                                                         "DESC",
110
1
                                                                         "DETACH",
111
1
                                                                         "DISTINCT",
112
1
                                                                         "DO",
113
1
                                                                         "DROP",
114
1
                                                                         "EACH",
115
1
                                                                         "ELSE",
116
1
                                                                         "END",
117
1
                                                                         "ESCAPE",
118
1
                                                                         "EXCEPT",
119
1
                                                                         "EXCLUDE",
120
1
                                                                         "EXCLUSIVE",
121
1
                                                                         "EXISTS",
122
1
                                                                         "EXPLAIN",
123
1
                                                                         "FAIL",
124
1
                                                                         "FILTER",
125
1
                                                                         "FIRST",
126
1
                                                                         "FOLLOWING",
127
1
                                                                         "FOR",
128
1
                                                                         "FOREIGN",
129
1
                                                                         "FROM",
130
1
                                                                         "FULL",
131
1
                                                                         "GENERATED",
132
1
                                                                         "GLOB",
133
1
                                                                         "GROUP",
134
1
                                                                         "GROUPS",
135
1
                                                                         "HAVING",
136
1
                                                                         "IF",
137
1
                                                                         "IGNORE",
138
1
                                                                         "IMMEDIATE",
139
1
                                                                         "IN",
140
1
                                                                         "INDEX",
141
1
                                                                         "INDEXED",
142
1
                                                                         "INITIALLY",
143
1
                                                                         "INNER",
144
1
                                                                         "INSERT",
145
1
                                                                         "INSTEAD",
146
1
                                                                         "INTERSECT",
147
1
                                                                         "INTO",
148
1
                                                                         "IS",
149
1
                                                                         "ISNULL",
150
1
                                                                         "JOIN",
151
1
                                                                         "KEY",
152
1
                                                                         "LAST",
153
1
                                                                         "LEFT",
154
1
                                                                         "LIKE",
155
1
                                                                         "LIMIT",
156
1
                                                                         "MATCH",
157
1
                                                                         "MATERIALIZED",
158
1
                                                                         "NATURAL",
159
1
                                                                         "NO",
160
1
                                                                         "NOT",
161
1
                                                                         "NOTHING",
162
1
                                                                         "NOTNULL",
163
1
                                                                         "NULL",
164
1
                                                                         "NULLS",
165
1
                                                                         "OF",
166
1
                                                                         "OFFSET",
167
1
                                                                         "ON",
168
1
                                                                         "OR",
169
1
                                                                         "ORDER",
170
1
                                                                         "OTHERS",
171
1
                                                                         "OUTER",
172
1
                                                                         "OVER",
173
1
                                                                         "PARTITION",
174
1
                                                                         "PLAN",
175
1
                                                                         "PRAGMA",
176
1
                                                                         "PRECEDING",
177
1
                                                                         "PRIMARY",
178
1
                                                                         "QUERY",
179
1
                                                                         "RAISE",
180
1
                                                                         "RANGE",
181
1
                                                                         "RECURSIVE",
182
1
                                                                         "REFERENCES",
183
1
                                                                         "REGEXP",
184
1
                                                                         "REINDEX",
185
1
                                                                         "RELEASE",
186
1
                                                                         "RENAME",
187
1
                                                                         "REPLACE",
188
1
                                                                         "RESTRICT",
189
1
                                                                         "RETURNING",
190
1
                                                                         "RIGHT",
191
1
                                                                         "ROLLBACK",
192
1
                                                                         "ROW",
193
1
                                                                         "ROWS",
194
1
                                                                         "SAVEPOINT",
195
1
                                                                         "SELECT",
196
1
                                                                         "SET",
197
1
                                                                         "TABLE",
198
1
                                                                         "TEMP",
199
1
                                                                         "TEMPORARY",
200
1
                                                                         "THEN",
201
1
                                                                         "TIES",
202
1
                                                                         "TO",
203
1
                                                                         "TRANSACTION",
204
1
                                                                         "TRIGGER",
205
1
                                                                         "UNBOUNDED",
206
1
                                                                         "UNION",
207
1
                                                                         "UNIQUE",
208
1
                                                                         "UPDATE",
209
1
                                                                         "USING",
210
1
                                                                         "VACUUM",
211
1
                                                                         "VALUES",
212
1
                                                                         "VIEW",
213
1
                                                                         "VIRTUAL",
214
1
                                                                         "WHEN",
215
1
                                                                         "WHERE",
216
1
                                                                         "WINDOW",
217
1
                                                                         "WITH",
218
1
                                                                         "WITHOUT"}))},
219
1
            {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_NUMERIC_FUNCTIONS,
220
1
             arrow::flight::sql::SqlInfoResult(std::vector<std::string>(
221
1
                     {"ACOS",    "ACOSH", "ASIN", "ASINH",   "ATAN", "ATAN2", "ATANH", "CEIL",
222
1
                      "CEILING", "COS",   "COSH", "DEGREES", "EXP",  "FLOOR", "LN",    "LOG",
223
1
                      "LOG",     "LOG10", "LOG2", "MOD",     "PI",   "POW",   "POWER", "RADIANS",
224
1
                      "SIN",     "SINH",  "SQRT", "TAN",     "TANH", "TRUNC"}))},
225
1
            {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_STRING_FUNCTIONS,
226
1
             arrow::flight::sql::SqlInfoResult(
227
1
                     std::vector<std::string>({"SUBSTR", "TRIM", "LTRIM", "RTRIM", "LENGTH",
228
1
                                               "REPLACE", "UPPER", "LOWER", "INSTR"}))},
229
1
            {arrow::flight::sql::SqlInfoOptions::SqlInfo::SQL_SUPPORTS_CONVERT,
230
1
             arrow::flight::sql::SqlInfoResult(std::unordered_map<int32_t, std::vector<int32_t>>(
231
1
                     {{arrow::flight::sql::SqlInfoOptions::SqlSupportsConvert::SQL_CONVERT_BIGINT,
232
1
                       std::vector<int32_t>(
233
1
                               {arrow::flight::sql::SqlInfoOptions::SqlSupportsConvert::
234
1
                                        SQL_CONVERT_INTEGER})}}))}};
235
1
}
236
237
} // namespace flight
238
} // namespace doris