Expand description
§adbc-spanner
An ADBC (Arrow Database Connectivity) driver for
Google Cloud Spanner, built on top of the official
google-cloud-spanner preview client and the native Rust adbc_core traits.
The driver exposes Spanner through the standard ADBC object hierarchy:
SpannerDriver ──> SpannerDatabase ──> SpannerConnection ──> SpannerStatementQuery results are returned as Arrow RecordBatches, so they can be
consumed by any Arrow-native tool without an intermediate row-by-row copy.
§Configuration
A database is configured through ADBC options. The Spanner database path is required and can be
supplied either through the standard OptionDatabase::Uri
option or the driver-specific OPTION_DATABASE key:
projects/<project>/instances/<instance>/databases/<database>To talk to a Spanner emulator, either set the SPANNER_EMULATOR_HOST environment variable (the
driver picks it up automatically and uses anonymous credentials) or set the OPTION_ENDPOINT
and OPTION_EMULATOR options explicitly.
§Example
use adbc_core::{Driver, Database, Connection, Statement};
use adbc_core::options::{OptionDatabase, OptionValue};
use adbc_spanner::{SpannerDriver, OPTION_DATABASE};
use arrow_array::RecordBatchReader;
let mut driver = SpannerDriver::try_new()?;
let database = driver.new_database_with_opts([(
OptionDatabase::Other(OPTION_DATABASE.into()),
OptionValue::String("projects/p/instances/i/databases/d".into()),
)])?;
let mut connection = database.new_connection()?;
let mut statement = connection.new_statement()?;
statement.set_sql_query("SELECT 1 AS one")?;
let reader = statement.execute()?;
for batch in reader {
let batch = batch?;
println!("got {} rows", batch.num_rows());
}Structs§
- Spanner
Connection - An ADBC connection to a Spanner database.
- Spanner
Database - A configured, but not yet connected, Spanner database.
- Spanner
Driver - The Spanner ADBC driver — the entry point for creating
SpannerDatabaseinstances. - Spanner
Statement - An ADBC statement bound to a Spanner
DatabaseClient.
Constants§
- DRIVER_
NAME - The driver name reported by
Connection::get_info. - DRIVER_
VERSION - The version of this driver.
- OPTION_
DATABASE - Driver-specific database option: the fully-qualified Spanner database path,
projects/<project>/instances/<instance>/databases/<database>. - OPTION_
EMULATOR - Driver-specific database option: when set to
true, connect with anonymous credentials (the mode used by the Spanner emulator). Automatically enabled whenSPANNER_EMULATOR_HOSTis present in the environment. - OPTION_
ENDPOINT - Driver-specific database option: an explicit gRPC endpoint (for example the address of a
Spanner emulator,
http://localhost:9010). When unset the client connects to the production Spanner service. - VENDOR_
NAME - The vendor name reported by
Connection::get_info.