@@ -142,20 +142,35 @@ const (
142142 StatusUnauthorized // Unauthorized
143143)
144144
145+ const (
146+ AdbcVersion1_0_0 int64 = 1_000_000
147+ AdbcVersion1_1_0 int64 = 1_001_000
148+ )
149+
145150// Canonical option values
146151const (
147- OptionValueEnabled = "true"
148- OptionValueDisabled = "false"
149- OptionKeyAutoCommit = "adbc.connection.autocommit"
150- OptionKeyIngestTargetTable = "adbc.ingest.target_table"
151- OptionKeyIngestMode = "adbc.ingest.mode"
152- OptionKeyIsolationLevel = "adbc.connection.transaction.isolation_level"
153- OptionKeyReadOnly = "adbc.connection.readonly"
154- OptionValueIngestModeCreate = "adbc.ingest.mode.create"
155- OptionValueIngestModeAppend = "adbc.ingest.mode.append"
156- OptionKeyURI = "uri"
157- OptionKeyUsername = "username"
158- OptionKeyPassword = "password"
152+ OptionValueEnabled = "true"
153+ OptionValueDisabled = "false"
154+ OptionKeyAutoCommit = "adbc.connection.autocommit"
155+ // The current catalog.
156+ OptionKeyCurrentCatalog = "adbc.connection.catalog"
157+ // The current schema.
158+ OptionKeyCurrentDbSchema = "adbc.connection.db_schema"
159+ // Make ExecutePartitions nonblocking.
160+ OptionKeyIncremental = "adbc.statement.exec.incremental"
161+ // Get the progress
162+ OptionKeyProgress = "adbc.statement.exec.progress"
163+ OptionKeyIngestTargetTable = "adbc.ingest.target_table"
164+ OptionKeyIngestMode = "adbc.ingest.mode"
165+ OptionKeyIsolationLevel = "adbc.connection.transaction.isolation_level"
166+ OptionKeyReadOnly = "adbc.connection.readonly"
167+ OptionValueIngestModeCreate = "adbc.ingest.mode.create"
168+ OptionValueIngestModeAppend = "adbc.ingest.mode.append"
169+ OptionValueIngestModeReplace = "adbc.ingest.mode.replace"
170+ OptionValueIngestModeCreateAppend = "adbc.ingest.mode.create_append"
171+ OptionKeyURI = "uri"
172+ OptionKeyUsername = "username"
173+ OptionKeyPassword = "password"
159174)
160175
161176type OptionIsolationLevel string
@@ -170,6 +185,11 @@ const (
170185 LevelLinearizable OptionIsolationLevel = "adbc.connection.transaction.isolation.linearizable"
171186)
172187
188+ // Canonical property values
189+ const (
190+ PropertyProgress = "adbc.statement.exec.progress"
191+ )
192+
173193// Driver is the entry point for the interface. It is similar to
174194// database/sql.Driver taking a map of keys and values as options
175195// to initialize a Connection to the database. Any common connection
@@ -212,6 +232,8 @@ const (
212232 InfoDriverVersion InfoCode = 101 // DriverVersion
213233 // The driver Arrow library version (type: utf8)
214234 InfoDriverArrowVersion InfoCode = 102 // DriverArrowVersion
235+ // The driver ADBC API version (type: int64)
236+ InfoDriverADBCVersion InfoCode = 103 // DriverADBCVersion
215237)
216238
217239type ObjectDepth int
@@ -275,6 +297,10 @@ type Connection interface {
275297 // codes are defined as constants. Codes [0, 10_000) are reserved
276298 // for ADBC usage. Drivers/vendors will ignore requests for unrecognized
277299 // codes (the row will be omitted from the result).
300+ //
301+ // Since ADBC 1.1.0: the range [500, 1_000) is reserved for "XDBC"
302+ // information, which is the same metadata provided by the same info
303+ // code range in the Arrow Flight SQL GetSqlInfo RPC.
278304 GetInfo (ctx context.Context , infoCodes []InfoCode ) (array.RecordReader , error )
279305
280306 // GetObjects gets a hierarchical view of all catalogs, database schemas,
@@ -470,6 +496,9 @@ type Statement interface {
470496 // of rows affected if known, otherwise it will be -1.
471497 //
472498 // This invalidates any prior result sets on this statement.
499+ //
500+ // Since ADBC 1.1.0: releasing the returned RecordReader without
501+ // consuming it fully is equivalent to calling AdbcStatementCancel.
473502 ExecuteQuery (context.Context ) (array.RecordReader , int64 , error )
474503
475504 // ExecuteUpdate executes a statement that does not generate a result
@@ -534,5 +563,45 @@ type Statement interface {
534563 //
535564 // If the driver does not support partitioned results, this will return
536565 // an error with a StatusNotImplemented code.
566+ //
567+ // When OptionKeyIncremental is set, this should be called
568+ // repeatedly until receiving an empty Partitions.
537569 ExecutePartitions (context.Context ) (* arrow.Schema , Partitions , int64 , error )
538570}
571+
572+ // StatementCancel is a Statement that also supports Cancel.
573+ //
574+ // Since ADBC API revision 1.1.0.
575+ type StatementCancel interface {
576+ // Cancel stops execution of an in-progress query.
577+ //
578+ // This can be called during ExecuteQuery (or similar), or while
579+ // consuming a RecordReader returned from such. Calling this
580+ // function should make the other functions return an error with a
581+ // StatusCancelled code.
582+ //
583+ // This must always be thread-safe (other operations are not
584+ // necessarily thread-safe).
585+ Cancel () error
586+ }
587+
588+ // StatementExecuteSchema is a Statement that also supports ExecuteSchema.
589+ //
590+ // Since ADBC API revision 1.1.0.
591+ type StatementExecuteSchema interface {
592+ // ExecuteSchema gets the schema of the result set of a query without executing it.
593+ ExecuteSchema (context.Context ) (* arrow.Schema , error )
594+ }
595+
596+ // GetSetOptions is a PostInitOptions that also supports getting and setting property values of different types.
597+ //
598+ // Since ADBC API revision 1.1.0.
599+ type GetSetOptions interface {
600+ PostInitOptions
601+
602+ SetOption (key , value string ) error
603+ SetOptionInt (key , value int64 ) error
604+ SetOptionDouble (key , value float64 ) error
605+ GetOptionInt (key string ) (int64 , error )
606+ GetOptionDouble (key string ) (float64 , error )
607+ }
0 commit comments