Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

* Implemented `Connection::get_option_string()` for `OptionConnection::AutoCommit`
(always `"true"`, as ClickHouse has no transactions) and `OptionConnection::CurrentCatalog`
(always empty, as ClickHouse has no catalog level above the database). ([#65])

[#65]: https://github.com/ClickHouse/adbc_clickhouse/pull/65

## [0.1.2] - 2026-11-06

### Fixed
Expand Down
26 changes: 22 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -801,21 +801,39 @@ impl Optionable for ClickhouseConnection {
Status::NotFound,
)
}),
// ClickHouse has no transactions, so every statement commits as it runs.
// Driver managers read this back before using a connection.
OptionConnection::AutoCommit => Ok("true".into()),
// ClickHouse has no catalog level above the database (an ADBC schema),
// so the catalog is always empty rather than unsupported.
OptionConnection::CurrentCatalog => Ok(String::new()),
OptionConnection::Other(s) => self.get_custom_option(&s),
other => err_unimplemented!("ClickhouseConnection::get_option_string({other:?})"),
other => Err(Error::with_message_and_status(
format!("unimplemented connection option: {:?}", other.as_ref()),
Status::NotImplemented,
)),
}
}

fn get_option_bytes(&self, key: Self::Option) -> adbc_core::error::Result<Vec<u8>> {
err_unimplemented!("ClickhouseConnection::get_option_bytes({key:?})")
// There's no options that are specifically binary-only, so... *shrug*
self.get_option_string(key).map(String::into_bytes)
}

fn get_option_int(&self, key: Self::Option) -> adbc_core::error::Result<i64> {
err_unimplemented!("ClickhouseConnection::get_option_int({key:?})")
// Currently no connection options that can be integers
Err(Error::with_message_and_status(
format!("option {:?} is not an integer", key.as_ref()),
Status::InvalidArguments,
))
}

fn get_option_double(&self, key: Self::Option) -> adbc_core::error::Result<f64> {
err_unimplemented!("ClickhouseConnection::get_option_double({key:?})")
// Currently no connection options that can be doubles
Err(Error::with_message_and_status(
format!("option {:?} is not a double", key.as_ref()),
Status::InvalidArguments,
))
}
}

Expand Down
42 changes: 41 additions & 1 deletion tests/it/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use adbc_clickhouse::options;
use adbc_core::options::{OptionDatabase, OptionStatement};
use adbc_core::error::Status;
use adbc_core::options::{OptionConnection, OptionDatabase, OptionStatement};
use adbc_core::{Connection, Database, Driver, Optionable, Statement};
use arrow_array::cast::AsArray;
use arrow_array::types::Int32Type;
Expand Down Expand Up @@ -327,6 +328,45 @@ fn execute_handles_no_result_set_statements() {
assert_eq!(joined, expected);
}

#[test]
fn connection_option_getters() {
let db = test_database();
let conn = db.new_connection().unwrap();

assert_eq!(
conn.get_option_string(OptionConnection::AutoCommit)
.unwrap(),
"true"
);
assert_eq!(
conn.get_option_string(OptionConnection::CurrentCatalog)
.unwrap(),
""
);

for option in [OptionConnection::IsolationLevel, OptionConnection::ReadOnly] {
let err = conn.get_option_string(option).unwrap_err();
assert_eq!(err.status, Status::NotImplemented);
}

assert_eq!(
conn.get_option_bytes(OptionConnection::AutoCommit).unwrap(),
b"true"
);
assert_eq!(
conn.get_option_int(OptionConnection::AutoCommit)
.unwrap_err()
.status,
Status::InvalidArguments
);
assert_eq!(
conn.get_option_double(OptionConnection::AutoCommit)
.unwrap_err()
.status,
Status::InvalidArguments
);
}

#[test]
fn query_with_product_info() {
// Note: may be `ManagedStatement` if using the `ffi` feature.
Expand Down
Loading