ADBC
Arrow Database Connectivity
Loading...
Searching...
No Matches
adbc.h
Go to the documentation of this file.
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
39
40#pragma once
41
42#include <stddef.h>
43#include <stdint.h>
44
51
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
58// Extra guard for versions of Arrow without the canonical guard
59#ifndef ARROW_FLAG_DICTIONARY_ORDERED
60
61#ifndef ARROW_C_DATA_INTERFACE
62#define ARROW_C_DATA_INTERFACE
63
64#define ARROW_FLAG_DICTIONARY_ORDERED 1
65#define ARROW_FLAG_NULLABLE 2
66#define ARROW_FLAG_MAP_KEYS_SORTED 4
67
68struct ArrowSchema {
69 // Array type description
70 const char* format;
71 const char* name;
72 const char* metadata;
73 int64_t flags;
74 int64_t n_children;
75 struct ArrowSchema** children;
76 struct ArrowSchema* dictionary;
77
78 // Release callback
79 void (*release)(struct ArrowSchema*);
80 // Opaque producer-specific data
81 void* private_data;
82};
83
84struct ArrowArray {
85 // Array data description
86 int64_t length;
87 int64_t null_count;
88 int64_t offset;
89 int64_t n_buffers;
90 int64_t n_children;
91 const void** buffers;
92 struct ArrowArray** children;
93 struct ArrowArray* dictionary;
94
95 // Release callback
96 void (*release)(struct ArrowArray*);
97 // Opaque producer-specific data
98 void* private_data;
99};
100
101#endif // ARROW_C_DATA_INTERFACE
102
103#ifndef ARROW_C_STREAM_INTERFACE
104#define ARROW_C_STREAM_INTERFACE
105
106struct ArrowArrayStream {
107 // Callback to get the stream type
108 // (will be the same for all arrays in the stream).
109 //
110 // Return value: 0 if successful, an `errno`-compatible error code otherwise.
111 //
112 // If successful, the ArrowSchema must be released independently from the stream.
113 int (*get_schema)(struct ArrowArrayStream*, struct ArrowSchema* out);
114
115 // Callback to get the next array
116 // (if no error and the array is released, the stream has ended)
117 //
118 // Return value: 0 if successful, an `errno`-compatible error code otherwise.
119 //
120 // If successful, the ArrowArray must be released independently from the stream.
121 int (*get_next)(struct ArrowArrayStream*, struct ArrowArray* out);
122
123 // Callback to get optional detailed error information.
124 // This must only be called if the last stream operation failed
125 // with a non-0 return code.
126 //
127 // Return value: pointer to a null-terminated character array describing
128 // the last error, or NULL if no description is available.
129 //
130 // The returned pointer is only valid until the next operation on this stream
131 // (including release).
132 const char* (*get_last_error)(struct ArrowArrayStream*);
133
134 // Release callback: release the stream's own resources.
135 // Note that arrays returned by `get_next` must be individually released.
136 void (*release)(struct ArrowArrayStream*);
137
138 // Opaque producer-specific data
139 void* private_data;
140};
141
142#endif // ARROW_C_STREAM_INTERFACE
143#endif // ARROW_FLAG_DICTIONARY_ORDERED
144
146
148
149#ifndef ADBC
150#define ADBC
151
152// Storage class macros for Windows
153// Allow overriding/aliasing with application-defined macros
154#if !defined(ADBC_EXPORT)
155#if defined(_WIN32)
156#if defined(ADBC_EXPORTING)
157#define ADBC_EXPORT __declspec(dllexport)
158#else
159#define ADBC_EXPORT __declspec(dllimport)
160#endif // defined(ADBC_EXPORTING)
161#else
162#define ADBC_EXPORT
163#endif // defined(_WIN32)
164#endif // !defined(ADBC_EXPORT)
165
174
176typedef uint8_t AdbcStatusCode;
177
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
250
257#define ADBC_ERROR_VENDOR_CODE_PRIVATE_DATA INT32_MIN
258
269struct ADBC_EXPORT AdbcError {
271 char* message;
272
274 int32_t vendor_code;
275
279 char sqlstate[5];
280
285 void (*release)(struct AdbcError* error);
286
295
304};
305
306#ifdef __cplusplus
310#define ADBC_ERROR_INIT \
311 (AdbcError{nullptr, \
312 ADBC_ERROR_VENDOR_CODE_PRIVATE_DATA, \
313 {0, 0, 0, 0, 0}, \
314 nullptr, \
315 nullptr, \
316 nullptr})
317#else
321#define ADBC_ERROR_INIT \
322 ((struct AdbcError){ \
323 NULL, ADBC_ERROR_VENDOR_CODE_PRIVATE_DATA, {0, 0, 0, 0, 0}, NULL, NULL, NULL})
324#endif
325
333#define ADBC_ERROR_1_0_0_SIZE (offsetof(struct AdbcError, private_data))
341#define ADBC_ERROR_1_1_0_SIZE (sizeof(struct AdbcError))
342
350struct ADBC_EXPORT AdbcErrorDetail {
352 const char* key;
354 const uint8_t* value;
357};
358
362ADBC_EXPORT
363int AdbcErrorGetDetailCount(const struct AdbcError* error);
364
371ADBC_EXPORT
372struct AdbcErrorDetail AdbcErrorGetDetail(const struct AdbcError* error, int index);
373
388ADBC_EXPORT
389const struct AdbcError* AdbcErrorFromArrayStream(struct ArrowArrayStream* stream,
390 AdbcStatusCode* status);
391
393
396
401#define ADBC_VERSION_1_0_0 1000000
402
409#define ADBC_VERSION_1_1_0 1001000
410
414#define ADBC_OPTION_VALUE_ENABLED "true"
418#define ADBC_OPTION_VALUE_DISABLED "false"
419
428#define ADBC_OPTION_URI "uri"
437#define ADBC_OPTION_USERNAME "username"
446#define ADBC_OPTION_PASSWORD "password"
447
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
480
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
502
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
523
527
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"
571
578#define ADBC_CONNECTION_OPTION_AUTOCOMMIT "adbc.connection.autocommit"
579
586#define ADBC_CONNECTION_OPTION_READ_ONLY "adbc.connection.readonly"
587
595#define ADBC_CONNECTION_OPTION_CURRENT_CATALOG "adbc.connection.catalog"
596
604#define ADBC_CONNECTION_OPTION_CURRENT_DB_SCHEMA "adbc.connection.db_schema"
605
621#define ADBC_STATEMENT_OPTION_INCREMENTAL "adbc.statement.exec.incremental"
622
636#define ADBC_STATEMENT_OPTION_PROGRESS "adbc.statement.exec.progress"
637
649#define ADBC_STATEMENT_OPTION_MAX_PROGRESS "adbc.statement.exec.max_progress"
650
662#define ADBC_CONNECTION_OPTION_ISOLATION_LEVEL \
663 "adbc.connection.transaction.isolation_level"
664
668#define ADBC_OPTION_ISOLATION_LEVEL_DEFAULT \
669 "adbc.connection.transaction.isolation.default"
670
675#define ADBC_OPTION_ISOLATION_LEVEL_READ_UNCOMMITTED \
676 "adbc.connection.transaction.isolation.read_uncommitted"
677
691#define ADBC_OPTION_ISOLATION_LEVEL_READ_COMMITTED \
692 "adbc.connection.transaction.isolation.read_committed"
693
701#define ADBC_OPTION_ISOLATION_LEVEL_REPEATABLE_READ \
702 "adbc.connection.transaction.isolation.repeatable_read"
703
710#define ADBC_OPTION_ISOLATION_LEVEL_SNAPSHOT \
711 "adbc.connection.transaction.isolation.snapshot"
712
719#define ADBC_OPTION_ISOLATION_LEVEL_SERIALIZABLE \
720 "adbc.connection.transaction.isolation.serializable"
721
732#define ADBC_OPTION_ISOLATION_LEVEL_LINEARIZABLE \
733 "adbc.connection.transaction.isolation.linearizable"
734
746
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"
793
795
797
804
808struct ADBC_EXPORT AdbcDatabase {
815};
816
818
822
831struct ADBC_EXPORT AdbcConnection {
838};
839
841
850
869struct ADBC_EXPORT AdbcStatement {
873
877};
878
895
900
904 const uint8_t** partitions;
905
907 const size_t* partition_lengths;
908
912
918};
919
921
923
929
936struct ADBC_EXPORT AdbcDriver {
945
950 AdbcStatusCode (*release)(struct AdbcDriver* driver, struct AdbcError* error);
951
952 AdbcStatusCode (*DatabaseInit)(struct AdbcDatabase*, struct AdbcError*);
953 AdbcStatusCode (*DatabaseNew)(struct AdbcDatabase*, struct AdbcError*);
954 AdbcStatusCode (*DatabaseSetOption)(struct AdbcDatabase*, const char*, const char*,
955 struct AdbcError*);
956 AdbcStatusCode (*DatabaseRelease)(struct AdbcDatabase*, struct AdbcError*);
957
958 AdbcStatusCode (*ConnectionCommit)(struct AdbcConnection*, struct AdbcError*);
959 AdbcStatusCode (*ConnectionGetInfo)(struct AdbcConnection*, const uint32_t*, size_t,
960 struct ArrowArrayStream*, struct AdbcError*);
961 AdbcStatusCode (*ConnectionGetObjects)(struct AdbcConnection*, int, const char*,
962 const char*, const char*, const char**,
963 const char*, struct ArrowArrayStream*,
964 struct AdbcError*);
965 AdbcStatusCode (*ConnectionGetTableSchema)(struct AdbcConnection*, const char*,
966 const char*, const char*,
967 struct ArrowSchema*, struct AdbcError*);
968 AdbcStatusCode (*ConnectionGetTableTypes)(struct AdbcConnection*,
969 struct ArrowArrayStream*, struct AdbcError*);
970 AdbcStatusCode (*ConnectionInit)(struct AdbcConnection*, struct AdbcDatabase*,
971 struct AdbcError*);
972 AdbcStatusCode (*ConnectionNew)(struct AdbcConnection*, struct AdbcError*);
973 AdbcStatusCode (*ConnectionSetOption)(struct AdbcConnection*, const char*, const char*,
974 struct AdbcError*);
975 AdbcStatusCode (*ConnectionReadPartition)(struct AdbcConnection*, const uint8_t*,
976 size_t, struct ArrowArrayStream*,
977 struct AdbcError*);
978 AdbcStatusCode (*ConnectionRelease)(struct AdbcConnection*, struct AdbcError*);
979 AdbcStatusCode (*ConnectionRollback)(struct AdbcConnection*, struct AdbcError*);
980
981 AdbcStatusCode (*StatementBind)(struct AdbcStatement*, struct ArrowArray*,
982 struct ArrowSchema*, struct AdbcError*);
983 AdbcStatusCode (*StatementBindStream)(struct AdbcStatement*, struct ArrowArrayStream*,
984 struct AdbcError*);
985 AdbcStatusCode (*StatementExecuteQuery)(struct AdbcStatement*, struct ArrowArrayStream*,
986 int64_t*, struct AdbcError*);
987 AdbcStatusCode (*StatementExecutePartitions)(struct AdbcStatement*, struct ArrowSchema*,
988 struct AdbcPartitions*, int64_t*,
989 struct AdbcError*);
990 AdbcStatusCode (*StatementGetParameterSchema)(struct AdbcStatement*,
991 struct ArrowSchema*, struct AdbcError*);
992 AdbcStatusCode (*StatementNew)(struct AdbcConnection*, struct AdbcStatement*,
993 struct AdbcError*);
994 AdbcStatusCode (*StatementPrepare)(struct AdbcStatement*, struct AdbcError*);
995 AdbcStatusCode (*StatementRelease)(struct AdbcStatement*, struct AdbcError*);
996 AdbcStatusCode (*StatementSetOption)(struct AdbcStatement*, const char*, const char*,
997 struct AdbcError*);
998 AdbcStatusCode (*StatementSetSqlQuery)(struct AdbcStatement*, const char*,
999 struct AdbcError*);
1000 AdbcStatusCode (*StatementSetSubstraitPlan)(struct AdbcStatement*, const uint8_t*,
1001 size_t, struct AdbcError*);
1002
1024
1025 int (*ErrorGetDetailCount)(const struct AdbcError* error);
1026 struct AdbcErrorDetail (*ErrorGetDetail)(const struct AdbcError* error, int index);
1027 const struct AdbcError* (*ErrorFromArrayStream)(struct ArrowArrayStream* stream,
1028 AdbcStatusCode* status);
1029
1030 AdbcStatusCode (*DatabaseGetOption)(struct AdbcDatabase*, const char*, char*, size_t*,
1031 struct AdbcError*);
1032 AdbcStatusCode (*DatabaseGetOptionBytes)(struct AdbcDatabase*, const char*, uint8_t*,
1033 size_t*, struct AdbcError*);
1034 AdbcStatusCode (*DatabaseGetOptionDouble)(struct AdbcDatabase*, const char*, double*,
1035 struct AdbcError*);
1036 AdbcStatusCode (*DatabaseGetOptionInt)(struct AdbcDatabase*, const char*, int64_t*,
1037 struct AdbcError*);
1038 AdbcStatusCode (*DatabaseSetOptionBytes)(struct AdbcDatabase*, const char*,
1039 const uint8_t*, size_t, struct AdbcError*);
1040 AdbcStatusCode (*DatabaseSetOptionDouble)(struct AdbcDatabase*, const char*, double,
1041 struct AdbcError*);
1042 AdbcStatusCode (*DatabaseSetOptionInt)(struct AdbcDatabase*, const char*, int64_t,
1043 struct AdbcError*);
1044
1045 AdbcStatusCode (*ConnectionCancel)(struct AdbcConnection*, struct AdbcError*);
1046 AdbcStatusCode (*ConnectionGetOption)(struct AdbcConnection*, const char*, char*,
1047 size_t*, struct AdbcError*);
1048 AdbcStatusCode (*ConnectionGetOptionBytes)(struct AdbcConnection*, const char*,
1049 uint8_t*, size_t*, struct AdbcError*);
1050 AdbcStatusCode (*ConnectionGetOptionDouble)(struct AdbcConnection*, const char*,
1051 double*, struct AdbcError*);
1052 AdbcStatusCode (*ConnectionGetOptionInt)(struct AdbcConnection*, const char*, int64_t*,
1053 struct AdbcError*);
1054 AdbcStatusCode (*ConnectionGetStatistics)(struct AdbcConnection*, const char*,
1055 const char*, const char*, char,
1056 struct ArrowArrayStream*, struct AdbcError*);
1057 AdbcStatusCode (*ConnectionGetStatisticNames)(struct AdbcConnection*,
1058 struct ArrowArrayStream*,
1059 struct AdbcError*);
1060 AdbcStatusCode (*ConnectionSetOptionBytes)(struct AdbcConnection*, const char*,
1061 const uint8_t*, size_t, struct AdbcError*);
1062 AdbcStatusCode (*ConnectionSetOptionDouble)(struct AdbcConnection*, const char*, double,
1063 struct AdbcError*);
1064 AdbcStatusCode (*ConnectionSetOptionInt)(struct AdbcConnection*, const char*, int64_t,
1065 struct AdbcError*);
1066
1067 AdbcStatusCode (*StatementCancel)(struct AdbcStatement*, struct AdbcError*);
1068 AdbcStatusCode (*StatementExecuteSchema)(struct AdbcStatement*, struct ArrowSchema*,
1069 struct AdbcError*);
1070 AdbcStatusCode (*StatementGetOption)(struct AdbcStatement*, const char*, char*, size_t*,
1071 struct AdbcError*);
1072 AdbcStatusCode (*StatementGetOptionBytes)(struct AdbcStatement*, const char*, uint8_t*,
1073 size_t*, struct AdbcError*);
1074 AdbcStatusCode (*StatementGetOptionDouble)(struct AdbcStatement*, const char*, double*,
1075 struct AdbcError*);
1076 AdbcStatusCode (*StatementGetOptionInt)(struct AdbcStatement*, const char*, int64_t*,
1077 struct AdbcError*);
1078 AdbcStatusCode (*StatementSetOptionBytes)(struct AdbcStatement*, const char*,
1079 const uint8_t*, size_t, struct AdbcError*);
1080 AdbcStatusCode (*StatementSetOptionDouble)(struct AdbcStatement*, const char*, double,
1081 struct AdbcError*);
1082 AdbcStatusCode (*StatementSetOptionInt)(struct AdbcStatement*, const char*, int64_t,
1083 struct AdbcError*);
1084
1086};
1087
1094#define ADBC_DRIVER_1_0_0_SIZE (offsetof(struct AdbcDriver, ErrorGetDetailCount))
1095
1102#define ADBC_DRIVER_1_1_0_SIZE (sizeof(struct AdbcDriver))
1103
1105
1108
1116ADBC_EXPORT
1117AdbcStatusCode AdbcDatabaseNew(struct AdbcDatabase* database, struct AdbcError* error);
1118
1155ADBC_EXPORT
1156AdbcStatusCode AdbcDatabaseGetOption(struct AdbcDatabase* database, const char* key,
1157 char* value, size_t* length,
1158 struct AdbcError* error);
1159
1195ADBC_EXPORT
1197 uint8_t* value, size_t* length,
1198 struct AdbcError* error);
1199
1219ADBC_EXPORT
1221 double* value, struct AdbcError* error);
1222
1242ADBC_EXPORT
1243AdbcStatusCode AdbcDatabaseGetOptionInt(struct AdbcDatabase* database, const char* key,
1244 int64_t* value, struct AdbcError* error);
1245
1257ADBC_EXPORT
1258AdbcStatusCode AdbcDatabaseSetOption(struct AdbcDatabase* database, const char* key,
1259 const char* value, struct AdbcError* error);
1260
1271ADBC_EXPORT
1273 const uint8_t* value, size_t length,
1274 struct AdbcError* error);
1275
1285ADBC_EXPORT
1287 double value, struct AdbcError* error);
1288
1298ADBC_EXPORT
1299AdbcStatusCode AdbcDatabaseSetOptionInt(struct AdbcDatabase* database, const char* key,
1300 int64_t value, struct AdbcError* error);
1301
1306ADBC_EXPORT
1308
1313ADBC_EXPORT
1315 struct AdbcError* error);
1316
1318
1321
1329ADBC_EXPORT
1331 struct AdbcError* error);
1332
1344ADBC_EXPORT
1345AdbcStatusCode AdbcConnectionSetOption(struct AdbcConnection* connection, const char* key,
1346 const char* value, struct AdbcError* error);
1347
1358ADBC_EXPORT
1360 const char* key, const uint8_t* value,
1361 size_t length, struct AdbcError* error);
1362
1375ADBC_EXPORT
1377 const char* key, int64_t value,
1378 struct AdbcError* error);
1379
1392ADBC_EXPORT
1394 const char* key, double value,
1395 struct AdbcError* error);
1396
1401ADBC_EXPORT
1403 struct AdbcDatabase* database, struct AdbcError* error);
1404
1410ADBC_EXPORT
1412 struct AdbcError* error);
1413
1434ADBC_EXPORT
1436 struct AdbcError* error);
1437
1461
1498ADBC_EXPORT
1500 const uint32_t* info_codes, size_t info_codes_length,
1501 struct ArrowArrayStream* out,
1502 struct AdbcError* error);
1503
1608ADBC_EXPORT
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,
1614 struct AdbcError* error);
1615
1644ADBC_EXPORT
1645AdbcStatusCode AdbcConnectionGetOption(struct AdbcConnection* connection, const char* key,
1646 char* value, size_t* length,
1647 struct AdbcError* error);
1648
1684ADBC_EXPORT
1686 const char* key, uint8_t* value,
1687 size_t* length, struct AdbcError* error);
1688
1708ADBC_EXPORT
1710 const char* key, int64_t* value,
1711 struct AdbcError* error);
1712
1732ADBC_EXPORT
1734 const char* key, double* value,
1735 struct AdbcError* error);
1736
1797ADBC_EXPORT
1799 const char* catalog, const char* db_schema,
1800 const char* table_name, char approximate,
1801 struct ArrowArrayStream* out,
1802 struct AdbcError* error);
1803
1817ADBC_EXPORT
1819 struct ArrowArrayStream* out,
1820 struct AdbcError* error);
1821
1830ADBC_EXPORT
1832 const char* catalog, const char* db_schema,
1833 const char* table_name,
1834 struct ArrowSchema* schema,
1835 struct AdbcError* error);
1836
1850ADBC_EXPORT
1852 struct ArrowArrayStream* out,
1853 struct AdbcError* error);
1854
1856
1869
1883ADBC_EXPORT
1885 const uint8_t* serialized_partition,
1886 size_t serialized_length,
1887 struct ArrowArrayStream* out,
1888 struct AdbcError* error);
1889
1891
1899
1905ADBC_EXPORT
1907 struct AdbcError* error);
1908
1914ADBC_EXPORT
1916 struct AdbcError* error);
1917
1919
1921
1924
1932ADBC_EXPORT
1934 struct AdbcStatement* statement, struct AdbcError* error);
1935
1940ADBC_EXPORT
1942 struct AdbcError* error);
1943
1959ADBC_EXPORT
1961 struct ArrowArrayStream* out,
1962 int64_t* rows_affected, struct AdbcError* error);
1963
1980ADBC_EXPORT
1982 struct ArrowSchema* schema,
1983 struct AdbcError* error);
1984
1989ADBC_EXPORT
1991 struct AdbcError* error);
1992
1999
2009ADBC_EXPORT
2011 const char* query, struct AdbcError* error);
2012
2014
2021
2032ADBC_EXPORT
2034 const uint8_t* plan, size_t length,
2035 struct AdbcError* error);
2036
2038
2049ADBC_EXPORT
2051 struct ArrowArray* values, struct ArrowSchema* schema,
2052 struct AdbcError* error);
2053
2062ADBC_EXPORT
2064 struct ArrowArrayStream* stream,
2065 struct AdbcError* error);
2066
2087ADBC_EXPORT
2089 struct AdbcError* error);
2090
2127ADBC_EXPORT
2128AdbcStatusCode AdbcStatementGetOption(struct AdbcStatement* statement, const char* key,
2129 char* value, size_t* length,
2130 struct AdbcError* error);
2131
2167ADBC_EXPORT
2169 const char* key, uint8_t* value,
2170 size_t* length, struct AdbcError* error);
2171
2191ADBC_EXPORT
2192AdbcStatusCode AdbcStatementGetOptionInt(struct AdbcStatement* statement, const char* key,
2193 int64_t* value, struct AdbcError* error);
2194
2214ADBC_EXPORT
2216 const char* key, double* value,
2217 struct AdbcError* error);
2218
2234ADBC_EXPORT
2236 struct ArrowSchema* schema,
2237 struct AdbcError* error);
2238
2246ADBC_EXPORT
2247AdbcStatusCode AdbcStatementSetOption(struct AdbcStatement* statement, const char* key,
2248 const char* value, struct AdbcError* error);
2249
2260ADBC_EXPORT
2262 const char* key, const uint8_t* value,
2263 size_t length, struct AdbcError* error);
2264
2274ADBC_EXPORT
2275AdbcStatusCode AdbcStatementSetOptionInt(struct AdbcStatement* statement, const char* key,
2276 int64_t value, struct AdbcError* error);
2277
2287ADBC_EXPORT
2289 const char* key, double value,
2290 struct AdbcError* error);
2291
2294
2307ADBC_EXPORT
2309 struct ArrowSchema* schema,
2310 struct AdbcPartitions* partitions,
2311 int64_t* rows_affected,
2312 struct AdbcError* error);
2313
2315
2317
2320
2347typedef AdbcStatusCode (*AdbcDriverInitFunc)(int version, void* driver,
2348 struct AdbcError* error);
2349
2351
2352#endif // ADBC
2353
2354#ifdef __cplusplus
2355}
2356#endif
AdbcStatusCode AdbcConnectionGetOptionBytes(struct AdbcConnection *connection, const char *key, uint8_t *value, size_t *length, struct AdbcError *error)
Get a bytestring option of the connection.
AdbcStatusCode AdbcConnectionGetObjects(struct AdbcConnection *connection, int depth, const char *catalog, const char *db_schema, const char *table_name, const char **table_type, const char *column_name, struct ArrowArrayStream *out, struct AdbcError *error)
Get a hierarchical view of all catalogs, database schemas, tables, and columns.
AdbcStatusCode AdbcConnectionGetTableTypes(struct AdbcConnection *connection, struct ArrowArrayStream *out, struct AdbcError *error)
Get a list of table types in the database.
AdbcStatusCode AdbcConnectionGetStatisticNames(struct AdbcConnection *connection, struct ArrowArrayStream *out, struct AdbcError *error)
Get the names of statistics specific to this driver.
AdbcStatusCode AdbcConnectionGetOptionInt(struct AdbcConnection *connection, const char *key, int64_t *value, struct AdbcError *error)
Get an integer option of the connection.
AdbcStatusCode AdbcConnectionGetOptionDouble(struct AdbcConnection *connection, const char *key, double *value, struct AdbcError *error)
Get a double option of the connection.
AdbcStatusCode AdbcConnectionGetStatistics(struct AdbcConnection *connection, const char *catalog, const char *db_schema, const char *table_name, char approximate, struct ArrowArrayStream *out, struct AdbcError *error)
Get statistics about the data distribution of table(s).
AdbcStatusCode AdbcConnectionGetOption(struct AdbcConnection *connection, const char *key, char *value, size_t *length, struct AdbcError *error)
Get a string option of the connection.
AdbcStatusCode AdbcConnectionGetInfo(struct AdbcConnection *connection, const uint32_t *info_codes, size_t info_codes_length, struct ArrowArrayStream *out, struct AdbcError *error)
Get metadata about the database/driver.
AdbcStatusCode AdbcConnectionGetTableSchema(struct AdbcConnection *connection, const char *catalog, const char *db_schema, const char *table_name, struct ArrowSchema *schema, struct AdbcError *error)
Get the Arrow schema of a table.
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