MCPcopy Create free account
hub / github.com/apache/arrow / PrepareQueryForGetTables

Function PrepareQueryForGetTables

cpp/src/arrow/flight/sql/example/sqlite_server.cc:54–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54std::string PrepareQueryForGetTables(const GetTables& command) {
55 std::stringstream table_query;
56
57 table_query << "SELECT 'main' as catalog_name, null as schema_name, name as "
58 "table_name, type as table_type FROM sqlite_master where 1=1";
59
60 if (command.catalog.has_value()) {
61 table_query << " and catalog_name='" << command.catalog.value() << "'";
62 }
63
64 if (command.db_schema_filter_pattern.has_value()) {
65 table_query << " and schema_name LIKE '" << command.db_schema_filter_pattern.value()
66 << "'";
67 }
68
69 if (command.table_name_filter_pattern.has_value()) {
70 table_query << " and table_name LIKE '" << command.table_name_filter_pattern.value()
71 << "'";
72 }
73
74 if (!command.table_types.empty()) {
75 table_query << " and table_type IN (";
76 size_t size = command.table_types.size();
77 for (size_t i = 0; i < size; i++) {
78 table_query << "'" << command.table_types[i] << "'";
79 if (size - 1 != i) {
80 table_query << ",";
81 }
82 }
83
84 table_query << ")";
85 }
86
87 table_query << " order by table_name";
88 return table_query.str();
89}
90
91template <typename Callback>
92Status SetParametersOnSQLiteStatement(SqliteStatement* statement,

Callers 1

DoGetTablesMethod · 0.85

Calls 4

strMethod · 0.80
valueMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected