Repository navigation
feat(session/metadata/pyo3): attach async statement by id, case-insensitive table_types, SEA error envelope, num_modified_rows - #139
Merged
Conversation
gopalldb
approved these changes
Jun 8, 2026
…ror envelope, expose num_modified_rows, attach async statement
Batch-3 kernel changes backing the connector's use_kernel parity work:
- metadata: ``filter_tables_by_type`` matches ``table_types``
case-insensitively (``eq_ignore_ascii_case``) so ``tables(['view'])``
matches a ``VIEW`` row regardless of server casing.
- client/http: parse the SEA error envelope (``{error_code, message,
sql_state}``, also the ``{"error": ...}`` wrapper) on transport-level
HTTP errors, attaching ``error_code`` / ``sql_state`` to the returned
``Error`` instead of discarding them into the raw message.
- pyo3: expose ``ExecutedStatement.num_modified_rows`` so the connector
can surface DML rowcount.
- session: add ``Session::attach_async_statement(id)`` (+ pyo3 getter) —
re-attach to an already-submitted server statement by its id, yielding
an ``ExecutedAsyncStatement`` that can poll ``status`` / await results
without having been the submitting handle. SEA keys
GetStatementStatus/Result purely on the id, so this enables resuming an
async statement whose originating handle was dropped (or lives in
another process). The handle is NON-OWNING: it does not close the
server statement on ``Drop`` or ``close()`` (starts ``closed=true``),
so re-attaching on every poll can't tear down the statement being
watched. Seeds initial status from a ``GetStatementStatus``; an
unknown/expired id surfaces ``ErrorCode::NotFound`` (404). Verified
against a live SEA warehouse: GET after close returns 200 state=CLOSED
until TTL, then 404 NOT_FOUND.
Co-authored-by: Isaac
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
vikrantpuppala
force-pushed
the
feat/use-kernel-cuj-batch3
branch
from
June 8, 2026 11:57
3991d8b to
0ab1e0e
Compare
Collaborator
|
P1 — Should fix
P2 — Minor
|
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Batch-3 kernel changes backing the connector's
use_kernelparity work (paired with databricks/databricks-sql-python#838).table_types— case-insensitive (B2)filter_tables_by_typematches requested types witheq_ignore_ascii_case, sotables(table_types=['view'])matches aVIEWrow regardless of the server's canonical casing.Parse the SEA error envelope on transport-level HTTP errors
client/http.rsnow best-effort parses the SEA{error_code, message, sql_state}envelope (and the{"error": ...}wrapper) on non-2xx errors, attachingerror_code/sql_stateto the returnedErrorinstead of discarding them into the raw message. Mirrors what the statement path (sea.rs terminal_outcome) already did.Expose
num_modified_rowsthrough pyo3#[getter] ExecutedStatement.num_modified_rowsso the connector can surface DML rowcount ascursor.rowcount.Session::attach_async_statement(id)— resume an async statement by idRe-attach to an already-submitted server statement by its id, yielding an
ExecutedAsyncStatementthat can pollstatus()/ await results / cancel — without having been the handle that submitted it. SEA keysGetStatementStatus/GetStatementResultpurely on the id, so this enables resuming an async statement whose originating handle was dropped (or lives in another process).Key design points:
closed=true, so it does not close the server statement onDropor viaclose(). Attach is a read-only adopt — the statement's lifecycle stays with whatever submitted it. Without this, a poll loop that re-attaches each tick would close the very statement it's watching. (Locked byattached_handle_drop_does_not_close_statement.)ValidityFlag(no parentStatementto share with), so a re-execute elsewhere can't invalidate it.GetStatementStatus; an unknown/expired id surfacesErrorCode::NotFound(404). A closed statement is not an error — the server keeps reportingCLOSEDuntil the result TTL elapses.Verified against a live SEA warehouse:
GETafter close →200 state=CLOSED(idempotent); a closed-but-succeeded statement keeps reportingSUCCEEDED+ result; an unknown well-formed id →404 NOT_FOUND(distinct from a malformed-id400and a transient5xx).This is what lets the connector make async command state server-sourced — see databricks/databricks-sql-python#838, which deletes its
_closed_commandslocal-state bookkeeping in favour of re-attaching by id.Testing
attach_seeds_status_and_reports_server_state,attach_reports_closed_for_a_closed_statement,attach_errors_not_found_for_unknown_id,attached_handle_drop_does_not_close_statement; plus the existing B2 / HTTP-envelope /num_modified_rowstests.cargo +stable fmt --all,cargo clippy --all-targets -- -D warnings(kernel + pyo3), fullcargo test— all green.