Skip to content

Complete Volume file operations through the kernel backend - #1057

Open
aakash-saravanan-db wants to merge 62 commits into
mainfrom
aakash-saravanan_data/feat/volume-restart-20261113
Open

aakash-saravanan-db wants to merge 62 commits into
mainfrom
aakash-saravanan_data/feat/volume-restart-20261113

Conversation

@aakash-saravanan-db

@aakash-saravanan-db aakash-saravanan-db commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Feature or gap

Kernel-backed cursors need to complete server-marked Volume transfers through the Python staging API.

What this PR addresses

Complete file PUT, GET, REMOVE and BinaryIO PUT through the native core. Keep the mutable statement owner and detached canceller available during synchronous transfer, consume instruction rows on completion, and preserve Python filesystem and HTTP exception mapping. Async execution completes through its retained result stream. Cancelling or closing the cursor stops a running transfer; the Thrift backend lets it finish. Resolved symlink targets must stay within staging_allowed_local_path.

Dependencies

Requires the kernel Volume APIs in databricks/databricks-sql-kernel#513 and a compatible coordinated native release. The package floor and lock must select that release, with clean installed-driver validation before merge.

Kernel version

The compatible kernel release has not been selected. When it is available, update the dependency floor and lockfile in this PR and validate a clean installation before merge. KERNEL_REV selects source for local and CI builds only.

Tests and validation

The focused client and result-set suites pass. Local validation uses source-built native inputs; package installation and scheduled activation remain separate gates.

@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.

Verdict: 1 High · 1 Medium · 1 Low

Needs changes. The main blocker is that the code relies on new kernel APIs while the dependency floor still allows older wheels, which would break every kernel query, not only Volume operations. There is also a KeyError crash when the best-effort canceller is missing.

Other findings

  • 🔵 Low — This PR deletes the kernel e2e tests for staging and adds no replacements. All new coverage uses mocks that invent is_volume_operation, complete_volume_operation return strings ("needs_input_stream", "completed", "not_volume") and exception attributes (local_os_error, http_status, local_path). Nothing in CI checks that the real kernel binding actually has these names and values. Please add kernel e2e cases, such as PUT→GET→REMOVE round trips (file and input_stream) and a rejected symlink outside the allowed root, so a mismatch with the kernel contract fails the build.

@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.

Verdict: 1 High · 1 Medium · 2 Nit

Needs changes: 1 high, 1 medium and 2 low findings. The high one: the new is_volume_operation attribute is read unconditionally on every execute, but the kernel floor is still ^1.4.0, so released wheels would break all kernel queries. The medium one: any kernel error with an HTTP status is turned into a generic staging OperationalError. Follow-up already noted in the PR: Windows and installed released-package validation are still open.

Other findings

  • ⚪ Nit — The new ordering (backend close_command first, then _kernel_handle.close()) now applies to every kernel result set, not only Volume ones. For async results, close_command closes the retained owning handle and the parent Statement (client.py ~800-820) while the result stream taken from them is still open. Before this change the stream was closed first. Any error from closing the stream afterwards is logged and swallowed, but this changes the teardown order for all async results to work around a lock that only Volume transfers hold. Consider cancelling only the Volume canceller first and keeping the old order for everything else.
  • ⚪ Nit — Several new cancellation paths have no unit tests: close_session now cancels all in-flight sync cancellers and retained Volume cancellers, and close_command cancels a pending Volume canceller (client.py:784-790). The only Volume backend test covers cancel_command and finish_volume_operation. test_volume_close_signals_backend_before_native_lock uses a mocked backend, so it doesn't exercise the real close_command logic. Add tests that (a) close_command on a registered Volume id calls cancel() and removes the entry, and (b) close_session cancels and clears both maps, even when cancel() raises.
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@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.

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 High · 1 Low

Looks good — 1 low concern. Merge is still blocked on the dependency gate the PR already notes: KernelResultSet reads is_volume_operation on every handle, so with the current floor an older kernel wheel would break every query.

This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.

results_queue=None,
description=description_from_arrow_schema(schema),
is_staging_operation=False,
is_staging_operation=kernel_handle.is_volume_operation,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High — KernelResultSet.__init__ reads kernel_handle.is_volume_operation for every result, and execute_command reads executed.is_volume_operation too. The lock file pins databricks-sql-kernel 1.5.0 and pyproject allows ^1.5.0, so a released wheel without the Volume API would break ordinary queries. Only KERNEL_REV was bumped, so installed users aren't covered. Raise the dependency floor and lock to the release that has the Volume API, or read the attribute defensively with getattr.

