Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
57283b0
fix(results): fetch paged results with CloudFetch disabled
aakash-saravanan-db Nov 10, 2026
31287d1
fix(results): enforce disabled cloud downloads and configuration prec…
aakash-saravanan-db Nov 10, 2026
19617a8
test(results): cover disabled CloudFetch against a live server
aakash-saravanan-db Nov 10, 2026
cf809f9
fix(results): classify rejected storage links as a protocol error
aakash-saravanan-db Nov 10, 2026
743e0b4
docs(results): describe paged inline memory bounds
aakash-saravanan-db Nov 10, 2026
cf4f7ec
docs(results): align inline prefetch descriptions
aakash-saravanan-db Nov 11, 2026
4bfac5f
test: cover unsupported inline-result servers
aakash-saravanan-db Nov 11, 2026
86643d4
docs: describe paged inline chunk fetching
aakash-saravanan-db Nov 11, 2026
8fa59b2
test: pin the C ABI no-download session capability
aakash-saravanan-db Nov 11, 2026
cf075a4
docs: clarify warehouse support for inline results
aakash-saravanan-db Nov 11, 2026
85d3723
fix: reject unusable inline responses without exposing storage links
aakash-saravanan-db Nov 11, 2026
dccdcb5
fix(results): preserve explicit download disable across configuration…
aakash-saravanan-db Nov 11, 2026
6615a07
fix(config): explain conflicting CloudFetch settings in native diagno…
aakash-saravanan-db Nov 11, 2026
f69327d
docs(session): correct disabled download configuration explanation
aakash-saravanan-db Nov 11, 2026
0b5d0ed
Merge branch 'main' of github.com-kernel-db:databricks/databricks-sql…
aakash-saravanan-db Nov 11, 2026
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
9 changes: 5 additions & 4 deletions adbc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,11 @@ operation is pending. Client query deadlines and rows-per-block slicing apply
equally to synchronous and submitted execution. Dropping a submitted handle or
an incompletely consumed reader triggers best-effort server cleanup.

`adbc.databricks.cloudfetch.enabled` is wired to the kernel result
configuration. The current kernel/server combination does not yet support the
`false` path because SEA rejects inline Arrow results; disabling CloudFetch is
therefore not a production-supported configuration in this release.
Set `adbc.databricks.cloudfetch.enabled` to `false` to fetch results through
Comment thread
oss-reviewer-bot[bot] marked this conversation as resolved.
Resolved
the SQL connection when the application cannot access cloud storage directly.
Large results are read in pages.
The warehouse must support paged inline delivery; otherwise session creation
or the first statement returns the server's configuration error.

## ADBC behavior

Expand Down
4 changes: 2 additions & 2 deletions include/databricks_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -595,12 +595,12 @@ KernelStatusCode kernel_session_config_set_u2m_token_cache_config(KernelSessionC
*
* Recognised keys (case-insensitive):
* - "cloudfetch_enabled" = "true"|"false" — false serves every result
* inline (SEA disposition = INLINE), mirroring JDBC EnableQueryResultDownload=0.
* through paged inline delivery without cloud-storage downloads.
* - "cloudfetch_link_prefetch_window" = positive integer.
* - "cloudfetch_max_chunks_in_memory" = positive integer (bounds peak RSS;
* values above the kernel ceiling of 256 are clamped with a warning).
* - "inline_max_chunks_in_memory" = positive integer (inline-Arrow prefetch
* window, used when cloudfetch_enabled = false).
* window for paged inline results).
* - "complex_types_as_json" = "true"|"false" — render ARRAY / MAP / STRUCT /
* VARIANT / GEOMETRY / GEOGRAPHY as JSON text (PySQL
* _use_arrow_native_complex_types=False, JDBC complexDatatypeSupport=false).
Expand Down
5 changes: 2 additions & 3 deletions src/c_abi/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1378,15 +1378,14 @@ pub unsafe extern "C" fn kernel_session_config_set_u2m_token_cache_config(
/// Recognised keys (matched case-insensitively), mapping to
/// [`ResultConfig`]:
/// - `cloudfetch_enabled` = `"true"` / `"false"` — `false` serves every
/// result inline (SEA `disposition = INLINE`), mirroring JDBC's
/// `EnableQueryResultDownload=0`.
/// result through paged inline delivery without cloud-storage downloads.
Comment thread
oss-reviewer-bot[bot] marked this conversation as resolved.
Resolved
/// - `cloudfetch_link_prefetch_window` = positive integer — presigned URLs
/// prefetched ahead of the consumer.
/// - `cloudfetch_max_chunks_in_memory` = positive integer — decompressed
/// CloudFetch chunks held at once (bounds peak RSS). Values above the
/// kernel ceiling (256) are **clamped** with a warning, not rejected.
/// - `inline_max_chunks_in_memory` = positive integer — inline-Arrow
/// prefetch window (used when `cloudfetch_enabled = false`).
/// prefetch window for paged inline results.
/// - `complex_types_as_json` = `"true"` / `"false"` — render `ARRAY` /
/// `MAP` / `STRUCT` / `VARIANT` / `GEOMETRY` / `GEOGRAPHY` as JSON text
/// (PySQL `_use_arrow_native_complex_types=False`, JDBC
Expand Down
45 changes: 10 additions & 35 deletions src/client/sea.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,30 +658,6 @@ impl SeaRestTransport {
) -> Result<ExecuteResponse> {
let url = format!("{}/statements", self.base_url());

// Select the result disposition per statement from the
// connection-level CloudFetch setting, mirroring the reference
// JDBC driver's SEA path (`DatabricksSdkClient.getRequest`:
// `cloudFetch ? INLINE_OR_EXTERNAL_LINKS : INLINE`). This is the
// authoritative mechanism for disabling cloud-fetch on SEA —
// there is NO `CAN_CLOUD_DOWNLOAD` session conf (the server
// rejects it at ExecuteStatement with `CONFIG_NOT_AVAILABLE`,
// issue #196).
//
// `INLINE`: the server serves every result inline (Arrow bytes in
// the response `attachment`), regardless of size. `format` stays
// `ARROW_STREAM` — the kernel's inline reader consumes Arrow IPC
// from the attachment (the SEA inline-Arrow path), so unlike JDBC
// we keep Arrow rather than switching to `JSON_ARRAY`.
//
// `INLINE_OR_EXTERNAL_LINKS` (the CloudFetch-enabled default): not
// a public API disposition but enables returning all chunk links
// in a single response (requires the JDBC user agent). Once
// EXTERNAL_LINKS supports multi-link responses, switch back to it.
let disposition = if self.config.cloudfetch_enabled {
"INLINE_OR_EXTERNAL_LINKS"
} else {
"INLINE"
};
let (warehouse_id, session_id) = match self.session_route.get() {
Some(SessionRoute::Standard { .. }) | None => (
Some(self.warehouse_id.clone()),
Expand All @@ -696,7 +672,7 @@ impl SeaRestTransport {
session_version: self.current_session_version(),
catalog: params.catalog.clone(),
schema: params.schema.clone(),
disposition: disposition.to_string(),
disposition: "INLINE_OR_EXTERNAL_LINKS".to_string(),
format: "ARROW_STREAM".to_string(),
wait_timeout: params.wait_timeout.clone(),
on_wait_timeout: params.on_wait_timeout.clone(),
Expand Down Expand Up @@ -1156,10 +1132,15 @@ impl Transport for SeaRestTransport {
&self,
catalog: Option<&str>,
schema: Option<&str>,
session_config: HashMap<String, String>,
mut session_config: HashMap<String, String>,
) -> Result<SessionInfo> {
let url = self.warehouse_sessions_url();

if !self.config.cloudfetch_enabled {
Comment thread
aakash-saravanan-db marked this conversation as resolved.
Resolved
Comment thread
aakash-saravanan-db marked this conversation as resolved.
Resolved
Comment thread
aakash-saravanan-db marked this conversation as resolved.
Resolved
session_config.retain(|key, _| !key.eq_ignore_ascii_case("can_cloud_download"));
session_config.insert("can_cloud_download".to_string(), "false".to_string());
Comment thread
aakash-saravanan-db marked this conversation as resolved.
Resolved
Comment thread
oss-reviewer-bot[bot] marked this conversation as resolved.
Resolved
Comment thread
oss-reviewer-bot[bot] marked this conversation as resolved.
Resolved
}

let request_body = CreateSessionRequest {
warehouse_id: None,
catalog: catalog.map(|s| s.to_string()),
Expand Down Expand Up @@ -1537,18 +1518,12 @@ impl Transport for SeaRestTransport {
))
})?;

// Inline-Arrow path: bytes must be present in `attachment`.
// If the server returned an external_links response on what
// we expected to be the inline path, surface a clear error
// (probably the `disposition = INLINE` on the execute request
// didn't take effect server-side).
let bytes = chunks_response.attachment.ok_or_else(|| {
Error::data_loss().message(format!(
"Inline chunk {} response missing `attachment` field — \
server may have ignored the INLINE disposition and \
returned a CloudFetch response. Body: {}",
chunk_index,
String::from_utf8_lossy(&body)
server did not return inline Arrow data and \
returned a CloudFetch response",
chunk_index
))
})?;

Expand Down
23 changes: 3 additions & 20 deletions src/client/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,8 @@ pub(crate) struct TransportConfig {
/// Whether CloudFetch (cloud-storage-backed result download via
/// external links) is enabled for this session.
///
/// This is a **connection-level** setting — like the reference JDBC
/// driver's `EnableQueryResultDownload`, it is read once at session
/// open and applied to every `ExecuteStatement`, not toggled per
/// statement. It selects the SEA `disposition` sent on each execute:
/// `true` → `INLINE_OR_EXTERNAL_LINKS` (results may come back as
/// external CloudFetch links), `false` → `INLINE` (the server serves
/// every result inline, regardless of size).
///
/// **Why this is `disposition`, not a session conf.** SEA has no
/// `CAN_CLOUD_DOWNLOAD` session conf — sending one is accepted at
/// `CreateSession` but rejected at the first `ExecuteStatement` with
/// `CONFIG_NOT_AVAILABLE` (see issue #196). Both the JDBC and Thrift
/// reference drivers control cloud-fetch per request (SEA
/// `disposition` / Thrift `canDownloadResult`), never via session
/// conf; this mirrors JDBC's SEA path
/// (`DatabricksSdkClient.getRequest`).
/// When false, session creation requests paged inline results without
/// cloud-storage downloads. The value is fixed for the session lifetime.
pub cloudfetch_enabled: bool,
}

Expand Down Expand Up @@ -404,10 +390,7 @@ pub(crate) trait Transport: Send + Sync + std::fmt::Debug {
/// Fetch one inline-Arrow chunk by `chunk_index` (+ server-side
/// `row_offset`).
///
/// Used by the inline-Arrow streaming path that lights up when
/// `ResultConfig.cloudfetch_enabled == false` (i.e. the execute
/// request was sent with SEA `disposition = INLINE`). The
/// server-side response for this path carries Arrow IPC bytes inline
/// Used for paged inline results. The response carries Arrow IPC bytes inline
/// in `attachment` rather than emitting `external_links`.
///
/// Per the bounded SEA API contract for OSS drivers:
Expand Down
46 changes: 7 additions & 39 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1090,30 +1090,9 @@ pub struct ResultConfig {
/// Whether to opt into CloudFetch (cloud-storage-backed download of
/// large result sets via presigned URLs). Default: `true`.
///
/// Setting this to `false` mirrors JDBC's `EnableQueryResultDownload=0`
/// behaviour. It is a **connection-level** setting: read once at
/// [`Session::open`](crate::Session::open) and applied to every
/// statement by selecting the SEA `disposition` on each
/// `ExecuteStatement` (`false` → `INLINE`, so SEA serves **all**
/// result sizes via the inline-Arrow path regardless of size). This
/// matches how the JDBC and Thrift reference drivers control
/// cloud-fetch (per request), and is deliberately **not** expressed
/// as a session conf — SEA has no `CAN_CLOUD_DOWNLOAD` conf and
/// rejects one at ExecuteStatement with `CONFIG_NOT_AVAILABLE`
/// (issue #196). Users who need inline-only behaviour (e.g.
/// workspaces without cloud-storage egress) should set this to
/// `false`.
///
/// Disabling CloudFetch routes results to the inline-Arrow
/// path. The kernel today supports the **single-attachment**
/// inline path; the multi-chunk inline path is on the SEA
/// inline-Arrow rollout (DD1) and is tracked as a follow-up
/// (`InlineArrowProvider::new` consumes one attachment, and
/// `src/reader/mod.rs` returns `Error::not_implemented` for
/// inline responses that carry a `next_chunk_internal_link`).
/// Once multi-chunk lands, this path will not match
/// CloudFetch's concurrent chunk-download pipeline
/// (`cloudfetch_max_chunks_in_memory`).
/// Set to `false` for applications without direct access to cloud storage.
/// This connection-level setting requests paged inline Arrow results.
/// Servers without this capability may reject session creation or the first statement.
pub cloudfetch_enabled: bool,

/// Number of presigned URLs to prefetch ahead of the consumer.
Expand All @@ -1125,8 +1104,7 @@ pub struct ResultConfig {

/// Maximum number of decompressed Arrow chunks the inline-Arrow
/// streaming reader holds in memory at once. Analogue of
/// [`Self::cloudfetch_max_chunks_in_memory`] for the inline path
/// (used when [`Self::cloudfetch_enabled`] is `false`).
/// [`Self::cloudfetch_max_chunks_in_memory`] for paged inline results.
///
/// The inline path is sequential per the SEA contract — one
/// `GetResultData` call at a time — so this knob bounds the
Expand Down Expand Up @@ -1565,19 +1543,9 @@ pub struct SessionConfig {
/// Thrift `configuration`. Typed sub-structs above translate
/// the *client-side* knobs; this map carries everything else.
///
/// The kernel passes user-supplied entries through unchanged. The
/// kernel does not synthesise any entries here from typed
/// client-side knobs.
///
/// In particular, [`ResultConfig::cloudfetch_enabled`] is **not**
/// expressed as a session conf: SEA has no `CAN_CLOUD_DOWNLOAD`
/// conf (it is accepted at CreateSession but rejected at the first
/// ExecuteStatement with `CONFIG_NOT_AVAILABLE`, issue #196).
/// CloudFetch-disable is instead applied per-statement via the SEA
/// `disposition` field, matching the JDBC / Thrift reference
/// drivers. A caller-supplied `can_cloud_download` is still forwarded
/// unchanged because the kernel does not validate server-bound
/// `session_conf` keys.
/// User-supplied entries are passed through, except that disabling
/// CloudFetch in [`ResultConfig`] takes precedence over its corresponding
/// session setting.
///
/// **Boolean-valued conf keys** should use the exact strings
/// `"true"` / `"false"`. SEA accepts these literally; other forms
Expand Down
5 changes: 2 additions & 3 deletions src/reader/inline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@
//! case. The server returns one chunk at a time via
//! `GET /result/chunks/{idx}?row_offset=N`; the kernel maintains a
//! bounded rolling window of pre-decoded chunks ahead of the
//! consumer. Used when CloudFetch is disabled (the execute request
//! was sent with SEA `disposition = INLINE`) and the result is
//! large enough that the server paginates it.
//! consumer. Used when the result is large enough that the server
//! paginates inline delivery.

mod provider;
mod streaming;
Expand Down
3 changes: 1 addition & 2 deletions src/reader/inline/streaming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@

//! `InlineStreamingProvider` — rolling-window prefetch for multi-chunk inline Arrow.
//!
//! Lights up when CloudFetch is disabled (`cloudfetch_enabled = false`,
//! i.e. the execute request was sent with SEA `disposition = INLINE`).
//! Used for paged inline results, including when CloudFetch is disabled.
//! The server returns chunks one at a time via `GET /result/chunks/{idx}`
//! with Arrow IPC bytes in `attachment`; this provider keeps a bounded
//! number of those chunks decoded and ready in memory ahead of the
Expand Down
5 changes: 5 additions & 0 deletions src/reader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ impl ResultReaderFactory {
// Priority 1: CloudFetch (external_links present)
if let Some(ref external_links) = result.external_links {
if !external_links.is_empty() {
if !self.config.enabled {
return Err(Error::data_loss().message(
Comment thread
oss-reviewer-bot[bot] marked this conversation as resolved.
Resolved
"CloudFetch is disabled, but the server returned cloud-storage result links",
));
}
// `total_chunk_count` is forwarded purely as a
// transition-period guard. The link fetcher uses
// it only when the server hasn't yet rolled out
Expand Down
36 changes: 27 additions & 9 deletions src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,6 @@ impl Session {
// install factory.
let defaults = config.defaults.clone().unwrap_or_default();
let transport_config = TransportConfig {
// Thread the connection-level CloudFetch toggle onto the
// transport so every ExecuteStatement picks the right SEA
// disposition (INLINE_OR_EXTERNAL_LINKS vs INLINE). This is
// how cloud-fetch is disabled on SEA — see TransportConfig
// and issue #196; there is no CAN_CLOUD_DOWNLOAD session conf.
cloudfetch_enabled: config.result.cloudfetch_enabled,
..TransportConfig::default()
};
Expand Down Expand Up @@ -423,10 +418,8 @@ impl Session {
"creating session"
);

// CloudFetch-disable is expressed per-statement via the SEA
// `disposition` (threaded onto `TransportConfig` above), not via a
// session conf. The kernel synthesises no geospatial session-conf
// entry; caller-supplied server-bound entries pass through unchanged.
// The kernel synthesises no geospatial session-conf entry;
// caller-supplied server-bound entries pass through unchanged.
// Resolve connector-service flags after authentication and immediately
// before CreateSession. The resolver populates the process-wide
// workspace cache; the session retains no private snapshot.
Expand Down Expand Up @@ -1254,9 +1247,11 @@ fn build_retry_configs_for_session(
/// Matched case-insensitively. If a host sets two spellings of the same key
/// differing only in case, the lexicographically-last spelling wins
/// deterministically and all variants are stripped.
/// An explicit typed CloudFetch disable takes precedence over the mixed bag.
Comment thread
oss-reviewer-bot[bot] marked this conversation as resolved.
Resolved
fn apply_client_result_overrides(config: &mut SessionConfig) {
use crate::config::ClientConfKey;

let cloudfetch_disabled = !config.result.cloudfetch_enabled;
// Recognised client keys currently present in session_conf. A key is
// "recognised" iff it parses to a ClientConfKey (case-insensitive).
let mut present: Vec<String> = config
Expand Down Expand Up @@ -1288,6 +1283,12 @@ fn apply_client_result_overrides(config: &mut SessionConfig) {
);
}
}
if cloudfetch_disabled && config.result.cloudfetch_enabled {
crate::klog::warn!(
"Ignoring cloudfetch_enabled=true in session configuration because the client option disables CloudFetch"
);
config.result.cloudfetch_enabled = false;
}
}

/// Project the public [`ResultConfig`] (today only carries
Expand Down Expand Up @@ -2048,6 +2049,23 @@ mod retry_config_tests {
);
}

#[test]
fn typed_cloudfetch_disable_takes_precedence_over_session_conf() {
for key in ["cloudfetch_enabled", "CLOUDFETCH_ENABLED"] {
let mut cfg = config_with_session_conf(HashMap::from([
(key.to_string(), "true".to_string()),
("TIMEZONE".to_string(), "UTC".to_string()),
]));
cfg.result.cloudfetch_enabled = false;
apply_client_result_overrides(&mut cfg);
assert!(!cfg.result.cloudfetch_enabled);
assert_eq!(
cfg.session_conf,
HashMap::from([("TIMEZONE".to_string(), "UTC".to_string())])
);
}
}

/// All six client-side result knobs are recognised in session_conf,
/// applied to the typed ResultConfig, and stripped so none reach the
/// wire. Guards the parity between `ClientConfKey::ALL` and the
Expand Down
4 changes: 1 addition & 3 deletions src/types/cloudfetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ pub struct CloudFetchConfig {
/// When > 0, consecutive small batches are concatenated into larger batches
/// of approximately this many rows before being served to consumers.
pub batch_merge_target_rows: usize,
/// Rolling-window bound for the multi-chunk inline-Arrow path
/// (used when CloudFetch is disabled, i.e. the execute request is
/// sent with SEA `disposition = INLINE`). Analogue of
/// Rolling-window bound for multi-chunk inline Arrow results. Analogue of
/// [`Self::max_chunks_in_memory`] but for sequential inline
/// prefetches rather than parallel cloud downloads.
pub inline_max_chunks_in_memory: usize,
Expand Down
4 changes: 1 addition & 3 deletions src/types/sea.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,7 @@ pub struct GetChunksResponse {
pub external_links: Option<Vec<ExternalLink>>,
/// Inline Arrow IPC bytes (base64-decoded by serde) for the
/// inline-Arrow streaming path. Populated when the server
/// returns chunks inline rather than via CloudFetch — i.e. when
/// the execute request was sent with SEA `disposition = INLINE`
/// (`cloudfetch_enabled = false`).
/// returns chunks inline rather than via CloudFetch.
#[serde(default, deserialize_with = "deserialize_base64_attachment")]
pub attachment: Option<Vec<u8>>,
}
Expand Down
Loading
Loading