Skip to content

fix(cloudfetch): disable via per-statement disposition, not session conf - #225

Merged
vikrantpuppala merged 1 commit into
mainfrom
fix/196-cloudfetch-disposition
Aug 10, 2026
Merged

vikrantpuppala merged 1 commit into
mainfrom
fix/196-cloudfetch-disposition

Conversation

@vikrantpuppala

Copy link
Copy Markdown
Collaborator

Summary

Fixes #196. Setting ResultConfig::cloudfetch_enabled = false made the session unusable: the kernel synthesised a CAN_CLOUD_DOWNLOAD=false SEA session conf at CreateSession, which the server accepts at session-create but then rejects at the first ExecuteStatement with [CONFIG_NOT_AVAILABLE] ... SQLSTATE: 42K0I. SEA has no such session conf.

Root cause & reference verification

I verified the correct behaviour empirically against the OSS JDBC reference driver (~/databricks-jdbc) rather than trusting the issue's stated "expected":

  • CAN_CLOUD_DOWNLOAD / can_cloud_download appears nowhere in the JDBC (or Thrift) driver source.
  • JDBC's EnableQueryResultDownload is documented as "Use EnableQueryResultDownload=0 for JSON inline results with SEA" and drives a per-statement disposition, not a session conf: DatabricksSdkClient.getRequest sets disposition = cloudFetch ? INLINE_OR_EXTERNAL_LINKS : INLINE.
  • The Thrift path does the same per-statement (setCanDownloadResult).

So the kernel was using the wrong wire mechanism entirely.

Fix

Mirror the reference drivers — control cloud-fetch per statement via the SEA disposition:

  • Thread cloudfetch_enabled onto TransportConfig (a connection-level setting, read once at Session::open).
  • In SeaRestTransport::call_execute_api, select disposition = INLINE when disabled, INLINE_OR_EXTERNAL_LINKS when enabled. format stays ARROW_STREAM (the kernel's inline reader consumes Arrow IPC from the response attachment).
  • Remove the can_cloud_download session-conf synthesis in Session::open.
  • Drop CAN_CLOUD_DOWNLOAD from the session-conf allowlist, so a stray caller-supplied value is filtered out (with a warn) rather than forwarded to the wire where it would poison the session.

The result-reader factory already dispatches on what the server returns (attachment → inline reader), so no reader change was needed.

Test plan

  • New execute-path wiremock tests (tests/v0_execute_wiremock.rs):
    • execute_with_cloudfetch_enabled_sends_inline_or_external_links_disposition
    • execute_with_cloudfetch_disabled_sends_inline_disposition — this is the reproduction; it asserts disposition = INLINE and a successful inline result. It failed before the fix (disposition was hardcoded INLINE_OR_EXTERNAL_LINKS) and passes after.
  • Session-path wiremock tests (tests/v0_session_wiremock.rs) rewritten: the old tests asserted the (bogus) CAN_CLOUD_DOWNLOAD synthesis; they now assert no can_cloud_download ever reaches CreateSession on the default, disabled, and stray-user-supplied paths.
  • New filter_session_conf unit tripwire (src/config.rs): can_cloud_download is dropped under any casing — flips RED if it's re-added to the allowlist.
  • cargo test, cargo clippy --all-targets -- -D warnings, and cargo fmt all clean (run with --no-default-features --features tls-rustls in this env due to a local OpenSSL 3.x / native-tls linker mismatch unrelated to this change).

Notes

  • The upstream conformance tripwire referenced in the issue (databricks-driver-test CLOUDFETCH-012, a #[should_panic] xfail) lives in a separate repo and will flip RED once this lands, as intended.

Closes #196

This pull request and its description were written by Isaac.

Setting `ResultConfig::cloudfetch_enabled = false` made the session
unusable: the kernel synthesised a `CAN_CLOUD_DOWNLOAD=false` SEA
session conf at CreateSession, which the server accepts at session
create but then rejects at the first ExecuteStatement with
`[CONFIG_NOT_AVAILABLE] ... SQLSTATE: 42K0I`. SEA has no such session
conf.

Both the JDBC and Thrift reference drivers control cloud-fetch
per request, never via session conf — JDBC's SEA path
(`DatabricksSdkClient.getRequest`) picks
`disposition = cloudFetch ? INLINE_OR_EXTERNAL_LINKS : INLINE`, and
`CAN_CLOUD_DOWNLOAD` appears nowhere in either driver.

This change mirrors that:
- Thread `cloudfetch_enabled` onto `TransportConfig` (a connection-level
  setting, read once at `Session::open`).
- In `call_execute_api`, select `disposition = INLINE` when disabled,
  `INLINE_OR_EXTERNAL_LINKS` when enabled. `format` stays `ARROW_STREAM`
  (the kernel's inline reader consumes Arrow IPC from the response
  attachment).
- Remove the `can_cloud_download` session-conf synthesis in
  `Session::open` entirely.
- Drop `CAN_CLOUD_DOWNLOAD` from the session-conf allowlist so a stray
  caller-supplied value is filtered out (with a warn) rather than
  forwarded to the wire where it would poison the session.

The result-reader factory already dispatches on what the server returns
(attachment -> inline reader), so no reader change is needed.

Tests:
- New execute-path wiremock tests assert the disposition per
  `cloudfetch_enabled` (INLINE vs INLINE_OR_EXTERNAL_LINKS); the
  disabled case is the reproduction that failed before the fix.
- Session-path wiremock tests rewritten to assert no `can_cloud_download`
  ever reaches CreateSession (default, disabled, and stray-user-supplied).
- New `filter_session_conf` unit tripwire: `can_cloud_download` is
  dropped under any casing.

Closes #196

Co-authored-by: Isaac
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No issues identified by the review bot.

This branch was previously deployed

1 inactive deployment
azure-prod — 2bfff99a Deployed Aug 10, 2026 by vikrantpuppala via review #98
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cloudfetch_enabled=false synthesises CAN_CLOUD_DOWNLOAD conf that SEA rejects (CONFIG_NOT_AVAILABLE)

1 participant