🔀 Found by GPT-6.1 Sol · confirmed by the judge

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.

Blocked on the kernel release, so I'm leaving this open: is_volume_operation and complete_volume_operation need databricks/databricks-sql-kernel#520 and #521 merged and a released databricks-sql-kernel that includes them, and the pyproject.toml floor and lock move to that release before this merges. KERNEL_REV already pins the #521 head for source builds.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Still open at 3aa6fca: result_set.py:87 still reads is_volume_operation directly, and the floor and lock remain at 1.5.0 until the kernel release.

Comment thread src/databricks/sql/client.py Resolved

@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.

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 High · 1 Low

Looks good, with 1 low concern: a code comment and the docs disagree on the default Volume transfer idle limit. Not yet mergeable: is_volume_operation is read unconditionally, so current kernel wheels break every query until the dependency floor and lock select the release with databricks/databricks-sql-kernel#513.

This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.

Comment thread src/databricks/sql/client.py Resolved
pass
executed = stmt.execute()
command_id = CommandId.from_sea_statement_id(executed.statement_id)
if executed.is_volume_operation:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High — KernelResultSet reads kernel_handle.is_volume_operation for every statement, and client.py reads executed.is_volume_operation. pyproject allows ^1.5.0 and poetry.lock pins 1.5.0, which likely predates these APIs, so ordinary queries could fail with AttributeError. Raise the kernel dependency floor to the release that has the Volume APIs and regenerate the lockfile.

🔀 Found by GPT-6.1 Sol · confirmed by the judge

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.

Blocked on the kernel release, so I'm leaving this open: is_volume_operation and complete_volume_operation need databricks/databricks-sql-kernel#520 and #521 merged and a released databricks-sql-kernel that includes them, and the pyproject.toml floor and lock move to that release before this merges. KERNEL_REV already pins the #521 head for source builds.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Still open at 3aa6fca: the pyproject floor and lock still need to move to a released kernel with the Volume APIs before merge.

Pin the kernel bindings that complete Volume PUT, GET and REMOVE
(databricks-sql-kernel #521 on #520). The Volume API this connector
uses is unchanged. The docs drop the note that a redirected PUT resend
has no idle bound, which this kernel no longer does, and state that a
kernel PUT reads a regular file.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@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.

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 High · 2 Low

Needs changes: 1 high, 1 low. The Volume completion and cancel wiring looks correct, but the code assumes a kernel API that the current dependency floor (1.5.0) doesn't provide.

This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.

Comment thread tests/e2e/test_kernel_backend.py Resolved
pass
executed = stmt.execute()
command_id = CommandId.from_sea_statement_id(executed.statement_id)
if executed.is_volume_operation:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High — The code now reads is_volume_operation and calls complete_volume_operation on every kernel result, but the dependency floor is still ^1.5.0 while KERNEL_REV moved to a new kernel. A released 1.5.0 wheel may lack these attributes, so ordinary queries could raise AttributeError. Bump the floor and lock to a release that has the Volume API, or read the attribute defensively.

🔀 Found by both reviewers · confirmed by the judge

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.

Blocked on the kernel release, so I'm leaving this open: is_volume_operation and complete_volume_operation need databricks/databricks-sql-kernel#520 and #521 merged and a released databricks-sql-kernel that includes them, and the pyproject.toml floor and lock move to that release before this merges. KERNEL_REV already pins the #521 head for source builds.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Still open at 3aa6fca: client.py:651 reads is_volume_operation with no fallback, and the pyproject floor/lock still haven't moved past ^1.5.0.

Comment thread src/databricks/sql/client.py Resolved
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@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.

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 High · 1 Low

Mostly sound, with 1 medium and 1 low concern. The cancel and close wiring for sync and async Volume transfers holds up. The main risk is that every kernel query now reads is_volume_operation, which some wheels allowed by the current kernel floor (^1.5.0) don't have.

pass
executed = stmt.execute()
command_id = CommandId.from_sea_statement_id(executed.statement_id)
if executed.is_volume_operation:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High — The code reads is_volume_operation on every kernel result, but pyproject allows ^1.5.0 and poetry.lock pins 1.5.0, which likely lacks the attribute, so every query would raise AttributeError. Raise the dependency floor and lock to the kernel release that includes the Volume API, or read it with getattr(..., False).

🔀 Found by both reviewers · confirmed by the judge

else "You must provide at least one staging_allowed_local_path when initialising a connection to perform ingestion commands"
)
raise ProgrammingError(message) from exc
os_code = getattr(exc, "local_os_error", None)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Low — staging_allowed_local_path=[] gives paths == [], which is not None. A PUT or GET is then rejected with the 'restricted to paths within' message, while Thrift says 'You must provide at least one staging_allowed_local_path'. Choose the message with if paths (empty or None) instead of paths is not None, and add the [] case to the parametrized test.

