Repository navigation
feat(statement,napi): surface row_limit + per-statement query timeout on StatementSpec - #94
Closed
msrathore-db wants to merge 2 commits into
Closed
msrathore-db wants to merge 2 commits into
msrathore-db wants to merge 2 commits into
Conversation
… on StatementSpec Closes the SEA↔Thrift parity rows 2.15 (row_limit) and 2.17 (server statement timeout) from the cross-driver feature matrix. Both are exercised by Python `use_sea` (row_limit=, wait_timeout=) but were not reachable through the kernel's public StatementSpec, so NodeJS SEA and Python use_kernel could not offer them. - StatementSpec gains `row_limit: Option<i64>` and `query_timeout_secs: Option<u32>` with fluent setters. The SEA wire request already carried `row_limit` / `wait_timeout` / `on_wait_timeout` (types::sea::ExecuteParams); this only surfaces them on the public spec and threads them through `prepare_for_dispatch` — no new wire surface. - Server statement timeout maps to SEA `wait_timeout` with `on_wait_timeout = CANCEL` so the statement is cancelled on elapse (JDBC setQueryTimeout / Python use_sea wait_timeout semantics), distinct from the connection-level transport `overall_timeout`. The wait-timeout precedence (async-submit "0s" respected verbatim vs sync-execute honoring the spec timeout vs server default) is extracted into the pure `resolve_wait_timeout` helper and unit-tested. - napi `ExecuteOptions` exposes `rowLimit` + `queryTimeoutSecs`, threaded onto the spec; the scalars are read before `options` is consumed by the query-tags merge. Validation: cargo fmt + clippy clean; new unit tests cover the spec setters, the wait-timeout precedence (3 cases), and the unchanged query-tags merge. The SEA server clamps wait_timeout at 50s; the kernel forwards the requested value verbatim. Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
With a row_limit applied, the SEA server returns one extra look-ahead Arrow row beyond the logical result size and marks the manifest `truncated = true` with `total_row_count = N` (the requested limit). The inline reader decoded the raw Arrow stream verbatim, so `row_limit = N` surfaced N+1 rows — verified live (limit 10 → 11 rows, ids 0..10; limit 5 → 6) and against the SEA response manifest, which reports `total_row_count = 10, truncated = true` for a limit of 10. The manifest count — not the raw Arrow row count — is the authoritative result size. `InlineArrowProvider::new` now takes the manifest's `total_row_count` and clamps the decoded batches to it (slicing the batch that crosses the boundary), mirroring the Python SEA connector, which bounds its `ArrowQueue` by `total_row_count`. This makes `row_limit` return exactly N rows — parity with Python use_sea and Thrift. `None` (count absent) leaves batches unclamped; an above-actual count is a no-op. The clamp arithmetic is a pure, unit-tested helper. Verified live: row_limit 10 → 10 rows, 5 → 5 rows; non-limited queries unchanged. New unit tests cover None-passthrough, cross-batch slicing, above-actual no-op, and the N+1 look-ahead clamp. Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
This was referenced May 31, 2026
Collaborator
Author
|
Closing as superseded by #101, which is now the main-based kernel SEA parity mega PR for agent review. The branch is preserved and this can be reopened if we decide to return to smaller stacked reviews. |
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.
Summary
Surfaces two per-statement options that the SEA wire already supports but the public
StatementSpecdid not expose — closing parity-matrix rows 2.15 (row_limit) and 2.17 (server statement timeout). Both are offered today by Pythonuse_sea(row_limit=,wait_timeout=); without this, NodeJS SEA and Pythonuse_kernel(both routed through this kernel) cannot match the Thrift/Python surface.This is the follow-on the
statement-optionsExecuteOptionsdoc explicitly deferred (row_limit/wait_timeout"land in follow-on PRs").Changes
StatementSpecgainsrow_limit: Option<i64>andquery_timeout_secs: Option<u32>with fluent setters. No new wire surface —types::sea::ExecuteParamsalready carriedrow_limit/wait_timeout/on_wait_timeout; this threads the spec values throughprepare_for_dispatch.wait_timeoutwithon_wait_timeout = CANCEL, so the statement is cancelled on elapse (JDBCsetQueryTimeout/ Pythonuse_seawait_timeoutsemantics) — distinct from the connection-level transportoverall_timeout."0s"respected verbatim · sync-execute honoring the spec timeout · server default when neither set) is extracted into a pureresolve_wait_timeouthelper and unit-tested in isolation.ExecuteOptionsexposesrowLimit+queryTimeoutSecs, threaded onto the spec; scalars are read beforeoptionsis consumed by the query-tags merge.Layering
Logic lives in the kernel (
StatementSpec→prepare_for_dispatch); napi is a thin pass-through. The NodeJS SEA adapter maps its publicExecuteStatementOptions.maxRows/queryTimeoutonto these napi fields in a separate driver PR.Downstream fixes / reviewer note
queryTimeouttoqueryTimeoutSecs, and databricks-sql-nodejs#408 wiresrowLimitto the kernelrow_limitfield.fix(reader): clamp inline result to manifest.total_row_count) alongside the publicrow_limit/query_timeout_secssurface, so reviewers should not request a separate follow-up for inline Arrow over-fetch within this stack.rowLimitlands later in databricks-sql-nodejs#408; this kernel PR only makes the kernel/napi knobs available.Validation
cargo fmt --all+cargo clippy --libclean.StatementSpecsetters/defaults;resolve_wait_timeout(async-submit, sync+timeout→CANCEL, sync default→omit); the unchanged query-tags merge still passes (16 napi tests green).wait_timeoutat 50s; the kernel forwards the requested value verbatim and lets the server clamp.This pull request and its description were written by Isaac.