Skip to content

Commit e004300

Browse files
aakash-saravanan-dbIsaac
andcommitted
feat(volume): expose Volume completion through the C ABI, ADBC, NAPI and PyO3
Each binding exposes whether a result is a Volume operation and runs the transfer through ResultStream::complete_volume_operation. Local file errors carry the OS error number and path. Each binding's socket timeout also sets the transfer idle limit. ADBC runs transfers when the staging_allowed_local_paths statement option is set, and execute_update fails on a Volume statement without it. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
1 parent 427de46 commit e004300

29 files changed

Lines changed: 1247 additions & 23 deletions

‎NEXT_CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ changes go in their respective binding's NEXT_CHANGELOG.
2020
Local paths, with symlinks resolved, must be inside the caller's allowed
2121
directories. `HttpConfig::storage_read_timeout` limits how long a transfer
2222
may go without progress (15 minutes by default).
23+
- C ABI: `kernel_result_stream_complete_volume_operation`, the
24+
`kernel_*_is_volume_operation` flags, `kernel_session_config_set_storage_read_timeout`,
25+
and `kernel_get_last_error_code` / `_local_os_error` / `_local_path`.
26+
- ADBC: the `adbc.databricks.statement.staging_allowed_local_paths` statement
27+
option runs Volume transfers.
2328

2429
### Changed
2530

‎adbc/Cargo.lock‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎adbc/Cargo.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ serde_json = "1"
3737
tokio = { version = "1", features = ["rt-multi-thread"] }
3838

3939
[dev-dependencies]
40+
arrow-ipc = "59"
41+
base64 = "0.22"
4042
adbc_driver_manager = "0.24"
4143
arrow-cast = "59"
4244
wiremock = "0.6"

‎adbc/README.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@ optional C interface and native Rust asynchronous submission and polling.
7373
Transactions, partitioned execution, statistics, and progress reporting are
7474
not currently implemented.
7575

76+
## Volume file operations
77+
78+
Set the statement option `adbc.databricks.statement.staging_allowed_local_paths`
79+
to a JSON array of local directories to run the file transfer for a Volume
80+
`PUT`, `GET` or `REMOVE` before results are returned; the instruction row stays
81+
readable. Local paths, with symlinks resolved, must be inside one of those
82+
directories, and `[]` allows only `REMOVE`. The option stays set until it is set
83+
to JSON `null`. Without it, `execute` returns the server's instruction row and
84+
moves no file, and `execute_update` fails with `InvalidState`. `REMOVE` of a
85+
missing object succeeds. `PUT` from an input stream is not supported.
86+
`SocketTimeout` also limits how long a transfer may go without progress
87+
(15 minutes by default).
88+
7689
## Compatibility and status
7790

7891
The current implementation targets Rust 1.89+, Rust edition 2021, ADBC 1.1,

‎adbc/src/config.rs‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,11 @@ impl DatabaseConfig {
386386
"adbc.databricks.http_request_timeout" => {
387387
self.http.request_timeout = duration_seconds(value, key)?
388388
}
389-
"SocketTimeout" => self.http.request_timeout = duration(value, key, false)?,
389+
"SocketTimeout" => {
390+
let timeout = duration(value, key, false)?;
391+
self.http.request_timeout = timeout;
392+
self.http.storage_read_timeout = Some(timeout);
393+
}
390394
_ if key.starts_with(HTTP_PREFIX) => self.set_http(key, value)?,
391395
_ if key.starts_with(PROXY_PREFIX) => self.set_proxy(key, value)?,
392396
_ if key.starts_with(TLS_PREFIX) => self.set_tls(key, value)?,
@@ -1234,6 +1238,17 @@ mod tests {
12341238
assert_eq!(error.status, Status::InvalidArguments);
12351239
}
12361240

1241+
#[test]
1242+
fn socket_timeout_also_limits_volume_transfers() {
1243+
let mut config = DatabaseConfig::default();
1244+
set(&mut config, "SocketTimeout", 4500_i64);
1245+
assert_eq!(config.http.request_timeout, Duration::from_millis(4500));
1246+
assert_eq!(
1247+
config.http.storage_read_timeout,
1248+
Some(Duration::from_millis(4500))
1249+
);
1250+
}
1251+
12371252
#[test]
12381253
fn cloudfetch_enabled_option_configures_kernel_result_delivery() {
12391254
let mut config = DatabaseConfig::default();

‎adbc/src/reader.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ pub(crate) struct SequenceReader {
461461
base_spec: kernel::StatementSpec,
462462
parameter_style: ParameterStyle,
463463
client_timeout: Option<Duration>,
464+
volume_options: Option<kernel::VolumeOptions>,
464465
rows: BoundRows,
465466
current: Option<kernel::ExecutedStatement>,
466467
schema: SchemaRef,
@@ -476,6 +477,7 @@ impl SequenceReader {
476477
base_spec: kernel::StatementSpec,
477478
parameter_style: ParameterStyle,
478479
client_timeout: Option<Duration>,
480+
volume_options: Option<kernel::VolumeOptions>,
479481
rows: BoundRows,
480482
executed: kernel::ExecutedStatement,
481483
connection_operation: OperationGuard,
@@ -489,6 +491,7 @@ impl SequenceReader {
489491
base_spec,
490492
parameter_style,
491493
client_timeout,
494+
volume_options,
492495
rows,
493496
current: Some(executed),
494497
schema,
@@ -582,6 +585,7 @@ impl Iterator for SequenceReader {
582585
&row,
583586
self.parameter_style,
584587
self.client_timeout,
588+
self.volume_options.as_ref(),
585589
) {
586590
Ok(executed) => executed,
587591
Err(source) => return self.fail(ArrowError::ExternalError(Box::new(source))),

0 commit comments

Comments
 (0)