Skip to content

Add SEA inline Arrow results and server-flag routing - #1731

Merged
rahuls-db merged 14 commits into
databricks:mainfrom
rahuls-db:rahul-singhal/sea-inline-server-flag
Oct 20, 2026
Merged

rahuls-db merged 14 commits into
databricks:mainfrom
rahuls-db:rahul-singhal/sea-inline-server-flag

Conversation

@rahuls-db

@rahuls-db rahuls-db commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Recreate the SEA inline Arrow result support from #1470 on the latest main, so SEA requests use INLINE_OR_EXTERNAL_LINKS and can consume Arrow bytes returned inline when CloudFetch is disabled.

Also remove the client-side CloudFetch prerequisite from automatic client selection. This lets the server-side enableSqlExecForJdbc flag select SEA when EnableQueryResultDownload=0, while preserving explicit Thrift selection and existing platform safeguards.

The inline provider supports bounded multi-chunk fetching, lazy streaming LZ4 decompression, unknown manifest row counts, and cleanup of prefetched results.

Testing

  • Spotless passed.
  • DatabricksConnectionContextTest: 161 passed.
  • SeaInlineArrowChunkProviderTest: 30 passed.
  • ArrowStreamResultTest: 26 passed.
  • DatabricksResultSetMetaDataTest: 36 passed.
  • DatabricksResultSetTest: 68 passed.
  • DecompressionUtilTest: 13 passed.
  • DatabricksSdkClientTest passed.

Telemetry Errors

  • Not applicable — this PR does not add or change a telemetry-visible error.
  • Applicable — the error uses DatabricksDriverErrorCode where appropriate, and any new code is uniquely numbered and tested.
  • Applicable — its driver/server/user classification is linked, or maintainer help is requested because the author cannot access the classification.

Additional Notes to the Reviewer

The server-side SQL Execution API feature flag remains the rollout control. The live E2E test is included but was not run locally.

@rahuls-db
rahuls-db requested a review from vuanhphung October 19, 2026 19:56
gopalldb and others added 8 commits October 19, 2026 20:26
…ownload=0)

When UseBoundedSeaApi=1 AND EnableQueryResultDownload=0:

1. Session conf: sends can_cloud_download=false to tell server to inline
   results instead of using cloud storage.

2. Execute request: uses ARROW_STREAM + INLINE_OR_EXTERNAL_LINKS (instead
   of JSON_ARRAY + INLINE). This gets Arrow IPC data in the attachment
   field rather than JSON in data_array.

3. New SeaInlineArrowChunkProvider: lazily fetches inline Arrow chunks via
   GetResultData with row_offset. Similar to Thrift's
   LazyThriftInlineArrowResult but using SEA's ArrowIPC format in the
   attachment field. Decompresses via DecompressionUtil, creates
   ArrowResultChunk per chunk. End-of-stream when nextChunkIndex is null.

4. getResultChunksData overload: accepts rowOffset parameter, appends
   ?row_offset=N when bounded SEA is enabled.

Without UseBoundedSeaApi=1, EnableQueryResultDownload=0 continues to use
the existing JSON_ARRAY inline format (unchanged).

Co-authored-by: Isaac
Signed-off-by: Gopal Lal <[email protected]>
…oring ThriftStreamingProvider

Replace synchronous lazy-fetch design with background prefetch thread
using ReentrantLock + Condition signaling, ConcurrentHashMap for indexed
chunk storage, and explicit chunksInMemory tracking for backpressure.
This ensures consistency with ThriftStreamingProvider's design patterns.

Signed-off-by: Gopal Lal <[email protected]>

Co-authored-by: Isaac
Signed-off-by: Gopal Lal <[email protected]>
Document why nextFetchChunkIndex and nextFetchRowOffset are safe as
separate AtomicLongs (single prefetch thread writer) unlike
StreamingChunkProvider which needs a bundled FetchPosition holder.

Signed-off-by: Gopal Lal <[email protected]>

Co-authored-by: Isaac
Signed-off-by: Gopal Lal <[email protected]>
…on and server-provided chunk indices

- Add DecompressionUtil.decompressLazy() that wraps compressed bytes in
  LZ4FrameInputStream for lazy decompression (no intermediate byte[] buffer)
- Replace eager decompress() with decompressLazy() in processResultData()
  so ultra-compressed data doesn't blow up memory during decompression
- Refactor chunk consumption to use server-provided next_chunk_index via a
  ConcurrentLinkedQueue instead of assuming sequential indices
- Add 30 unit tests for SeaInlineArrowChunkProvider covering single/multi
  chunk iteration, streaming decompression, error handling, lifecycle,
  backpressure, edge cases, and prefetch behavior
- Add 7 unit tests for DecompressionUtil.decompressLazy()

Signed-off-by: Gopal Lal <[email protected]>