🔀 Found by Claude Opus 5.5 · the judge disputed it but couldn't back that up, so it's kept

@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.

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 High · 1 Low

Changes requested: 1 high, 1 low. The cancel and cleanup wiring for Volume transfers looks consistent. The blocker is the unconditional is_volume_operation reads, which break every kernel query against the current ^1.5.0 kernel floor.

results_queue=None,
description=description_from_arrow_schema(schema),
is_staging_operation=False,
is_staging_operation=kernel_handle.is_volume_operation,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High — is_volume_operation is read unconditionally on every kernel result, but pyproject still allows kernel ^1.5.0, which apparently lacks it. Ordinary queries would then raise AttributeError. Bump the kernel floor and lock to the release with the Volume API, or use getattr(..., False).

🔀 Found by both reviewers · confirmed by the judge

try:
return self._make_result_set(executed, cursor, command_id)
except Exception as exc:
self.finish_volume_operation(command_id)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Low — The cleanup paths are untested: finish_volume_operation after a _make_result_set failure, and close_command popping _volume_cancellers. Add unit tests asserting _volume_cancellers is empty after each.

🔀 Found by Claude Opus 5.5 · confirmed by the judge

@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.

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 High · 1 Low

Needs a dependency gate before merge — 1 medium, 1 low. The native Volume completion wiring and error mapping look sound, and the tests cover the main paths well.

self.close()
raise
outcome = self._complete_volume_operation(paths, data)
if outcome != _kernel.VolumeCompletion.Completed:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Low — If the cursor is closed from another thread while the input stream is being read, close() sets _kernel_handle = None. The second _complete_volume_operation call then raises a bare AttributeError. Check for a closed handle after the read and raise a clear driver error, such as one saying the operation was cancelled or closed.

🔀 Found by Claude Opus 5.5 · confirmed by the judge

pass
executed = stmt.execute()
command_id = CommandId.from_sea_statement_id(executed.statement_id)
if executed.is_volume_operation:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High — The code reads kernel_handle.is_volume_operation and executed.is_volume_operation on every query. pyproject.toml still allows kernel ^1.5.0, and only KERNEL_REV was bumped, so older wheels fail on ordinary SELECTs. Raise the dependency floor and lock to the release that has the Volume API, or read the attribute with getattr(..., False).

🔀 Found by both reviewers · confirmed by the judge

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Aakash Saravanan <aakash.saravanan@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.

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 High · 1 Low

Looks good, with one low concern. The canceller lifecycle, the error mapping and the native completion routing check out against the sync, async and close paths. The kernel dependency floor and lockfile are not updated yet; as the PR description says, that must happen before merge.

This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.

pass
executed = stmt.execute()
command_id = CommandId.from_sea_statement_id(executed.statement_id)
if executed.is_volume_operation:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High — The kernel client now reads is_volume_operation on every executed statement and result set, but pyproject.toml still allows kernel ^1.5.0, which lacks the Volume API. Installs on that version would fail on ordinary queries. Raise the dependency floor to the kernel release that includes the Volume API, or guard the access, before release.

🔀 Found by GPT-6.1 Sol · confirmed by the judge

Comment thread CHANGELOG.md
# Unreleased
- Honor `_port` and `_connection_uri` on kernel connections (`use_kernel=True`), as Thrift does. Requires a databricks-sql-kernel release that includes databricks/databricks-sql-kernel#505.
- Speed up `fetchone()`, `fetchmany()` and `fetchall()` by building each result `Row` with fewer Python calls. The rows are unchanged. Large results and many concurrent cursors in one process benefit most.
- Support Volume `PUT`, `GET` and `REMOVE` on the kernel backend, including existing Python stream uploads. Local file paths and resolved symlink targets must stay within configured allowed roots.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Low — The changelog entry for kernel Volume support doesn't name the kernel version it needs, although the code calls complete_volume_operation and VolumeCompletion. The entry above it does state its requirement. Add the matching 'Requires a databricks-sql-kernel release that includes ...' note.

🔀 Found by Claude Opus 5.5 · confirmed by the judge

This branch was previously deployed

1 inactive deployment
azure-prod — 99b92f10 Deployed Dec 2, 2026 by oss-reviewer-bot[bot] via followup #2802
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant