Skip to content

Commit

Permalink
feat(format): add AdbcStatementExecuteSchema
Browse files Browse the repository at this point in the history
Fixes apache#318.
  • Loading branch information
lidavidm committed May 17, 2023
1 parent d379f84 commit c6d1543
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ repos:
- "--linelength=90"
- "--verbose=2"
- repo: https://github.com/golangci/golangci-lint
rev: v1.49.0
rev: v1.52.2
hooks:
- id: golangci-lint
entry: bash -c 'cd go/adbc && golangci-lint run --fix --timeout 5m'
Expand Down
18 changes: 18 additions & 0 deletions adbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,24 @@ AdbcStatusCode AdbcStatementExecuteQuery(struct AdbcStatement* statement,
struct ArrowArrayStream* out,
int64_t* rows_affected, struct AdbcError* error);

/// \brief Get the schema of the result set of a query without
/// executing it.
///
/// This invalidates any prior result sets.
///
/// \since ADBC API revision 1.1.0
///
/// \param[in] statement The statement to execute.
/// \param[out] out The result 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 AdbcStatementExecuteSchema(struct AdbcStatement* statement,
struct ArrowSchema* schema,
struct AdbcError* error);

/// \brief Turn this statement into a prepared statement to be
/// executed multiple times.
///
Expand Down
13 changes: 13 additions & 0 deletions go/adbc/adbc.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,3 +536,16 @@ type Statement interface {
// an error with a StatusNotImplemented code.
ExecutePartitions(context.Context) (*arrow.Schema, Partitions, int64, error)
}

// Statement110 is an extension interface for methods added to Statement in
// ADBC API revision 1.1.0.
type Statement110 interface {
Statement

// ExecuteSchema returns the schema of the result set of a query without
// executing it.
//
// If the driver does not support this, this will return an error with a
// StatusNotImplemented code.
ExecuteSchema(context.Context) (*arrow.Schema, error)
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ default void bind(VectorSchemaRoot root) throws AdbcException {
*/
UpdateResult executeUpdate() throws AdbcException;

/**
* Get the schema of the result set of a query without executing it.
*
* @since ADBC API revision 1.1.0
* @throws AdbcException with status {@link AdbcStatusCode#NOT_IMPLEMENTED} if the driver does not
* support this.
*/
default Schema executeSchema() throws AdbcException {
throw AdbcException.notImplemented("Statement does not support executeSchema");
}

/**
* Execute a result set-generating query and get a list of partitions of the result set.
*
Expand Down

0 comments on commit c6d1543

Please sign in to comment.