Skip to content
Open
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
2 changes: 2 additions & 0 deletions adbc/Cargo.lock

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

2 changes: 2 additions & 0 deletions adbc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ serde_json = "1"
tokio = { version = "1", features = ["rt-multi-thread"] }

[dev-dependencies]
arrow-ipc = "59"
base64 = "0.22"
adbc_driver_manager = "0.24"
wiremock = "0.6"

Expand Down
15 changes: 15 additions & 0 deletions adbc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,21 @@ optional C interface and native Rust asynchronous submission and polling.
Transactions, partitioned execution, statistics, and progress reporting are
not currently implemented.

## Volume file operations

Set `adbc.databricks.statement.staging_allowed_local_paths` to a JSON array of
local directories to run the file transfer for Volume `PUT`, `GET` and `REMOVE`
before results are returned. The result rows stay readable. Without the option
no file moves and the result is only the server's instruction row.
`execute_update` returns no rows, so without the option it fails with
`InvalidState` for a Volume statement.
The option remains enabled for the statement until set to JSON `null`; an empty
array still permits REMOVE while denying file PUT and GET. REMOVE of a missing object succeeds. Input-stream PUT is unsupported.
The client timeout ends at the terminal SQL status and does not bound Volume transfers.
`SocketTimeout` (milliseconds) also sets the idle limit for Volume transfers (15 minutes when unset; `0` disables it);
`adbc.databricks.http_request_timeout` sets only the SQL request deadline.
See the kernel [Volume file operations](../README.md#volume-file-operations).

## Compatibility and status

The current implementation targets Rust 1.89+, Rust edition 2021, ADBC 1.1,
Expand Down
11 changes: 10 additions & 1 deletion adbc/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,11 @@ impl DatabaseConfig {
"adbc.databricks.http_request_timeout" => {
self.http.request_timeout = duration_seconds(value, key)?
}
"SocketTimeout" => self.http.request_timeout = duration(value, key, false)?,
"SocketTimeout" => {
let timeout = duration(value, key, false)?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium — SocketTimeout is parsed with duration(value, key, false), which rejects 0. The ADBC README says 0 disables the Volume idle limit, so that setting returns InvalidArguments. Accept 0 and map it to storage_read_timeout = None while keeping the SQL default, as NAPI does, or fix the README. Add a test.

🔀 Found by both reviewers · confirmed by the judge

self.http.request_timeout = timeout;
self.http.storage_read_timeout = Some(timeout);
}
_ if key.starts_with(HTTP_PREFIX) => self.set_http(key, value)?,
_ if key.starts_with(PROXY_PREFIX) => self.set_proxy(key, value)?,
_ if key.starts_with(TLS_PREFIX) => self.set_tls(key, value)?,
Expand Down Expand Up @@ -1695,6 +1699,7 @@ mod tests {
#[test]
fn http_pool_and_custom_headers_reach_kernel_config() {
let mut config = DatabaseConfig::default();
set(&mut config, "SocketTimeout", 4500_i64);
set(&mut config, HOST, "https://example.databricks.com");
set(&mut config, HTTP_PATH, "/sql/1.0/warehouses/warehouse-id");
set(&mut config, ACCESS_TOKEN, "sentinel-token");
Expand All @@ -1712,6 +1717,10 @@ mod tests {

let resolved = config.resolve().unwrap();
assert_eq!(resolved.http.pool_max_idle_per_host, 37);
assert_eq!(
resolved.http.storage_read_timeout,
Some(Duration::from_millis(4500))
);
assert_eq!(
resolved.user_agent_entry.as_deref(),
Some("partner+product")
Expand Down
25 changes: 24 additions & 1 deletion adbc/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ pub(crate) fn map_kernel_error(source: kernel::Error) -> Error {
mapped.details = source
.error_code
.map(|code| vec![("databricks.error_code".to_string(), code.into_bytes())]);
if let Some(local) = source.local_error {
let details = mapped.details.get_or_insert_default();
details.push((
"databricks.local_error_kind".into(),
format!("{:?}", local.kind).into_bytes(),
));
details.push(("databricks.local_path".into(), local.path.into_bytes()));
if let Some(errno) = local.raw_os_error {
details.push((
"databricks.local_os_error".into(),
errno.to_string().into_bytes(),
));
}
}
mapped
}

Expand Down Expand Up @@ -101,14 +115,23 @@ mod tests {
kernel::Error::sql_error()
.message("bad query")
.with_sql_state("42000")
.with_vendor_code(42),
.with_vendor_code(42)
.with_local_error(kernel::LocalFileError::new(
Some(2),
std::io::ErrorKind::NotFound,
"/allowed/missing",
)),
);
assert_eq!(mapped.status, Status::InvalidData);
assert_eq!(mapped.vendor_code, 42);
assert_eq!(
mapped.sqlstate,
(*b"42000").map(|byte| byte as std::ffi::c_char)
);
assert!(mapped
.details
.unwrap()
.contains(&("databricks.local_path".into(), b"/allowed/missing".to_vec())));
}

#[test]
Expand Down
4 changes: 4 additions & 0 deletions adbc/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ pub(crate) struct SequenceReader {
base_spec: kernel::StatementSpec,
parameter_style: ParameterStyle,
client_timeout: Option<Duration>,
volume_options: Option<kernel::VolumeOptions>,
rows: BoundRows,
current: Option<kernel::ExecutedStatement>,
schema: SchemaRef,
Expand All @@ -476,6 +477,7 @@ impl SequenceReader {
base_spec: kernel::StatementSpec,
parameter_style: ParameterStyle,
client_timeout: Option<Duration>,
volume_options: Option<kernel::VolumeOptions>,
rows: BoundRows,
executed: kernel::ExecutedStatement,
connection_operation: OperationGuard,
Expand All @@ -489,6 +491,7 @@ impl SequenceReader {
base_spec,
parameter_style,
client_timeout,
volume_options,
rows,
current: Some(executed),
schema,
Expand Down Expand Up @@ -582,6 +585,7 @@ impl Iterator for SequenceReader {
&row,
self.parameter_style,
self.client_timeout,
self.volume_options.as_ref(),
) {
Ok(executed) => executed,
Err(source) => return self.fail(ArrowError::ExternalError(Box::new(source))),
Expand Down
Loading
Loading