Co-authored-by: Isaac
Signed-off-by: Gopal Lal <[email protected]>
@rahuls-db
rahuls-db force-pushed the rahul-singhal/sea-inline-server-flag branch from 9d6619e to fe18d86 Compare October 19, 2026 20:32
@rahuls-db rahuls-db changed the title Allow SEA with inline query results Add SEA inline Arrow results and server-flag routing Oct 19, 2026
@rahuls-db
rahuls-db requested a review from vuanhphung October 19, 2026 21:27
Format format = cloudFetch ? Format.ARROW_STREAM : Format.JSON_ARRAY;
// Bounded SEA inline Arrow: use ARROW_STREAM + INLINE_OR_EXTERNAL_LINKS even without CloudFetch
boolean boundedSeaInline = connectionContext.isBoundedSeaApiEnabled() && !cloudFetch;
Format format = (cloudFetch || boundedSeaInline) ? Format.ARROW_STREAM : Format.JSON_ARRAY;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

when arrow is disabled, useCloudFetchForResult() will return false, so boundedSeaInline will be true and we will request arrow. this seems like a bug

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

You're right. I audited the entire param waterfall logic and here's the behavior with green cells highlighting the exact behavior change in this PR -

image

@rahuls-db
rahuls-db force-pushed the rahul-singhal/sea-inline-server-flag branch from 5c84361 to 1afd2ee Compare October 20, 2026 01:40
@rahuls-db
rahuls-db requested a review from vuanhphung October 20, 2026 01:54
@rahuls-db
rahuls-db marked this pull request as draft October 20, 2026 04:48
@rahuls-db
rahuls-db marked this pull request as ready for review October 20, 2026 05:14
@rahuls-db
rahuls-db added this pull request to the merge queue Oct 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 20, 2026
Signed-off-by: Rahul Singhal <[email protected]>
@rahuls-db
rahuls-db enabled auto-merge October 20, 2026 06:57
@rahuls-db
rahuls-db added this pull request to the merge queue Oct 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 20, 2026
@rahuls-db
rahuls-db enabled auto-merge October 20, 2026 16:21
@rahuls-db
rahuls-db added this pull request to the merge queue Oct 20, 2026
Merged via the queue into databricks:main with commit 3a2f068 Oct 20, 2026
22 of 23 checks passed
@rahuls-db
rahuls-db deleted the rahul-singhal/sea-inline-server-flag branch October 20, 2026 17:08
github-merge-queue Bot pushed a commit that referenced this pull request Oct 20, 2026
## Description

Include the SEA inline Arrow support and server-flag routing from #1731
in JDBC 3.4.4. Roll both entries into the release notes and changelog,
clear NEXT_CHANGELOG, and update the release date to October 20.

## Testing

Clean core tests and thin/uber packaging passed: 3,780 tests, zero
failures or errors, 88 skipped. Both JARs report 3.4.4 and contain the
inline Arrow provider. Changelog coverage and git diff --check passed.
Fresh remote correctness and benchmark validation are pending before
tagging.

## Telemetry Errors

- [x] Not applicable — this PR does not add or change a
telemetry-visible error.

Signed-off-by: Vu Anh Phung <[email protected]>
diegofanesi pushed a commit to diegofanesi/databricks-jdbc that referenced this pull request Oct 28, 2026
## Description
Route every inline Arrow response through `SeaInlineArrowChunkProvider`
when bounded SEA is enabled, including hybrid CloudFetch responses that
return their initial data inline. This removes the remaining split
between the legacy inline provider and the bounded SEA continuation
path.

Also handle the provider end-of-stream transition in
`ArrowStreamResult.next()` without dereferencing a missing chunk.

## Testing
Added a hybrid-inline test that asserts `SeaInlineArrowChunkProvider` is
selected and consumes both the initial and continuation chunks. `git
diff --check` passes. Full CI will run on this PR.

**Comparator Tests**
Validated Thrift-versus-SEA parity on the staging warehouse with
CloudFetch both enabled and disabled.

* 15,242 comparisons per mode across nine configurations, excluding
USE_QUERY_FOR_METADATA and PRO_WAREHOUSE
* CloudFetch-enabled and disabled runs produced identical results
* No differences in query results, row counts, Arrow data, chunk
traversal, compression, complex types, geospatial data, or volume
operations
* All comparator suites completed without execution errors

The reported differences were existing Thrift-versus-SEA behavior
unrelated to this PR:

* 756 getTables/getColumns differences: for empty-string catalog/schema
arguments, Thrift throws error 1003 while SEA returns an empty result
set.
* 275 primary/imported/exported-key metadata differences: both clients
reject invalid inputs, but Thrift returns a server stack trace while SEA
returns a concise validation error.
* 43 negative-test differences: both clients fail as expected but format
error messages differently.
* 1 stale DDL expectation: both clients return the same additional
metadata columns.
* 1 EXPLAIN difference: only dynamically generated expression IDs
differ.

This provides no evidence of a regression from the inline chunk-provider
unification.

## Telemetry Errors
- [x] Not applicable — this PR does not add or change a
telemetry-visible error.
- [ ] Applicable — the error uses `DatabricksDriverErrorCode` where
appropriate, and any new code is uniquely numbered and tested.
- [ ] Applicable — its driver/server/user classification is linked, or
maintainer help is requested because the author cannot access the
classification.

## Additional Notes to the Reviewer
`NO_CHANGELOG=true`

This is intentionally separate from databricks#1731 so the request-routing
behavior and provider unification can be reviewed independently.

---------

Signed-off-by: Rahul Singhal <[email protected]>
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.

3 participants