From 66f261c55f41e42df90053608acfcf8bfdb4bc04 Mon Sep 17 00:00:00 2001 From: yanglongwei Date: Fri, 7 Aug 2026 02:50:41 +0000 Subject: [PATCH 1/4] feat: implement Connection::get_info() (#9) Expose driver/vendor metadata (including server version via SELECT version()) so ADBC clients can discover ClickHouse capabilities. Co-authored-by: Cursor --- .gitignore | 1 + CHANGELOG.md | 8 +++ README.md | 1 + src/info.rs | 147 +++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 81 +++++++++++++++++++++++- tests/it/get_info.rs | 145 ++++++++++++++++++++++++++++++++++++++++++ tests/it/main.rs | 1 + 7 files changed, 382 insertions(+), 2 deletions(-) create mode 100644 src/info.rs create mode 100644 tests/it/get_info.rs diff --git a/.gitignore b/.gitignore index 3a8cabc..f310b3c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target .idea +.cargo/ diff --git a/CHANGELOG.md b/CHANGELOG.md index a043a0c..332e63b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added + +* Implemented `Connection::get_info()` for driver/vendor metadata ([#9]). + +[#9]: https://github.com/ClickHouse/adbc_clickhouse/issues/9 + ## [0.1.0] - 2026-07-01 First stable release of the driver. diff --git a/README.md b/README.md index bd87da6..e8f8c13 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ However, the core query flow is supported: * Creating a `Driver` and `Database` * Setting URL, username and password on the `Database` * Creating a `Connection` and `Statement` +* Querying driver/vendor metadata with `Connection::get_info()` * Setting a query with `Statement::set_sql_query()` and binding parameters with `Statement::bind()` * Binding a statement in streaming insert mode with `Statement::bind_stream()` * Executing a statement with `Statement::execute()` or `Statement::execute_update()` diff --git a/src/info.rs b/src/info.rs new file mode 100644 index 0000000..83424ad --- /dev/null +++ b/src/info.rs @@ -0,0 +1,147 @@ +//! Helpers for building [`Connection::get_info`][adbc_core::Connection::get_info] results. +//! +//! The result schema is defined by [`adbc_core::schemas::GET_INFO_SCHEMA`]. + +use adbc_core::error::{Error, Status}; +use adbc_core::options::InfoCode; +use adbc_core::schemas::GET_INFO_SCHEMA; +use arrow_array::builder::{ + ArrayBuilder, BooleanBuilder, Int32Builder, Int64Builder, ListBuilder, MapBuilder, + MapFieldNames, StringBuilder, UInt32Builder, +}; +use arrow_array::{ArrayRef, RecordBatch, RecordBatchIterator, RecordBatchReader, UnionArray}; +use arrow_buffer::ScalarBuffer; +use arrow_schema::{DataType, UnionMode}; +use std::collections::HashSet; +use std::sync::Arc; + +type Result = std::result::Result; + +/// Builds a dense-union `get_info` result matching [`GET_INFO_SCHEMA`]. +/// +/// Pattern adapted from the ADBC Driver Foundry [`InfoBuilder`][info-builder]. +/// +/// [info-builder]: https://github.com/adbc-drivers/driverbase-rs/blob/main/driverbase/src/lib.rs +pub(crate) struct InfoBuilder { + info_name: UInt32Builder, + type_id: Vec, + offset: Vec, + string_value: StringBuilder, + bool_value: BooleanBuilder, + int64_value: Int64Builder, + int32_bitmask: Int32Builder, + string_list: ListBuilder, + int32_to_int32_list_map: MapBuilder>, +} + +impl InfoBuilder { + const CODE_STRING: i8 = 0; + const CODE_BOOL: i8 = 1; + const CODE_INT64: i8 = 2; + + pub(crate) fn new() -> Self { + Self { + info_name: UInt32Builder::new(), + type_id: Vec::new(), + offset: Vec::new(), + string_value: StringBuilder::new(), + bool_value: BooleanBuilder::new(), + int64_value: Int64Builder::new(), + int32_bitmask: Int32Builder::new(), + string_list: ListBuilder::new(StringBuilder::new()), + // Match `GET_INFO_SCHEMA` field names (`key`/`value`, not MapBuilder defaults). + int32_to_int32_list_map: MapBuilder::new( + Some(MapFieldNames { + entry: "entries".to_string(), + key: "key".to_string(), + value: "value".to_string(), + }), + Int32Builder::new(), + ListBuilder::new(Int32Builder::new()), + ), + } + } + + pub(crate) fn add_string(&mut self, code: InfoCode, value: impl AsRef) { + self.info_name.append_value(u32::from(&code)); + self.type_id.push(Self::CODE_STRING); + self.offset.push(self.string_value.len() as i32); + self.string_value.append_value(value); + } + + pub(crate) fn add_bool(&mut self, code: InfoCode, value: bool) { + self.info_name.append_value(u32::from(&code)); + self.type_id.push(Self::CODE_BOOL); + self.offset.push(self.bool_value.len() as i32); + self.bool_value.append_value(value); + } + + pub(crate) fn add_i64(&mut self, code: InfoCode, value: i64) { + self.info_name.append_value(u32::from(&code)); + self.type_id.push(Self::CODE_INT64); + self.offset.push(self.int64_value.len() as i32); + self.int64_value.append_value(value); + } + + pub(crate) fn finish(mut self) -> Result> { + let num_rows = self.type_id.len(); + let info_name = self.info_name.finish(); + + let type_ids = ScalarBuffer::from(self.type_id); + let offsets = ScalarBuffer::from(self.offset); + + let children: Vec = vec![ + Arc::new(self.string_value.finish()), + Arc::new(self.bool_value.finish()), + Arc::new(self.int64_value.finish()), + Arc::new(self.int32_bitmask.finish()), + Arc::new(self.string_list.finish()), + Arc::new(self.int32_to_int32_list_map.finish()), + ]; + + let schema = GET_INFO_SCHEMA.clone(); + let DataType::Union(union_fields, UnionMode::Dense) = schema.field(1).data_type() else { + return Err(Error::with_message_and_status( + "GET_INFO_SCHEMA.info_value is not a dense union", + Status::Internal, + )); + }; + + let info_value = UnionArray::try_new( + union_fields.clone(), + type_ids, + Some(offsets), + children, + ) + .map_err(|e| { + Error::with_message_and_status( + format!("error building get_info union array: {e}"), + Status::Internal, + ) + })?; + + let batch = RecordBatch::try_new( + schema.clone(), + vec![Arc::new(info_name), Arc::new(info_value)], + ) + .map_err(|e| { + Error::with_message_and_status( + format!("error building get_info record batch: {e}"), + Status::Internal, + ) + })?; + + debug_assert_eq!(batch.num_rows(), num_rows); + + Ok(Box::new(RecordBatchIterator::new( + std::iter::once(Ok(batch)), + schema, + ))) + } +} + +/// Whether `codes` requests `code` (or requests everything when `None`). +#[inline] +pub(crate) fn wants(codes: Option<&HashSet>, code: InfoCode) -> bool { + codes.is_none_or(|set| set.contains(&code)) +} diff --git a/src/lib.rs b/src/lib.rs index e70cb7a..2fa0905 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -97,6 +97,7 @@ //! all strings as binary strings instead. This may be set at the connection or statement level. use crate::options::{OptionValueExt, ProductInfo}; use adbc_core::error::{Error, Status}; +use adbc_core::constants::ADBC_VERSION_1_1_0; use adbc_core::options::{InfoCode, ObjectDepth, OptionConnection, OptionDatabase, OptionValue}; use adbc_core::{Connection, Database, Driver, Optionable, schemas}; use arrow_array::{RecordBatchIterator, RecordBatchReader, record_batch}; @@ -104,6 +105,7 @@ use arrow_schema::Schema; use clickhouse::Client; use rand::distr::{Alphanumeric, SampleString}; use std::collections::HashSet; +use std::future::Future; use std::ops::Deref; use std::sync::Arc; use tokio::runtime::{Handle, Runtime, RuntimeFlavor}; @@ -124,6 +126,7 @@ macro_rules! err_unimplemented { }; } +mod info; pub mod options; mod reader; mod schema; @@ -552,11 +555,17 @@ impl Connection for ClickhouseConnection { err_unimplemented!("ClickhouseConnection::cancel()") } + /// Return driver and vendor metadata as described by [`InfoCode`]. + /// + /// When `codes` is `None`, all supported info codes are returned. Unsupported codes + /// (currently `VendorArrowVersion` and Substrait version bounds) are omitted. + /// + /// `VendorVersion` is fetched from the server via `SELECT version()`. fn get_info( &self, - _codes: Option>, + codes: Option>, ) -> adbc_core::error::Result> { - err_unimplemented!("ClickhouseConnection::get_info()" -> Box) + self.tokio.block_on(self.build_info(codes.as_ref())) } fn get_objects( @@ -705,6 +714,74 @@ impl ClickhouseConnection { Ok(()) } + + async fn build_info( + &self, + codes: Option<&HashSet>, + ) -> Result> { + let mut builder = info::InfoBuilder::new(); + + if info::wants(codes, InfoCode::VendorName) { + builder.add_string(InfoCode::VendorName, "ClickHouse"); + } + + if info::wants(codes, InfoCode::VendorVersion) { + let version = fetch_vendor_version(&self.client).await?; + builder.add_string(InfoCode::VendorVersion, version); + } + + // ClickHouse does not expose a vendor Arrow library version over HTTP. + // Omit `VendorArrowVersion` rather than guessing. + + if info::wants(codes, InfoCode::VendorSql) { + builder.add_bool(InfoCode::VendorSql, true); + } + + if info::wants(codes, InfoCode::VendorSubstrait) { + builder.add_bool(InfoCode::VendorSubstrait, false); + } + + // Substrait is unsupported. Arrow dense unions cannot carry top-level nulls, so we omit + // `VendorSubstrait{Min,Max}Version` rather than returning null `info_value` rows. + + if info::wants(codes, InfoCode::DriverName) { + builder.add_string(InfoCode::DriverName, "ADBC ClickHouse Driver"); + } + + if info::wants(codes, InfoCode::DriverVersion) { + builder.add_string(InfoCode::DriverVersion, env!("CARGO_PKG_VERSION")); + } + + if info::wants(codes, InfoCode::DriverArrowVersion) { + // Keep in sync with the `arrow-*` crate versions in Cargo.toml. + builder.add_string(InfoCode::DriverArrowVersion, "58.3.0"); + } + + if info::wants(codes, InfoCode::DriverAdbcVersion) { + builder.add_i64(InfoCode::DriverAdbcVersion, ADBC_VERSION_1_1_0 as i64); + } + + builder.finish() + } +} + +#[derive(clickhouse::Row, serde::Deserialize)] +struct VendorVersionRow { + version: String, +} + +async fn fetch_vendor_version(client: &Client) -> Result { + client + .query("SELECT version() AS version") + .fetch_one::() + .await + .map(|row| row.version) + .map_err(|e| { + Error::with_message_and_status( + format!("error fetching ClickHouse version: {e}"), + Status::IO, + ) + }) } /// Wrapper for [`Client`] that implements expected semantics for certain settings. diff --git a/tests/it/get_info.rs b/tests/it/get_info.rs new file mode 100644 index 0000000..55e8d8c --- /dev/null +++ b/tests/it/get_info.rs @@ -0,0 +1,145 @@ +use adbc_core::constants::{ + ADBC_INFO_DRIVER_ADBC_VERSION, ADBC_INFO_DRIVER_ARROW_VERSION, ADBC_INFO_DRIVER_NAME, + ADBC_INFO_DRIVER_VERSION, ADBC_INFO_VENDOR_NAME, ADBC_INFO_VENDOR_SQL, + ADBC_INFO_VENDOR_SUBSTRAIT, ADBC_INFO_VENDOR_VERSION, ADBC_VERSION_1_1_0, +}; +use adbc_core::options::InfoCode; +use adbc_core::schemas::GET_INFO_SCHEMA; +use adbc_core::{Connection, Database}; +use arrow_array::cast::AsArray; +use arrow_array::types::UInt32Type; +use arrow_array::{BooleanArray, Int64Array, StringArray, UnionArray}; +use std::collections::{HashMap, HashSet}; + +use crate::test_database; + +#[test] +fn get_info_all() { + let db = test_database(); + let conn = db.new_connection().unwrap(); + + let reader = conn.get_info(None).unwrap(); + assert_eq!(reader.schema().as_ref(), GET_INFO_SCHEMA.as_ref()); + + let batches = reader.collect::, _>>().unwrap(); + assert_eq!(batches.len(), 1); + let batch = &batches[0]; + + let names = batch.column(0).as_primitive::(); + let values = batch + .column(1) + .as_any() + .downcast_ref::() + .expect("info_value should be a UnionArray"); + + let mut by_code = HashMap::new(); + for i in 0..batch.num_rows() { + by_code.insert(names.value(i), i); + } + + assert_eq!( + string_value(values, by_code[&ADBC_INFO_VENDOR_NAME]), + "ClickHouse" + ); + + let vendor_version = string_value(values, by_code[&ADBC_INFO_VENDOR_VERSION]); + assert!( + !vendor_version.is_empty(), + "expected non-empty vendor version, got {vendor_version:?}" + ); + + assert!(bool_value(values, by_code[&ADBC_INFO_VENDOR_SQL])); + assert!(!bool_value(values, by_code[&ADBC_INFO_VENDOR_SUBSTRAIT])); + + assert_eq!( + string_value(values, by_code[&ADBC_INFO_DRIVER_NAME]), + "ADBC ClickHouse Driver" + ); + assert_eq!( + string_value(values, by_code[&ADBC_INFO_DRIVER_VERSION]), + env!("CARGO_PKG_VERSION") + ); + assert_eq!( + string_value(values, by_code[&ADBC_INFO_DRIVER_ARROW_VERSION]), + "58.3.0" + ); + assert_eq!( + i64_value(values, by_code[&ADBC_INFO_DRIVER_ADBC_VERSION]), + ADBC_VERSION_1_1_0 as i64 + ); +} + +#[test] +fn get_info_filtered() { + let db = test_database(); + let conn = db.new_connection().unwrap(); + + let reader = conn + .get_info(Some(HashSet::from([ + InfoCode::DriverName, + InfoCode::VendorSql, + ]))) + .unwrap(); + + let batches = reader.collect::, _>>().unwrap(); + let batch = &batches[0]; + assert_eq!(batch.num_rows(), 2); + + let names = batch.column(0).as_primitive::(); + let values = batch + .column(1) + .as_any() + .downcast_ref::() + .expect("info_value should be a UnionArray"); + + let mut codes = Vec::new(); + for i in 0..batch.num_rows() { + codes.push(names.value(i)); + match names.value(i) { + ADBC_INFO_DRIVER_NAME => { + assert_eq!(string_value(values, i), "ADBC ClickHouse Driver"); + } + ADBC_INFO_VENDOR_SQL => { + assert!(bool_value(values, i)); + } + other => panic!("unexpected info code {other}"), + } + } + + codes.sort_unstable(); + assert_eq!( + codes, + vec![ADBC_INFO_VENDOR_SQL, ADBC_INFO_DRIVER_NAME] + ); +} + +fn string_value(values: &UnionArray, row: usize) -> String { + assert_eq!(values.type_id(row), 0, "expected string_value type id"); + values + .value(row) + .as_any() + .downcast_ref::() + .expect("string child") + .value(0) + .to_string() +} + +fn bool_value(values: &UnionArray, row: usize) -> bool { + assert_eq!(values.type_id(row), 1, "expected bool_value type id"); + values + .value(row) + .as_any() + .downcast_ref::() + .expect("bool child") + .value(0) +} + +fn i64_value(values: &UnionArray, row: usize) -> i64 { + assert_eq!(values.type_id(row), 2, "expected int64_value type id"); + values + .value(row) + .as_any() + .downcast_ref::() + .expect("int64 child") + .value(0) +} diff --git a/tests/it/main.rs b/tests/it/main.rs index a6137cc..79145d8 100644 --- a/tests/it/main.rs +++ b/tests/it/main.rs @@ -11,6 +11,7 @@ use arrow_schema::{DataType, Field, Schema, TimeUnit}; use std::sync::Arc; mod bulk_ingest; +mod get_info; mod get_table_schema; mod params; From f4c1ea91c35942c7026f78c41932ce002d43ea04 Mon Sep 17 00:00:00 2001 From: yanglongwei Date: Fri, 7 Aug 2026 06:49:00 +0000 Subject: [PATCH 2/4] feat: resolve DriverArrowVersion via cargo_metadata Avoid hardcoding the Arrow crate version; emit it from build.rs using cargo metadata. Co-authored-by: Cursor --- Cargo.lock | 37 +++++++++++++++++++++++++++++++++++++ Cargo.toml | 3 +++ build.rs | 23 +++++++++++++++++++++++ src/lib.rs | 4 ++-- tests/it/get_info.rs | 2 +- 5 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 build.rs diff --git a/Cargo.lock b/Cargo.lock index a9e9360..81c7032 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,6 +14,7 @@ dependencies = [ "arrow-buffer", "arrow-ipc", "arrow-schema", + "cargo_metadata", "chrono", "clickhouse", "clickhouse-ext-arrow", @@ -403,6 +404,38 @@ dependencies = [ "serde", ] +[[package]] +name = "camino" +version = "1.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb1307f12aa967b5a58416e87b3653360e0fd614a016b6e970db08fecbb1b80d" +dependencies = [ + "serde_core", +] + +[[package]] +name = "cargo-platform" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd5eb614ed4c27c5d706420e4320fbe3216ab31fa1c33cd8246ac36dae4479ba" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "cc" version = "1.2.65" @@ -1579,6 +1612,10 @@ name = "semver" version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" +dependencies = [ + "serde", + "serde_core", +] [[package]] name = "serde" diff --git a/Cargo.toml b/Cargo.toml index fa48fd8..fbe1f8e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,9 @@ license = "MIT OR Apache-2.0" [lib] crate-type = ["lib", "cdylib"] +[build-dependencies] +cargo_metadata = "0.19" + [features] ffi = ["adbc_ffi"] diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..f3def2a --- /dev/null +++ b/build.rs @@ -0,0 +1,23 @@ +//! Emit the resolved `arrow-array` version via `cargo metadata` so +//! `DriverArrowVersion` stays in sync when Arrow crates are bumped. + +use cargo_metadata::MetadataCommand; + +fn main() { + println!("cargo:rerun-if-changed=Cargo.toml"); + println!("cargo:rerun-if-changed=Cargo.lock"); + + let metadata = MetadataCommand::new() + .manifest_path("Cargo.toml") + .exec() + .expect("failed to run cargo metadata"); + + let version = metadata + .packages + .iter() + .find(|p| p.name.as_str() == "arrow-array") + .map(|p| p.version.to_string()) + .expect("package `arrow-array` not found in cargo metadata"); + + println!("cargo:rustc-env=ADBC_DRIVER_ARROW_VERSION={version}"); +} diff --git a/src/lib.rs b/src/lib.rs index 2fa0905..292a54c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -753,8 +753,8 @@ impl ClickhouseConnection { } if info::wants(codes, InfoCode::DriverArrowVersion) { - // Keep in sync with the `arrow-*` crate versions in Cargo.toml. - builder.add_string(InfoCode::DriverArrowVersion, "58.3.0"); + // Resolved `arrow-array` version via `cargo metadata` (see build.rs). + builder.add_string(InfoCode::DriverArrowVersion, env!("ADBC_DRIVER_ARROW_VERSION")); } if info::wants(codes, InfoCode::DriverAdbcVersion) { diff --git a/tests/it/get_info.rs b/tests/it/get_info.rs index 55e8d8c..5b85644 100644 --- a/tests/it/get_info.rs +++ b/tests/it/get_info.rs @@ -61,7 +61,7 @@ fn get_info_all() { ); assert_eq!( string_value(values, by_code[&ADBC_INFO_DRIVER_ARROW_VERSION]), - "58.3.0" + env!("ADBC_DRIVER_ARROW_VERSION") ); assert_eq!( i64_value(values, by_code[&ADBC_INFO_DRIVER_ADBC_VERSION]), From dd99e054649c48980640c99f935ac80ecbbdd19b Mon Sep 17 00:00:00 2001 From: yanglongwei Date: Fri, 7 Aug 2026 16:00:54 +0000 Subject: [PATCH 3/4] fix: stop expecting PARQUET UUID metadata in params round-trip ClickHouse Arrow output no longer includes PARQUET:logical_type on UUID columns, which broke binary_strings_round_trip under assert_eq!. --- tests/it/params.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/it/params.rs b/tests/it/params.rs index 1fe13b1..abe9187 100644 --- a/tests/it/params.rs +++ b/tests/it/params.rs @@ -10,8 +10,9 @@ use uuid::Uuid; fn binary_strings_round_trip() { let params_schema = Arc::new(Schema::new(vec![ Field::new("field_uuid", DataType::FixedSizeBinary(16), false) - // ClickHouse Server returns extra metadata over - // what's specified by the canonical extension type. + // Match the canonical extension metadata ClickHouse returns. + // Do not include server-version-specific keys such as + // `PARQUET:logical_type`. // // `.with_extension_type(arrow_schema::extensions::Uuid)` // deletes the `ARROW:extension:metadata` key so equality wouldn't work. @@ -19,7 +20,6 @@ fn binary_strings_round_trip() { [ ("ARROW:extension:name".to_string(), "arrow.uuid".to_string()), ("ARROW:extension:metadata".to_string(), "".to_string()), - ("PARQUET:logical_type".to_string(), "UUID".to_string()), ] .into(), ), From bb3059ee4c438a874b092226745da88523150c82 Mon Sep 17 00:00:00 2001 From: yanglongwei Date: Sat, 5 Sep 2026 15:13:51 +0000 Subject: [PATCH 4/4] Omit DriverArrowVersion until arrow_array::ARROW_VERSION is available. Drop the build.rs/cargo_metadata approach so we avoid a Cargo-only build script; restore when arrow-* is bumped far enough for apache/arrow-rs#10957. --- Cargo.lock | 37 --------------------------------- Cargo.toml | 3 --- build.rs | 23 --------------------- src/lib.rs | 49 ++++++++++++++++++++++---------------------- tests/it/get_info.rs | 7 ++++--- 5 files changed, 28 insertions(+), 91 deletions(-) delete mode 100644 build.rs diff --git a/Cargo.lock b/Cargo.lock index 4ff783a..8865859 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,7 +14,6 @@ dependencies = [ "arrow-buffer", "arrow-ipc", "arrow-schema", - "cargo_metadata", "chrono", "clickhouse", "clickhouse-ext-arrow", @@ -410,38 +409,6 @@ dependencies = [ "serde", ] -[[package]] -name = "camino" -version = "1.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb1307f12aa967b5a58416e87b3653360e0fd614a016b6e970db08fecbb1b80d" -dependencies = [ - "serde_core", -] - -[[package]] -name = "cargo-platform" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" -dependencies = [ - "serde", -] - -[[package]] -name = "cargo_metadata" -version = "0.19.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd5eb614ed4c27c5d706420e4320fbe3216ab31fa1c33cd8246ac36dae4479ba" -dependencies = [ - "camino", - "cargo-platform", - "semver", - "serde", - "serde_json", - "thiserror", -] - [[package]] name = "cc" version = "1.2.65" @@ -1581,10 +1548,6 @@ name = "semver" version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" -dependencies = [ - "serde", - "serde_core", -] [[package]] name = "serde" diff --git a/Cargo.toml b/Cargo.toml index b906a5d..43185cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,9 +15,6 @@ license = "MIT OR Apache-2.0" [lib] crate-type = ["lib", "cdylib"] -[build-dependencies] -cargo_metadata = "0.19" - [features] ffi = ["adbc_ffi"] diff --git a/build.rs b/build.rs deleted file mode 100644 index f3def2a..0000000 --- a/build.rs +++ /dev/null @@ -1,23 +0,0 @@ -//! Emit the resolved `arrow-array` version via `cargo metadata` so -//! `DriverArrowVersion` stays in sync when Arrow crates are bumped. - -use cargo_metadata::MetadataCommand; - -fn main() { - println!("cargo:rerun-if-changed=Cargo.toml"); - println!("cargo:rerun-if-changed=Cargo.lock"); - - let metadata = MetadataCommand::new() - .manifest_path("Cargo.toml") - .exec() - .expect("failed to run cargo metadata"); - - let version = metadata - .packages - .iter() - .find(|p| p.name.as_str() == "arrow-array") - .map(|p| p.version.to_string()) - .expect("package `arrow-array` not found in cargo metadata"); - - println!("cargo:rustc-env=ADBC_DRIVER_ARROW_VERSION={version}"); -} diff --git a/src/lib.rs b/src/lib.rs index 2f2822e..43b5324 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -860,6 +860,28 @@ impl ClickhouseConnection { Ok(()) } + fn get_custom_option(&self, key: &str) -> Result { + if let Some(name) = options::setting_name(key) { + return self + .client + .get_option(name) + .map(Into::into) + .ok_or_else(|| options::setting_not_set(name)); + } + + match key { + options::SESSION_ID => Ok(self + .client + .get_option(options::as_setting::SESSION_ID) + .unwrap_or("") + .into()), + other => Err(Error::with_message_and_status( + format!("unknown connection option {other:?}"), + Status::InvalidArguments, + )), + } + } + async fn build_info( &self, codes: Option<&HashSet>, @@ -897,10 +919,8 @@ impl ClickhouseConnection { builder.add_string(InfoCode::DriverVersion, env!("CARGO_PKG_VERSION")); } - if info::wants(codes, InfoCode::DriverArrowVersion) { - // Resolved `arrow-array` version via `cargo metadata` (see build.rs). - builder.add_string(InfoCode::DriverArrowVersion, env!("ADBC_DRIVER_ARROW_VERSION")); - } + // FIXME: populate `DriverArrowVersion` once we bump `arrow-*` far enough to use + // `arrow_array::ARROW_VERSION` (apache/arrow-rs#10957). if info::wants(codes, InfoCode::DriverAdbcVersion) { builder.add_i64(InfoCode::DriverAdbcVersion, ADBC_VERSION_1_1_0 as i64); @@ -927,27 +947,6 @@ async fn fetch_vendor_version(client: &Client) -> Result { Status::IO, ) }) - fn get_custom_option(&self, key: &str) -> Result { - if let Some(name) = options::setting_name(key) { - return self - .client - .get_option(name) - .map(Into::into) - .ok_or_else(|| options::setting_not_set(name)); - } - - match key { - options::SESSION_ID => Ok(self - .client - .get_option(options::as_setting::SESSION_ID) - .unwrap_or("") - .into()), - other => Err(Error::with_message_and_status( - format!("unknown connection option {other:?}"), - Status::InvalidArguments, - )), - } - } } /// Wrapper for [`Client`] that implements expected semantics for certain settings. diff --git a/tests/it/get_info.rs b/tests/it/get_info.rs index 5b85644..9bdc7d6 100644 --- a/tests/it/get_info.rs +++ b/tests/it/get_info.rs @@ -59,9 +59,10 @@ fn get_info_all() { string_value(values, by_code[&ADBC_INFO_DRIVER_VERSION]), env!("CARGO_PKG_VERSION") ); - assert_eq!( - string_value(values, by_code[&ADBC_INFO_DRIVER_ARROW_VERSION]), - env!("ADBC_DRIVER_ARROW_VERSION") + // FIXME: populate once arrow-* exposes a version constant (see get_info in lib.rs). + assert!( + !by_code.contains_key(&ADBC_INFO_DRIVER_ARROW_VERSION), + "DriverArrowVersion should be omitted until arrow-* provides ARROW_VERSION" ); assert_eq!( i64_value(values, by_code[&ADBC_INFO_DRIVER_ADBC_VERSION]),