|
6 | 6 | #include "duckdb/function/table/arrow.hpp" |
7 | 7 | #include "duckdb/function/table/arrow/arrow_duck_schema.hpp" |
8 | 8 | #include "duckdb/common/insertion_order_preserving_map.hpp" |
| 9 | +#include "duckdb/parser/parsed_data/create_table_function_info.hpp" |
9 | 10 | #include <nanoarrow/nanoarrow.h> |
10 | 11 |
|
11 | 12 | namespace duckdb { |
@@ -1232,43 +1233,98 @@ void RegisterAdbcCatalogFunctions(DatabaseInstance &db) { |
1232 | 1233 | ExtensionLoader loader(db, "adbc"); |
1233 | 1234 |
|
1234 | 1235 | // adbc_info(connection_id) - Get driver/database information |
1235 | | - TableFunction adbc_info_function("adbc_info", {LogicalType::BIGINT}, AdbcInfoFunction, |
1236 | | - AdbcInfoBind, AdbcInfoInitGlobal, AdbcInfoInitLocal); |
1237 | | - adbc_info_function.projection_pushdown = false; |
1238 | | - loader.RegisterFunction(adbc_info_function); |
| 1236 | + { |
| 1237 | + TableFunction adbc_info_function("adbc_info", {LogicalType::BIGINT}, AdbcInfoFunction, |
| 1238 | + AdbcInfoBind, AdbcInfoInitGlobal, AdbcInfoInitLocal); |
| 1239 | + adbc_info_function.projection_pushdown = false; |
| 1240 | + CreateTableFunctionInfo info(adbc_info_function); |
| 1241 | + FunctionDescription desc; |
| 1242 | + desc.description = "Get driver and database information from an ADBC connection"; |
| 1243 | + desc.parameter_names = {"connection_handle"}; |
| 1244 | + desc.parameter_types = {LogicalType::BIGINT}; |
| 1245 | + desc.examples = {"SELECT * FROM adbc_info(connection_handle)"}; |
| 1246 | + desc.categories = {"adbc"}; |
| 1247 | + info.descriptions.push_back(std::move(desc)); |
| 1248 | + loader.RegisterFunction(info); |
| 1249 | + } |
1239 | 1250 |
|
1240 | 1251 | // adbc_tables(connection_id, catalog, schema, table_name) - Get tables |
1241 | | - TableFunction adbc_tables_function("adbc_tables", {LogicalType::BIGINT}, AdbcTablesFunction, |
1242 | | - AdbcTablesBind, AdbcTablesInitGlobal, AdbcTablesInitLocal); |
1243 | | - adbc_tables_function.named_parameters["catalog"] = LogicalType::VARCHAR; |
1244 | | - adbc_tables_function.named_parameters["schema"] = LogicalType::VARCHAR; |
1245 | | - adbc_tables_function.named_parameters["table_name"] = LogicalType::VARCHAR; |
1246 | | - adbc_tables_function.projection_pushdown = false; |
1247 | | - loader.RegisterFunction(adbc_tables_function); |
| 1252 | + { |
| 1253 | + TableFunction adbc_tables_function("adbc_tables", {LogicalType::BIGINT}, AdbcTablesFunction, |
| 1254 | + AdbcTablesBind, AdbcTablesInitGlobal, AdbcTablesInitLocal); |
| 1255 | + adbc_tables_function.named_parameters["catalog"] = LogicalType::VARCHAR; |
| 1256 | + adbc_tables_function.named_parameters["schema"] = LogicalType::VARCHAR; |
| 1257 | + adbc_tables_function.named_parameters["table_name"] = LogicalType::VARCHAR; |
| 1258 | + adbc_tables_function.projection_pushdown = false; |
| 1259 | + CreateTableFunctionInfo info(adbc_tables_function); |
| 1260 | + FunctionDescription desc; |
| 1261 | + desc.description = "Get list of tables from an ADBC data source"; |
| 1262 | + desc.parameter_names = {"connection_handle", "catalog", "schema", "table_name"}; |
| 1263 | + desc.parameter_types = {LogicalType::BIGINT, LogicalType::VARCHAR, LogicalType::VARCHAR, LogicalType::VARCHAR}; |
| 1264 | + desc.examples = {"SELECT * FROM adbc_tables(conn)", |
| 1265 | + "SELECT * FROM adbc_tables(conn, catalog := 'main')", |
| 1266 | + "SELECT * FROM adbc_tables(conn, table_name := 'users')"}; |
| 1267 | + desc.categories = {"adbc"}; |
| 1268 | + info.descriptions.push_back(std::move(desc)); |
| 1269 | + loader.RegisterFunction(info); |
| 1270 | + } |
1248 | 1271 |
|
1249 | 1272 | // adbc_table_types(connection_id) - Get supported table types |
1250 | | - TableFunction adbc_table_types_function("adbc_table_types", {LogicalType::BIGINT}, AdbcTableTypesFunction, |
1251 | | - AdbcTableTypesBind, AdbcTableTypesInitGlobal, AdbcTableTypesInitLocal); |
1252 | | - adbc_table_types_function.projection_pushdown = false; |
1253 | | - loader.RegisterFunction(adbc_table_types_function); |
| 1273 | + { |
| 1274 | + TableFunction adbc_table_types_function("adbc_table_types", {LogicalType::BIGINT}, AdbcTableTypesFunction, |
| 1275 | + AdbcTableTypesBind, AdbcTableTypesInitGlobal, AdbcTableTypesInitLocal); |
| 1276 | + adbc_table_types_function.projection_pushdown = false; |
| 1277 | + CreateTableFunctionInfo info(adbc_table_types_function); |
| 1278 | + FunctionDescription desc; |
| 1279 | + desc.description = "Get supported table types from an ADBC data source (e.g., 'table', 'view')"; |
| 1280 | + desc.parameter_names = {"connection_handle"}; |
| 1281 | + desc.parameter_types = {LogicalType::BIGINT}; |
| 1282 | + desc.examples = {"SELECT * FROM adbc_table_types(conn)"}; |
| 1283 | + desc.categories = {"adbc"}; |
| 1284 | + info.descriptions.push_back(std::move(desc)); |
| 1285 | + loader.RegisterFunction(info); |
| 1286 | + } |
1254 | 1287 |
|
1255 | 1288 | // adbc_columns(connection_id, ...) - Get column metadata |
1256 | | - TableFunction adbc_columns_function("adbc_columns", {LogicalType::BIGINT}, AdbcColumnsFunction, |
1257 | | - AdbcColumnsBind, AdbcColumnsInitGlobal, AdbcColumnsInitLocal); |
1258 | | - adbc_columns_function.named_parameters["catalog"] = LogicalType::VARCHAR; |
1259 | | - adbc_columns_function.named_parameters["schema"] = LogicalType::VARCHAR; |
1260 | | - adbc_columns_function.named_parameters["table_name"] = LogicalType::VARCHAR; |
1261 | | - adbc_columns_function.named_parameters["column_name"] = LogicalType::VARCHAR; |
1262 | | - adbc_columns_function.projection_pushdown = false; |
1263 | | - loader.RegisterFunction(adbc_columns_function); |
| 1289 | + { |
| 1290 | + TableFunction adbc_columns_function("adbc_columns", {LogicalType::BIGINT}, AdbcColumnsFunction, |
| 1291 | + AdbcColumnsBind, AdbcColumnsInitGlobal, AdbcColumnsInitLocal); |
| 1292 | + adbc_columns_function.named_parameters["catalog"] = LogicalType::VARCHAR; |
| 1293 | + adbc_columns_function.named_parameters["schema"] = LogicalType::VARCHAR; |
| 1294 | + adbc_columns_function.named_parameters["table_name"] = LogicalType::VARCHAR; |
| 1295 | + adbc_columns_function.named_parameters["column_name"] = LogicalType::VARCHAR; |
| 1296 | + adbc_columns_function.projection_pushdown = false; |
| 1297 | + CreateTableFunctionInfo info(adbc_columns_function); |
| 1298 | + FunctionDescription desc; |
| 1299 | + desc.description = "Get column metadata for tables in an ADBC data source"; |
| 1300 | + desc.parameter_names = {"connection_handle", "catalog", "schema", "table_name", "column_name"}; |
| 1301 | + desc.parameter_types = {LogicalType::BIGINT, LogicalType::VARCHAR, LogicalType::VARCHAR, LogicalType::VARCHAR, LogicalType::VARCHAR}; |
| 1302 | + desc.examples = {"SELECT * FROM adbc_columns(conn)", |
| 1303 | + "SELECT * FROM adbc_columns(conn, table_name := 'users')", |
| 1304 | + "SELECT * FROM adbc_columns(conn, table_name := 'users', column_name := 'id')"}; |
| 1305 | + desc.categories = {"adbc"}; |
| 1306 | + info.descriptions.push_back(std::move(desc)); |
| 1307 | + loader.RegisterFunction(info); |
| 1308 | + } |
1264 | 1309 |
|
1265 | 1310 | // adbc_schema(connection_id, table_name, ...) - Get Arrow schema for a table |
1266 | | - TableFunction adbc_schema_function("adbc_schema", {LogicalType::BIGINT, LogicalType::VARCHAR}, AdbcSchemaFunction, |
1267 | | - AdbcSchemaBind, AdbcSchemaInitGlobal, AdbcSchemaInitLocal); |
1268 | | - adbc_schema_function.named_parameters["catalog"] = LogicalType::VARCHAR; |
1269 | | - adbc_schema_function.named_parameters["schema"] = LogicalType::VARCHAR; |
1270 | | - adbc_schema_function.projection_pushdown = false; |
1271 | | - loader.RegisterFunction(adbc_schema_function); |
| 1311 | + { |
| 1312 | + TableFunction adbc_schema_function("adbc_schema", {LogicalType::BIGINT, LogicalType::VARCHAR}, AdbcSchemaFunction, |
| 1313 | + AdbcSchemaBind, AdbcSchemaInitGlobal, AdbcSchemaInitLocal); |
| 1314 | + adbc_schema_function.named_parameters["catalog"] = LogicalType::VARCHAR; |
| 1315 | + adbc_schema_function.named_parameters["schema"] = LogicalType::VARCHAR; |
| 1316 | + adbc_schema_function.projection_pushdown = false; |
| 1317 | + CreateTableFunctionInfo info(adbc_schema_function); |
| 1318 | + FunctionDescription desc; |
| 1319 | + desc.description = "Get the Arrow schema for a specific table in an ADBC data source"; |
| 1320 | + desc.parameter_names = {"connection_handle", "table_name", "catalog", "schema"}; |
| 1321 | + desc.parameter_types = {LogicalType::BIGINT, LogicalType::VARCHAR, LogicalType::VARCHAR, LogicalType::VARCHAR}; |
| 1322 | + desc.examples = {"SELECT * FROM adbc_schema(conn, 'users')", |
| 1323 | + "SELECT * FROM adbc_schema(conn, 'users', catalog := 'main')"}; |
| 1324 | + desc.categories = {"adbc"}; |
| 1325 | + info.descriptions.push_back(std::move(desc)); |
| 1326 | + loader.RegisterFunction(info); |
| 1327 | + } |
1272 | 1328 | } |
1273 | 1329 |
|
1274 | 1330 | } // namespace adbc |
|
0 commit comments