59#ifndef ARROW_FLAG_DICTIONARY_ORDERED
61#ifndef ARROW_C_DATA_INTERFACE
62#define ARROW_C_DATA_INTERFACE
64#define ARROW_FLAG_DICTIONARY_ORDERED 1
65#define ARROW_FLAG_NULLABLE 2
66#define ARROW_FLAG_MAP_KEYS_SORTED 4
75 struct ArrowSchema** children;
76 struct ArrowSchema* dictionary;
79 void (*release)(
struct ArrowSchema*);
92 struct ArrowArray** children;
93 struct ArrowArray* dictionary;
96 void (*release)(
struct ArrowArray*);
103#ifndef ARROW_C_STREAM_INTERFACE
104#define ARROW_C_STREAM_INTERFACE
106struct ArrowArrayStream {
113 int (*get_schema)(
struct ArrowArrayStream*,
struct ArrowSchema* out);
121 int (*get_next)(
struct ArrowArrayStream*,
struct ArrowArray* out);
132 const char* (*get_last_error)(
struct ArrowArrayStream*);
136 void (*release)(
struct ArrowArrayStream*);
154#if !defined(ADBC_EXPORT)
156#if defined(ADBC_EXPORTING)
157#define ADBC_EXPORT __declspec(dllexport)
159#define ADBC_EXPORT __declspec(dllimport)
179#define ADBC_STATUS_OK 0
183#define ADBC_STATUS_UNKNOWN 1
187#define ADBC_STATUS_NOT_IMPLEMENTED 2
191#define ADBC_STATUS_NOT_FOUND 3
195#define ADBC_STATUS_ALREADY_EXISTS 4
201#define ADBC_STATUS_INVALID_ARGUMENT 5
209#define ADBC_STATUS_INVALID_STATE 6
216#define ADBC_STATUS_INVALID_DATA 7
223#define ADBC_STATUS_INTEGRITY 8
227#define ADBC_STATUS_INTERNAL 9
233#define ADBC_STATUS_IO 10
237#define ADBC_STATUS_CANCELLED 11
241#define ADBC_STATUS_TIMEOUT 12
245#define ADBC_STATUS_UNAUTHENTICATED 13
249#define ADBC_STATUS_UNAUTHORIZED 14
257#define ADBC_ERROR_VENDOR_CODE_PRIVATE_DATA INT32_MIN
310#define ADBC_ERROR_INIT \
311 (AdbcError{nullptr, \
312 ADBC_ERROR_VENDOR_CODE_PRIVATE_DATA, \
321#define ADBC_ERROR_INIT \
322 ((struct AdbcError){ \
323 NULL, ADBC_ERROR_VENDOR_CODE_PRIVATE_DATA, {0, 0, 0, 0, 0}, NULL, NULL, NULL})
333#define ADBC_ERROR_1_0_0_SIZE (offsetof(struct AdbcError, private_data))
341#define ADBC_ERROR_1_1_0_SIZE (sizeof(struct AdbcError))
401#define ADBC_VERSION_1_0_0 1000000
409#define ADBC_VERSION_1_1_0 1001000
414#define ADBC_OPTION_VALUE_ENABLED "true"
418#define ADBC_OPTION_VALUE_DISABLED "false"
428#define ADBC_OPTION_URI "uri"
437#define ADBC_OPTION_USERNAME "username"
446#define ADBC_OPTION_PASSWORD "password"
452#define ADBC_INFO_VENDOR_NAME 0
456#define ADBC_INFO_VENDOR_VERSION 1
461#define ADBC_INFO_VENDOR_ARROW_VERSION 2
465#define ADBC_INFO_VENDOR_SQL 3
469#define ADBC_INFO_VENDOR_SUBSTRAIT 4
474#define ADBC_INFO_VENDOR_SUBSTRAIT_MIN_VERSION 5
479#define ADBC_INFO_VENDOR_SUBSTRAIT_MAX_VERSION 6
484#define ADBC_INFO_DRIVER_NAME 100
488#define ADBC_INFO_DRIVER_VERSION 101
492#define ADBC_INFO_DRIVER_ARROW_VERSION 102
501#define ADBC_INFO_DRIVER_ADBC_VERSION 103
506#define ADBC_OBJECT_DEPTH_ALL 0
510#define ADBC_OBJECT_DEPTH_CATALOGS 1
514#define ADBC_OBJECT_DEPTH_DB_SCHEMAS 2
518#define ADBC_OBJECT_DEPTH_TABLES 3
522#define ADBC_OBJECT_DEPTH_COLUMNS ADBC_OBJECT_DEPTH_ALL
529#define ADBC_STATISTIC_AVERAGE_BYTE_WIDTH_KEY 0
535#define ADBC_STATISTIC_AVERAGE_BYTE_WIDTH_NAME "adbc.statistic.byte_width"
537#define ADBC_STATISTIC_DISTINCT_COUNT_KEY 1
541#define ADBC_STATISTIC_DISTINCT_COUNT_NAME "adbc.statistic.distinct_count"
543#define ADBC_STATISTIC_MAX_BYTE_WIDTH_KEY 2
549#define ADBC_STATISTIC_MAX_BYTE_WIDTH_NAME "adbc.statistic.max_byte_width"
551#define ADBC_STATISTIC_MAX_VALUE_KEY 3
553#define ADBC_STATISTIC_MAX_VALUE_NAME "adbc.statistic.max_value"
555#define ADBC_STATISTIC_MIN_VALUE_KEY 4
557#define ADBC_STATISTIC_MIN_VALUE_NAME "adbc.statistic.min_value"
559#define ADBC_STATISTIC_NULL_COUNT_KEY 5
563#define ADBC_STATISTIC_NULL_COUNT_NAME "adbc.statistic.null_count"
565#define ADBC_STATISTIC_ROW_COUNT_KEY 6
569#define ADBC_STATISTIC_ROW_COUNT_NAME "adbc.statistic.row_count"
578#define ADBC_CONNECTION_OPTION_AUTOCOMMIT "adbc.connection.autocommit"
586#define ADBC_CONNECTION_OPTION_READ_ONLY "adbc.connection.readonly"
595#define ADBC_CONNECTION_OPTION_CURRENT_CATALOG "adbc.connection.catalog"
604#define ADBC_CONNECTION_OPTION_CURRENT_DB_SCHEMA "adbc.connection.db_schema"
621#define ADBC_STATEMENT_OPTION_INCREMENTAL "adbc.statement.exec.incremental"
636#define ADBC_STATEMENT_OPTION_PROGRESS "adbc.statement.exec.progress"
649#define ADBC_STATEMENT_OPTION_MAX_PROGRESS "adbc.statement.exec.max_progress"
662#define ADBC_CONNECTION_OPTION_ISOLATION_LEVEL \
663 "adbc.connection.transaction.isolation_level"
668#define ADBC_OPTION_ISOLATION_LEVEL_DEFAULT \
669 "adbc.connection.transaction.isolation.default"
675#define ADBC_OPTION_ISOLATION_LEVEL_READ_UNCOMMITTED \
676 "adbc.connection.transaction.isolation.read_uncommitted"
691#define ADBC_OPTION_ISOLATION_LEVEL_READ_COMMITTED \
692 "adbc.connection.transaction.isolation.read_committed"
701#define ADBC_OPTION_ISOLATION_LEVEL_REPEATABLE_READ \
702 "adbc.connection.transaction.isolation.repeatable_read"
710#define ADBC_OPTION_ISOLATION_LEVEL_SNAPSHOT \
711 "adbc.connection.transaction.isolation.snapshot"
719#define ADBC_OPTION_ISOLATION_LEVEL_SERIALIZABLE \
720 "adbc.connection.transaction.isolation.serializable"
732#define ADBC_OPTION_ISOLATION_LEVEL_LINEARIZABLE \
733 "adbc.connection.transaction.isolation.linearizable"
755#define ADBC_INGEST_OPTION_TARGET_TABLE "adbc.ingest.target_table"
759#define ADBC_INGEST_OPTION_MODE "adbc.ingest.mode"
761#define ADBC_INGEST_OPTION_MODE_CREATE "adbc.ingest.mode.create"
765#define ADBC_INGEST_OPTION_MODE_APPEND "adbc.ingest.mode.append"
769#define ADBC_INGEST_OPTION_MODE_REPLACE "adbc.ingest.mode.replace"
774#define ADBC_INGEST_OPTION_MODE_CREATE_APPEND "adbc.ingest.mode.create_append"
778#define ADBC_INGEST_OPTION_TARGET_CATALOG "adbc.ingest.target_catalog"
782#define ADBC_INGEST_OPTION_TARGET_DB_SCHEMA "adbc.ingest.target_db_schema"
792#define ADBC_INGEST_OPTION_TEMPORARY "adbc.ingest.temporary"
960 struct ArrowArrayStream*,
struct AdbcError*);
962 const char*,
const char*,
const char**,
963 const char*,
struct ArrowArrayStream*,
966 const char*,
const char*,
969 struct ArrowArrayStream*,
struct AdbcError*);
976 size_t,
struct ArrowArrayStream*,
1025 int (*ErrorGetDetailCount)(
const struct AdbcError* error);
1027 const struct AdbcError* (*ErrorFromArrayStream)(
struct ArrowArrayStream* stream,
1039 const uint8_t*, size_t,
struct AdbcError*);
1055 const char*,
const char*, char,
1056 struct ArrowArrayStream*,
struct AdbcError*);
1058 struct ArrowArrayStream*,
1061 const uint8_t*, size_t,
struct AdbcError*);
1079 const uint8_t*, size_t,
struct AdbcError*);
1094#define ADBC_DRIVER_1_0_0_SIZE (offsetof(struct AdbcDriver, ErrorGetDetailCount))
1102#define ADBC_DRIVER_1_1_0_SIZE (sizeof(struct AdbcDriver))
1157 char* value,
size_t* length,
1197 uint8_t* value,
size_t* length,
1221 double* value,
struct AdbcError* error);
1244 int64_t* value,
struct AdbcError* error);
1259 const char* value,
struct AdbcError* error);
1273 const uint8_t* value,
size_t length,
1300 int64_t value,
struct AdbcError* error);
1346 const char* value,
struct AdbcError* error);
1360 const char* key,
const uint8_t* value,
1361 size_t length,
struct AdbcError* error);
1377 const char* key, int64_t value,
1394 const char* key,
double value,
1500 const uint32_t* info_codes,
size_t info_codes_length,
1501 struct ArrowArrayStream* out,
1610 const char* catalog,
const char* db_schema,
1611 const char* table_name,
const char** table_type,
1612 const char* column_name,
1613 struct ArrowArrayStream* out,
1646 char* value,
size_t* length,
1686 const char* key, uint8_t* value,
1687 size_t* length,
struct AdbcError* error);
1710 const char* key, int64_t* value,
1734 const char* key,
double* value,
1799 const char* catalog,
const char* db_schema,
1800 const char* table_name,
char approximate,
1801 struct ArrowArrayStream* out,
1819 struct ArrowArrayStream* out,
1832 const char* catalog,
const char* db_schema,
1833 const char* table_name,
1834 struct ArrowSchema* schema,
1852 struct ArrowArrayStream* out,
1885 const uint8_t* serialized_partition,
1886 size_t serialized_length,
1887 struct ArrowArrayStream* out,
1961 struct ArrowArrayStream* out,
1962 int64_t* rows_affected,
struct AdbcError* error);
1982 struct ArrowSchema* schema,
2011 const char* query,
struct AdbcError* error);
2034 const uint8_t* plan,
size_t length,
2051 struct ArrowArray* values,
struct ArrowSchema* schema,
2064 struct ArrowArrayStream* stream,
2129 char* value,
size_t* length,
2169 const char* key, uint8_t* value,
2170 size_t* length,
struct AdbcError* error);
2193 int64_t* value,
struct AdbcError* error);
2216 const char* key,
double* value,
2236 struct ArrowSchema* schema,
2248 const char* value,
struct AdbcError* error);
2262 const char* key,
const uint8_t* value,
2263 size_t length,
struct AdbcError* error);
2276 int64_t value,
struct AdbcError* error);
2289 const char* key,
double value,
2309 struct ArrowSchema* schema,
2311 int64_t* rows_affected,
AdbcStatusCode AdbcConnectionReadPartition(struct AdbcConnection *connection, const uint8_t *serialized_partition, size_t serialized_length, struct ArrowArrayStream *out, struct AdbcError *error)
Construct a statement for a partition of a query. The results can then be read independently.
AdbcStatusCode AdbcConnectionCommit(struct AdbcConnection *connection, struct AdbcError *error)
Commit any pending transactions. Only used if autocommit is disabled.
AdbcStatusCode AdbcConnectionRollback(struct AdbcConnection *connection, struct AdbcError *error)
Roll back any pending transactions. Only used if autocommit is disabled.
void * private_data
Opaque implementation-defined state. This field is NULLPTR iff the connection is unintialized/freed.
Definition adbc.h:834
struct AdbcDriver * private_driver
The associated driver (used by the driver manager to help track state).
Definition adbc.h:837
AdbcStatusCode AdbcConnectionSetOption(struct AdbcConnection *connection, const char *key, const char *value, struct AdbcError *error)
Set a char* option.
AdbcStatusCode AdbcConnectionCancel(struct AdbcConnection *connection, struct AdbcError *error)
Cancel the in-progress operation on a connection.
AdbcStatusCode AdbcConnectionNew(struct AdbcConnection *connection, struct AdbcError *error)
Allocate a new (but uninitialized) connection.
AdbcStatusCode AdbcConnectionSetOptionInt(struct AdbcConnection *connection, const char *key, int64_t value, struct AdbcError *error)
Set an integer option.
AdbcStatusCode AdbcConnectionSetOptionBytes(struct AdbcConnection *connection, const char *key, const uint8_t *value, size_t length, struct AdbcError *error)
Set a bytestring option on a connection.
AdbcStatusCode AdbcConnectionRelease(struct AdbcConnection *connection, struct AdbcError *error)
Destroy this connection.
AdbcStatusCode AdbcConnectionInit(struct AdbcConnection *connection, struct AdbcDatabase *database, struct AdbcError *error)
Finish setting options and initialize the connection.
AdbcStatusCode AdbcConnectionSetOptionDouble(struct AdbcConnection *connection, const char *key, double value, struct AdbcError *error)
Set a double option.
An active database connection.
Definition adbc.h:831
void * private_data
Opaque implementation-defined state. This field is NULLPTR iff the connection is unintialized/freed.
Definition adbc.h:811
struct AdbcDriver * private_driver
The associated driver (used by the driver manager to help track state).
Definition adbc.h:814
AdbcStatusCode AdbcDatabaseSetOptionDouble(struct AdbcDatabase *database, const char *key, double value, struct AdbcError *error)
Set a double option on a database.
AdbcStatusCode AdbcDatabaseGetOptionBytes(struct AdbcDatabase *database, const char *key, uint8_t *value, size_t *length, struct AdbcError *error)
Get a bytestring option of the database.
AdbcStatusCode AdbcDatabaseGetOptionInt(struct AdbcDatabase *database, const char *key, int64_t *value, struct AdbcError *error)
Get an integer option of the database.
AdbcStatusCode AdbcDatabaseNew(struct AdbcDatabase *database, struct AdbcError *error)
Allocate a new (but uninitialized) database.
AdbcStatusCode AdbcDatabaseRelease(struct AdbcDatabase *database, struct AdbcError *error)
Destroy this database. No connections may exist.
AdbcStatusCode AdbcDatabaseInit(struct AdbcDatabase *database, struct AdbcError *error)
Finish setting options and initialize the database.
AdbcStatusCode AdbcDatabaseGetOptionDouble(struct AdbcDatabase *database, const char *key, double *value, struct AdbcError *error)
Get a double option of the database.
AdbcStatusCode AdbcDatabaseSetOption(struct AdbcDatabase *database, const char *key, const char *value, struct AdbcError *error)
Set a char* option.
AdbcStatusCode AdbcDatabaseGetOption(struct AdbcDatabase *database, const char *key, char *value, size_t *length, struct AdbcError *error)
Get a string option of the database.
AdbcStatusCode AdbcDatabaseSetOptionInt(struct AdbcDatabase *database, const char *key, int64_t value, struct AdbcError *error)
Set an integer option on a database.
AdbcStatusCode AdbcDatabaseSetOptionBytes(struct AdbcDatabase *database, const char *key, const uint8_t *value, size_t length, struct AdbcError *error)
Set a bytestring option on a database.
An instance of a database.
Definition adbc.h:808
void * private_manager
Opaque driver manager-defined state. This field is NULL if the driver is unintialized/freed (but it n...
Definition adbc.h:944
void * private_data
Opaque driver-defined state. This field is NULL if the driver is unintialized/freed (but it need not ...
Definition adbc.h:940
AdbcStatusCode(* AdbcDriverInitFunc)(int version, void *driver, struct AdbcError *error)
Common entry point for drivers via the driver manager (which uses dlopen(3)/LoadLibrary)....
Definition adbc.h:2347
An instance of an initialized database driver.
Definition adbc.h:936
int32_t vendor_code
A vendor-specific error code, if applicable.
Definition adbc.h:274
void * private_data
Opaque implementation-defined state.
Definition adbc.h:294
const char * key
The metadata key.
Definition adbc.h:352
char * message
The error message.
Definition adbc.h:271
struct AdbcDriver * private_driver
The associated driver (used by the driver manager to help track state).
Definition adbc.h:303
size_t value_length
The length of the metadata value.
Definition adbc.h:356
const uint8_t * value
The binary metadata value.
Definition adbc.h:354
const struct AdbcError * AdbcErrorFromArrayStream(struct ArrowArrayStream *stream, AdbcStatusCode *status)
Get an ADBC error from an ArrowArrayStream created by a driver.
uint8_t AdbcStatusCode
Error codes for operations that may fail.
Definition adbc.h:176
int AdbcErrorGetDetailCount(const struct AdbcError *error)
Get the number of metadata values available in an error.
struct AdbcErrorDetail AdbcErrorGetDetail(const struct AdbcError *error, int index)
Get a metadata value in an error by index.
A detailed error message for an operation.
Definition adbc.h:269
Extra key-value metadata for an error.
Definition adbc.h:350
const size_t * partition_lengths
The length of each corresponding entry in partitions.
Definition adbc.h:907
void * private_data
Opaque implementation-defined state. This field is NULLPTR iff the connection is unintialized/freed.
Definition adbc.h:911
void(* release)(struct AdbcPartitions *partitions)
Release the contained partitions.
Definition adbc.h:917
size_t num_partitions
The number of partitions.
Definition adbc.h:899
const uint8_t ** partitions
The partitions of the result set, where each entry (up to num_partitions entries) is an opaque identi...
Definition adbc.h:904
AdbcStatusCode AdbcStatementExecutePartitions(struct AdbcStatement *statement, struct ArrowSchema *schema, struct AdbcPartitions *partitions, int64_t *rows_affected, struct AdbcError *error)
Execute a statement and get the results as a partitioned result set.
The partitions of a distributed/partitioned result set.
Definition adbc.h:897
AdbcStatusCode AdbcStatementSetSqlQuery(struct AdbcStatement *statement, const char *query, struct AdbcError *error)
Set the SQL query to execute.
AdbcStatusCode AdbcStatementSetSubstraitPlan(struct AdbcStatement *statement, const uint8_t *plan, size_t length, struct AdbcError *error)
Set the Substrait plan to execute.
void * private_data
Opaque implementation-defined state. This field is NULLPTR iff the connection is unintialized/freed.
Definition adbc.h:872
struct AdbcDriver * private_driver
The associated driver (used by the driver manager to help track state).
Definition adbc.h:876
AdbcStatusCode AdbcStatementExecuteQuery(struct AdbcStatement *statement, struct ArrowArrayStream *out, int64_t *rows_affected, struct AdbcError *error)
Execute a statement and get the results.
AdbcStatusCode AdbcStatementCancel(struct AdbcStatement *statement, struct AdbcError *error)
Cancel execution of an in-progress query.
AdbcStatusCode AdbcStatementGetParameterSchema(struct AdbcStatement *statement, struct ArrowSchema *schema, struct AdbcError *error)
Get the schema for bound parameters.
AdbcStatusCode AdbcStatementSetOptionInt(struct AdbcStatement *statement, const char *key, int64_t value, struct AdbcError *error)
Set an integer option on a statement.
AdbcStatusCode AdbcStatementExecuteSchema(struct AdbcStatement *statement, struct ArrowSchema *schema, struct AdbcError *error)
Get the schema of the result set of a query without executing it.
AdbcStatusCode AdbcStatementRelease(struct AdbcStatement *statement, struct AdbcError *error)
Destroy a statement.
AdbcStatusCode AdbcStatementSetOption(struct AdbcStatement *statement, const char *key, const char *value, struct AdbcError *error)
Set a string option on a statement.
AdbcStatusCode AdbcStatementPrepare(struct AdbcStatement *statement, struct AdbcError *error)
Turn this statement into a prepared statement to be executed multiple times.
AdbcStatusCode AdbcStatementGetOptionDouble(struct AdbcStatement *statement, const char *key, double *value, struct AdbcError *error)
Get a double option of the statement.
AdbcStatusCode AdbcStatementSetOptionBytes(struct AdbcStatement *statement, const char *key, const uint8_t *value, size_t length, struct AdbcError *error)
Set a bytestring option on a statement.
AdbcStatusCode AdbcStatementBindStream(struct AdbcStatement *statement, struct ArrowArrayStream *stream, struct AdbcError *error)
Bind Arrow data. This can be used for bulk inserts or prepared statements.
AdbcStatusCode AdbcStatementBind(struct AdbcStatement *statement, struct ArrowArray *values, struct ArrowSchema *schema, struct AdbcError *error)
Bind Arrow data. This can be used for bulk inserts or prepared statements.
AdbcStatusCode AdbcStatementGetOption(struct AdbcStatement *statement, const char *key, char *value, size_t *length, struct AdbcError *error)
Get a string option of the statement.
AdbcStatusCode AdbcStatementGetOptionInt(struct AdbcStatement *statement, const char *key, int64_t *value, struct AdbcError *error)
Get an integer option of the statement.
AdbcStatusCode AdbcStatementNew(struct AdbcConnection *connection, struct AdbcStatement *statement, struct AdbcError *error)
Create a new statement for a given connection.
AdbcStatusCode AdbcStatementGetOptionBytes(struct AdbcStatement *statement, const char *key, uint8_t *value, size_t *length, struct AdbcError *error)
Get a bytestring option of the statement.
AdbcStatusCode AdbcStatementSetOptionDouble(struct AdbcStatement *statement, const char *key, double value, struct AdbcError *error)
Set a double option on a statement.
A container for all state needed to execute a database query, such as the query itself,...
Definition adbc.h:869