From 4dfe808313886a7b6b5c67156157f73656c8e2e6 Mon Sep 17 00:00:00 2001 From: Dewey Dunnington Date: Mon, 27 Oct 2025 10:06:51 -0500 Subject: [PATCH 1/5] request schema --- c/include/arrow-adbc/adbc.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/c/include/arrow-adbc/adbc.h b/c/include/arrow-adbc/adbc.h index 5982e31572..598d8032a8 100644 --- a/c/include/arrow-adbc/adbc.h +++ b/c/include/arrow-adbc/adbc.h @@ -2293,6 +2293,31 @@ AdbcStatusCode AdbcStatementExecuteSchema(struct AdbcStatement* statement, struct ArrowSchema* schema, struct AdbcError* error); +/// \brief Request the schema of the next statement execution +/// +/// Allows the caller to request a specific schema based on prior +/// information or user input. This may be used to ensure a +/// consistent schema when executing queries against a database +/// with row-based types (e.g., SQLite) or a database whose types +/// are implemented with row-based parameters where Arrow prefers +/// type-level parameters (e.g., NUMERIC for PostgreSQL). Callers +/// may also use a transformation of the schema provided by +/// AdbcStatementExecuteSchema to request specific Arrow type +/// variants such as string views or list views. +/// +/// \since ADBC API revision 1.2.0 +/// +/// \param[in] statement The statement to execute. +/// \param[in] schema The requested schema. +/// \param[out] error An optional location to return an error +/// message if necessary. +/// +/// \return ADBC_STATUS_NOT_IMPLEMENTED if the driver does not support this. +ADBC_EXPORT +AdbcStatusCode AdbcStatementRequestSchema(struct AdbcStatement* statement, + struct ArrowSchema* schema, + struct AdbcError* error); + /// \brief Turn this statement into a prepared statement to be /// executed multiple times. /// From f9cea38c779ef71c85353f12dd45dc0fc665f7a3 Mon Sep 17 00:00:00 2001 From: Dewey Dunnington Date: Mon, 27 Oct 2025 10:36:31 -0500 Subject: [PATCH 2/5] add more language --- c/include/arrow-adbc/adbc.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/c/include/arrow-adbc/adbc.h b/c/include/arrow-adbc/adbc.h index 598d8032a8..95d40bc135 100644 --- a/c/include/arrow-adbc/adbc.h +++ b/c/include/arrow-adbc/adbc.h @@ -1255,6 +1255,10 @@ struct ADBC_EXPORT AdbcDriver { AdbcStatusCode (*StatementSetOptionInt)(struct AdbcStatement*, const char*, int64_t, struct AdbcError*); + // ADBC 1.2 + AdbcStatusCode (*StatementRequestSchema)(struct AdbcStatement*, struct ArrowSchema*, + struct AdbcError*); + /// @} /// \defgroup adbc-1.2.0 ADBC API Revision 1.2.0 @@ -2305,6 +2309,14 @@ AdbcStatusCode AdbcStatementExecuteSchema(struct AdbcStatement* statement, /// AdbcStatementExecuteSchema to request specific Arrow type /// variants such as string views or list views. /// +/// The provided schema is a request and not a guarantee (i.e., +/// callers must use the schema provided by the output stream to +/// interpret the result). +/// +/// Calling AdbcStatementRequestSchema() must not affect the result +/// of AdbcStatementExecuteSchema (which always infers its result +/// from the input query). +/// /// \since ADBC API revision 1.2.0 /// /// \param[in] statement The statement to execute. From 6fc5218251b7bdba971f0c8c3f8d6f9db5cfcc03 Mon Sep 17 00:00:00 2001 From: Dewey Dunnington Date: Wed, 19 Nov 2025 14:28:35 -0500 Subject: [PATCH 3/5] remove negotiation garbage --- c/include/arrow-adbc/adbc.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/c/include/arrow-adbc/adbc.h b/c/include/arrow-adbc/adbc.h index 95d40bc135..d16e47415c 100644 --- a/c/include/arrow-adbc/adbc.h +++ b/c/include/arrow-adbc/adbc.h @@ -2304,10 +2304,7 @@ AdbcStatusCode AdbcStatementExecuteSchema(struct AdbcStatement* statement, /// consistent schema when executing queries against a database /// with row-based types (e.g., SQLite) or a database whose types /// are implemented with row-based parameters where Arrow prefers -/// type-level parameters (e.g., NUMERIC for PostgreSQL). Callers -/// may also use a transformation of the schema provided by -/// AdbcStatementExecuteSchema to request specific Arrow type -/// variants such as string views or list views. +/// type-level parameters (e.g., NUMERIC for PostgreSQL). /// /// The provided schema is a request and not a guarantee (i.e., /// callers must use the schema provided by the output stream to From 120da6c6e9d31ba648e6f11d87cf6069a419087f Mon Sep 17 00:00:00 2001 From: Dewey Dunnington Date: Wed, 25 Feb 2026 09:20:16 -0600 Subject: [PATCH 4/5] add stub --- c/driver_manager/adbc_driver_manager.cc | 18 +++++++++++++ go/adbc/drivermgr/arrow-adbc/adbc.h | 34 +++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/c/driver_manager/adbc_driver_manager.cc b/c/driver_manager/adbc_driver_manager.cc index 15d98c00bd..7a925a18e8 100644 --- a/c/driver_manager/adbc_driver_manager.cc +++ b/c/driver_manager/adbc_driver_manager.cc @@ -1764,6 +1764,12 @@ AdbcStatusCode StatementSetSubstraitPlan(struct AdbcStatement*, const uint8_t*, return ADBC_STATUS_NOT_IMPLEMENTED; } +AdbcStatusCode StatementRequestSchema(struct AdbcStatement*, struct ArrowSchema*, + struct AdbcError* error) { + SetError(error, "AdbcStatementRequestSchema not implemented"); + return ADBC_STATUS_NOT_IMPLEMENTED; +} + /// Temporary state while the database is being configured. struct TempDatabase { std::unordered_map options; @@ -3159,6 +3165,17 @@ AdbcStatusCode AdbcStatementSetSubstraitPlan(struct AdbcStatement* statement, error); } +AdbcStatusCode AdbcStatementRequestSchema(struct AdbcStatement* statement, + struct ArrowSchema* schema, + struct AdbcError* error) { + if (!statement->private_driver) { + SetError(error, "AdbcStatementRequestSchema: must call AdbcStatementNew first"); + return ADBC_STATUS_INVALID_STATE; + } + INIT_ERROR(error, statement); + return statement->private_driver->StatementRequestSchema(statement, schema, error); +} + const char* AdbcStatusCodeMessage(AdbcStatusCode code) { #define CASE(CONSTANT) \ case ADBC_STATUS_##CONSTANT: \ @@ -3346,6 +3363,7 @@ AdbcStatusCode AdbcLoadDriverFromInitFunc(AdbcDriverInitFunc init_func, int vers FILL_DEFAULT(driver, StatementSetOption); FILL_DEFAULT(driver, StatementSetSqlQuery); FILL_DEFAULT(driver, StatementSetSubstraitPlan); + FILL_DEFAULT(driver, StatementRequestSchema); } if (version >= ADBC_VERSION_1_1_0) { auto* driver = reinterpret_cast(raw_driver); diff --git a/go/adbc/drivermgr/arrow-adbc/adbc.h b/go/adbc/drivermgr/arrow-adbc/adbc.h index 5982e31572..d16e47415c 100644 --- a/go/adbc/drivermgr/arrow-adbc/adbc.h +++ b/go/adbc/drivermgr/arrow-adbc/adbc.h @@ -1255,6 +1255,10 @@ struct ADBC_EXPORT AdbcDriver { AdbcStatusCode (*StatementSetOptionInt)(struct AdbcStatement*, const char*, int64_t, struct AdbcError*); + // ADBC 1.2 + AdbcStatusCode (*StatementRequestSchema)(struct AdbcStatement*, struct ArrowSchema*, + struct AdbcError*); + /// @} /// \defgroup adbc-1.2.0 ADBC API Revision 1.2.0 @@ -2293,6 +2297,36 @@ AdbcStatusCode AdbcStatementExecuteSchema(struct AdbcStatement* statement, struct ArrowSchema* schema, struct AdbcError* error); +/// \brief Request the schema of the next statement execution +/// +/// Allows the caller to request a specific schema based on prior +/// information or user input. This may be used to ensure a +/// consistent schema when executing queries against a database +/// with row-based types (e.g., SQLite) or a database whose types +/// are implemented with row-based parameters where Arrow prefers +/// type-level parameters (e.g., NUMERIC for PostgreSQL). +/// +/// The provided schema is a request and not a guarantee (i.e., +/// callers must use the schema provided by the output stream to +/// interpret the result). +/// +/// Calling AdbcStatementRequestSchema() must not affect the result +/// of AdbcStatementExecuteSchema (which always infers its result +/// from the input query). +/// +/// \since ADBC API revision 1.2.0 +/// +/// \param[in] statement The statement to execute. +/// \param[in] schema The requested schema. +/// \param[out] error An optional location to return an error +/// message if necessary. +/// +/// \return ADBC_STATUS_NOT_IMPLEMENTED if the driver does not support this. +ADBC_EXPORT +AdbcStatusCode AdbcStatementRequestSchema(struct AdbcStatement* statement, + struct ArrowSchema* schema, + struct AdbcError* error); + /// \brief Turn this statement into a prepared statement to be /// executed multiple times. /// From d2051a90267579d242dd3633501bdcd7bace052a Mon Sep 17 00:00:00 2001 From: Dewey Dunnington Date: Thu, 26 Feb 2026 20:25:20 -0600 Subject: [PATCH 5/5] maybe put things in the right place --- c/driver_manager/adbc_driver_manager.cc | 5 ++++- c/include/arrow-adbc/adbc.h | 7 +++---- go/adbc/drivermgr/adbc_driver_manager.cc | 21 +++++++++++++++++++++ go/adbc/drivermgr/arrow-adbc/adbc.h | 7 +++---- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/c/driver_manager/adbc_driver_manager.cc b/c/driver_manager/adbc_driver_manager.cc index 7a925a18e8..7cf2c424b9 100644 --- a/c/driver_manager/adbc_driver_manager.cc +++ b/c/driver_manager/adbc_driver_manager.cc @@ -3363,7 +3363,6 @@ AdbcStatusCode AdbcLoadDriverFromInitFunc(AdbcDriverInitFunc init_func, int vers FILL_DEFAULT(driver, StatementSetOption); FILL_DEFAULT(driver, StatementSetSqlQuery); FILL_DEFAULT(driver, StatementSetSubstraitPlan); - FILL_DEFAULT(driver, StatementRequestSchema); } if (version >= ADBC_VERSION_1_1_0) { auto* driver = reinterpret_cast(raw_driver); @@ -3400,6 +3399,10 @@ AdbcStatusCode AdbcLoadDriverFromInitFunc(AdbcDriverInitFunc init_func, int vers FILL_DEFAULT(driver, StatementSetOptionDouble); FILL_DEFAULT(driver, StatementSetOptionInt); } + if (version >= ADBC_VERSION_1_2_0) { + auto* driver = reinterpret_cast(raw_driver); + FILL_DEFAULT(driver, StatementRequestSchema); + } return ADBC_STATUS_OK; diff --git a/c/include/arrow-adbc/adbc.h b/c/include/arrow-adbc/adbc.h index d16e47415c..70696c4a6e 100644 --- a/c/include/arrow-adbc/adbc.h +++ b/c/include/arrow-adbc/adbc.h @@ -1255,10 +1255,6 @@ struct ADBC_EXPORT AdbcDriver { AdbcStatusCode (*StatementSetOptionInt)(struct AdbcStatement*, const char*, int64_t, struct AdbcError*); - // ADBC 1.2 - AdbcStatusCode (*StatementRequestSchema)(struct AdbcStatement*, struct ArrowSchema*, - struct AdbcError*); - /// @} /// \defgroup adbc-1.2.0 ADBC API Revision 1.2.0 @@ -1294,6 +1290,9 @@ struct ADBC_EXPORT AdbcDriver { AdbcStatusCode (*StatementExecuteMulti)(struct AdbcStatement*, struct AdbcMultiResultSet*, struct AdbcError*); + AdbcStatusCode (*StatementRequestSchema)(struct AdbcStatement*, struct ArrowSchema*, + struct AdbcError*); + /// @} }; diff --git a/go/adbc/drivermgr/adbc_driver_manager.cc b/go/adbc/drivermgr/adbc_driver_manager.cc index 15d98c00bd..7cf2c424b9 100644 --- a/go/adbc/drivermgr/adbc_driver_manager.cc +++ b/go/adbc/drivermgr/adbc_driver_manager.cc @@ -1764,6 +1764,12 @@ AdbcStatusCode StatementSetSubstraitPlan(struct AdbcStatement*, const uint8_t*, return ADBC_STATUS_NOT_IMPLEMENTED; } +AdbcStatusCode StatementRequestSchema(struct AdbcStatement*, struct ArrowSchema*, + struct AdbcError* error) { + SetError(error, "AdbcStatementRequestSchema not implemented"); + return ADBC_STATUS_NOT_IMPLEMENTED; +} + /// Temporary state while the database is being configured. struct TempDatabase { std::unordered_map options; @@ -3159,6 +3165,17 @@ AdbcStatusCode AdbcStatementSetSubstraitPlan(struct AdbcStatement* statement, error); } +AdbcStatusCode AdbcStatementRequestSchema(struct AdbcStatement* statement, + struct ArrowSchema* schema, + struct AdbcError* error) { + if (!statement->private_driver) { + SetError(error, "AdbcStatementRequestSchema: must call AdbcStatementNew first"); + return ADBC_STATUS_INVALID_STATE; + } + INIT_ERROR(error, statement); + return statement->private_driver->StatementRequestSchema(statement, schema, error); +} + const char* AdbcStatusCodeMessage(AdbcStatusCode code) { #define CASE(CONSTANT) \ case ADBC_STATUS_##CONSTANT: \ @@ -3382,6 +3399,10 @@ AdbcStatusCode AdbcLoadDriverFromInitFunc(AdbcDriverInitFunc init_func, int vers FILL_DEFAULT(driver, StatementSetOptionDouble); FILL_DEFAULT(driver, StatementSetOptionInt); } + if (version >= ADBC_VERSION_1_2_0) { + auto* driver = reinterpret_cast(raw_driver); + FILL_DEFAULT(driver, StatementRequestSchema); + } return ADBC_STATUS_OK; diff --git a/go/adbc/drivermgr/arrow-adbc/adbc.h b/go/adbc/drivermgr/arrow-adbc/adbc.h index d16e47415c..70696c4a6e 100644 --- a/go/adbc/drivermgr/arrow-adbc/adbc.h +++ b/go/adbc/drivermgr/arrow-adbc/adbc.h @@ -1255,10 +1255,6 @@ struct ADBC_EXPORT AdbcDriver { AdbcStatusCode (*StatementSetOptionInt)(struct AdbcStatement*, const char*, int64_t, struct AdbcError*); - // ADBC 1.2 - AdbcStatusCode (*StatementRequestSchema)(struct AdbcStatement*, struct ArrowSchema*, - struct AdbcError*); - /// @} /// \defgroup adbc-1.2.0 ADBC API Revision 1.2.0 @@ -1294,6 +1290,9 @@ struct ADBC_EXPORT AdbcDriver { AdbcStatusCode (*StatementExecuteMulti)(struct AdbcStatement*, struct AdbcMultiResultSet*, struct AdbcError*); + AdbcStatusCode (*StatementRequestSchema)(struct AdbcStatement*, struct ArrowSchema*, + struct AdbcError*); + /// @} };