Skip to content

Commit

Permalink
feat(format,go): add new APIs for ADBC 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lidavidm committed May 22, 2023
1 parent 9ee2b8d commit 5d4f31d
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 12 deletions.
72 changes: 60 additions & 12 deletions go/adbc/adbc.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,23 @@ const (

// Canonical option values
const (
OptionValueEnabled = "true"
OptionValueDisabled = "false"
OptionKeyAutoCommit = "adbc.connection.autocommit"
OptionKeyIngestTargetTable = "adbc.ingest.target_table"
OptionKeyIngestMode = "adbc.ingest.mode"
OptionKeyIsolationLevel = "adbc.connection.transaction.isolation_level"
OptionKeyReadOnly = "adbc.connection.readonly"
OptionValueIngestModeCreate = "adbc.ingest.mode.create"
OptionValueIngestModeAppend = "adbc.ingest.mode.append"
OptionKeyURI = "uri"
OptionKeyUsername = "username"
OptionKeyPassword = "password"
OptionValueEnabled = "true"
OptionValueDisabled = "false"
OptionKeyAutoCommit = "adbc.connection.autocommit"
OptionKeyCurrentCatalog = "adbc.connection.catalog"
OptionKeyCurrentDbSchema = "adbc.connection.db_schema"
OptionKeyIncremental = "adbc.statement.exec.incremental"
OptionKeyIngestTargetTable = "adbc.ingest.target_table"
OptionKeyIngestMode = "adbc.ingest.mode"
OptionKeyIsolationLevel = "adbc.connection.transaction.isolation_level"
OptionKeyReadOnly = "adbc.connection.readonly"
OptionValueIngestModeCreate = "adbc.ingest.mode.create"
OptionValueIngestModeAppend = "adbc.ingest.mode.append"
OptionValueIngestModeReplace = "adbc.ingest.mode.replace"
OptionValueIngestModeCreateAppend = "adbc.ingest.mode.create_append"
OptionKeyURI = "uri"
OptionKeyUsername = "username"
OptionKeyPassword = "password"
)

type OptionIsolationLevel string
Expand All @@ -170,6 +175,11 @@ const (
LevelLinearizable OptionIsolationLevel = "adbc.connection.transaction.isolation.linearizable"
)

// Canonical property values
const (
PropertyProgress = "adbc.statement.exec.progress"
)

// Driver is the entry point for the interface. It is similar to
// database/sql.Driver taking a map of keys and values as options
// to initialize a Connection to the database. Any common connection
Expand Down Expand Up @@ -212,6 +222,11 @@ const (
InfoDriverVersion InfoCode = 101 // DriverVersion
// The driver Arrow library version (type: utf8)
InfoDriverArrowVersion InfoCode = 102 // DriverArrowVersion

// The current catalog (type: utf8)
InfoCurrentCatalog InfoCode = 200 // CurrentCatalog
// The current schema (type: utf8)
InfoCurrentDbSchema InfoCode = 201 // CurrentDbSchema
)

type ObjectDepth int
Expand Down Expand Up @@ -275,6 +290,10 @@ type Connection interface {
// codes are defined as constants. Codes [0, 10_000) are reserved
// for ADBC usage. Drivers/vendors will ignore requests for unrecognized
// codes (the row will be omitted from the result).
//
// Since ADBC 1.1.0: the range [500, 1_000) is reserved for "XDBC"
// information, which is the same metadata provided by the same info
// code range in the Arrow Flight SQL GetSqlInfo RPC.
GetInfo(ctx context.Context, infoCodes []InfoCode) (array.RecordReader, error)

// GetObjects gets a hierarchical view of all catalogs, database schemas,
Expand Down Expand Up @@ -470,6 +489,9 @@ type Statement interface {
// of rows affected if known, otherwise it will be -1.
//
// This invalidates any prior result sets on this statement.
//
// Since ADBC 1.1.0: releasing the returned RecordReader without
// consuming it fully is equivalent to calling AdbcStatementCancel.
ExecuteQuery(context.Context) (array.RecordReader, int64, error)

// ExecuteUpdate executes a statement that does not generate a result
Expand Down Expand Up @@ -536,3 +558,29 @@ type Statement interface {
// an error with a StatusNotImplemented code.
ExecutePartitions(context.Context) (*arrow.Schema, Partitions, int64, error)
}

type StatementCancel interface {
// Cancel stops execution of an in-progress query.
//
// This can be called during ExecuteQuery (or similar), or while
// consuming a RecordReader returned from such. Calling this
// function should make the other functions return an error with a
// StatusCancelled code.
//
// This must always be thread-safe (other operations are not
// necessarily thread-safe).
Cancel() error
}

type StatementExecuteSchema interface {
// ExecuteSchema gets the schema of the result set of a query without executing it.
ExecuteSchema(context.Context) (*arrow.Schema, error)
}

type StatementGetProperty interface {
// GetDoubleProperty gets the value of a double property.
//
// This must always be thread-safe (other operations are not
// necessarily thread-safe).
GetDoubleProperty(key string) (float64, error)
}
7 changes: 7 additions & 0 deletions go/adbc/infocode_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5d4f31d

Please sign in to comment.