Repository navigation
feat(napi): accept ExecuteOptions on executeStatement — statementConf + queryTags - #75
Closed
msrathore-db wants to merge 3 commits into
Closed
msrathore-db wants to merge 3 commits into
msrathore-db wants to merge 3 commits into
Conversation
This was referenced May 25, 2026
msrathore-db
added a commit
that referenced
this pull request
May 26, 2026
…nf map Add a Quick-reference section at the top mapping the six implementation PRs (#74/#75/#76/#392/#393/#394) to features + test counts, plus a Python comparison table showing how each feature maps to Python's `use_sea=True` / `use_kernel=True` reference implementations. Scope-down the Statement conf map + Query tags rows in Section 3 to clarify the implementation is napi-only — the public NodeJS `ExecuteStatementOptions` surface does not yet expose them. Wiring to public API is a follow-up increment. Documented as Note 7. Addresses DA's round-3 PR #77 review point on Statement conf map scope. Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
Collaborator
Author
|
Re-review requested — round-3 fixups landed; DA round-3 sign-off received. Round-3 final tip: This PR carries the F3 kernel-side work (
Gates: Co-authored-by: Isaac |
msrathore-db
force-pushed
the
msrathore/krn-max-connections
branch
from
May 26, 2026 10:08
0c5ca3f to
9c2ad89
Compare
… + queryTags
Surfaces two of the kernel `StatementSpec` knobs through napi so
JS callers can pass per-statement Spark conf and query tags:
- `statementConf: Record<string, string>` — per-statement conf
overlay; merged on top of the session-level `sessionConf` at
execute time. The kernel's `StatementSpec::statement_conf()`
setter accepts this verbatim and forwards to SEA `parameters` /
Thrift `confOverlay`.
- `queryTags: Record<string, string>` — convenience wrapper that
JSON-encodes the tag map into the `query_tags` conf overlay key,
matching NodeJS Thrift's `serializeQueryTags` shape
(`{"k":"v","k2":"v2"}`). Passing both `queryTags` and an explicit
`statementConf["query_tags"]` raises `InvalidArgument` to
surface the ambiguity to the caller.
Deferred (require kernel-side `StatementSpec` extensions or napi
TypedValue mapping — separate PRs):
- Positional / named parameters (TypedValue mapping)
- Row limit, wait timeout (need `StatementSpec.row_limit` /
`wait_timeout` fields — currently only on internal `ExecuteParams`)
- Async execute (kernel has `submit()`; needs new napi wrapper class)
The new `ExecuteOptions` napi-object is `Option<…>` so existing
callers (`executeStatement(sql)`) keep working — napi-rs emits
`options?: ExecuteOptions | undefined | null` on the JS-side d.ts.
Empty maps (`{statementConf: {}}`) are treated the same as
omission so the wire shape stays stable for the common case.
Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
DA round 1 findings on F3: H1 (clippy `err_expect`): the `merged_conf_rejects_dual_query_tags_definition` test used `.err().expect(...)` which clippy 1.95+ flags. Switch to `.expect_err(...)` per the suggested help text. Behaviour unchanged; this was a stylistic clippy lint, not a logic defect. H2 (rustfmt): the `merged_conf_query_tags_escape_backslash_in_keys` test expressed a long `assert_eq!` on one line that exceeded rustfmt's max width. Break across three lines per the cargo fmt diff. Behaviour unchanged. Why I missed these initially: my prior gate verification ran inside a different worktree on the same branch (the F3b worktree, which had an in-progress amend), so my local `cargo clippy` + `cargo fmt --check` both reported green there. The origin branch (this PR's HEAD `79bba34`) didn't carry that amend. Lesson: never trust gate verification across worktrees without confirming the working tree matches the pushed SHA. Verified post-fix: - `cargo clippy --all-targets -- -D warnings` ✓ - `cargo +stable fmt --check` ✓ - `cargo test --lib` ✓ (32/32, same as before the fix) Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
DA round 2 findings on F3 (statement options + query tags): M1 docs: prior docstring claimed `queryTags` is "JSON-encoded into the conf overlay" — wrong. The actual implementation serialises to comma-separated `key:value` matching NodeJS Thrift's `serializeQueryTags` wire shape (`lib/utils/queryTags.ts`). Updated three sites that carried the stale "JSON" reference: - `ExecuteOptions` struct doc - `query_tags` field doc - `Connection::execute_statement` method doc + inline comment M2 dead code: the napi `queryTags` field is intentionally exported even though the JS adapter today pre-serialises via the Thrift helper and writes into `statementConf["query_tags"]` directly. The field stays as an alternate API surface for non- NodeJS consumers (future pyo3 reuse, direct napi consumers); the NodeJS adapter path is documented as the byte-identical-Thrift- parity route. Updated the struct doc to spell out the dual paths and their parity contracts. M4 parity: added a struct-level "Tag-order caveat" doc block that documents the HashMap-iteration-order vs `Object.keys`- insertion-order divergence between the napi `queryTags` path and Thrift's `serializeQueryTags`. The SEA server is order- insensitive on conf values so the two are functionally equivalent; callers needing byte-identical Thrift parity use the JS adapter path. Added 5 new Rust unit tests pinning the per-tag byte shape against the Thrift algorithm: - single-tag deterministic case - value-side escape ordering (`\` `:` `,`) - key-side backslash-only escape (NOT colons/commas — Thrift asymmetry pinned so a future "uniformity" refactor fails the test) - empty-map edge case - multi-tag order-insensitive set equality M3 lint: already clean — `cargo clippy --all-targets -- -D warnings` passes locally on this branch's tip. Test count: 32 → 37 (5 new). All passing. Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
msrathore-db
force-pushed
the
msrathore/krn-statement-options
branch
from
May 26, 2026 10:34
e5c53da to
be45ab2
Compare
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 of the kernel
StatementSpecknobs through napi so JS callers can pass per-statement Spark conf and query tags onConnection.executeStatement:Record<string, string>) — per-statement Spark conf overlay merged on top of the session-levelsessionConfat execute time. Routes verbatim intoStatementSpec::statement_conf().Record<string, string>) — serialised to comma-separatedkey:valuematching the wire shape produced by NodeJS Thrift'sserializeQueryTags(k1:v1,k2:v2with backslash-escapes). Passing bothqueryTagsand an explicitstatementConf["query_tags"]raisesInvalidArgument.Implementation
ExecuteOptionsnapi-object with optionalstatement_conf+query_tagsmapsConnection.executeStatement(sql, options?)accepts the new arg; backward-compatible (existingexecuteStatement(sql)keeps working — napi-rs emitsoptions?: ExecuteOptions | undefined | nullon the JS d.ts)build_merged_statement_confhelper merges the two maps and serialises query tags via the same algorithm Thrift usesserializeQueryTagsalgorithm (round 2)Round 2 fixups (DA findings)
.err().expect()→.expect_err()(commitcb3d989)assert_eq!line break (commitcb3d989)9fbc009)serialize_query_tagsbyte shape against Thrift's algorithm (commit9fbc009)Round 3 —
cargo fmt --allchore-fixupThis PR contains a small
chore(fmt): cargo fmt --allcommit (e5c53da) covering pre-existing rustfmt drift insrc/metadata/type_mapping.rsandsrc/reader/mod.rs. These files are NOT in F3's scope — they live on the F3 base branchmsrathore/krn-status-fieldsand the samecargo +stable fmt --all -- --checkfailure reproduces on its tip5265c75(verified via fresh clone). The standing policy bars pushing to existing stack branches, so the canonical fix lands here to clear the workspace-wide gate; rustfmt is convergent and idempotent so the eventual upstream merge will reconcile mechanically. Pure mechanical fmt; no semantic change.Post-fix gate status (workspace-wide, not the prior napi-scoped
-pflag which masked these failures):cargo +stable fmt --all -- --checkEXIT 0cargo clippy --all-targets -- -D warningsEXIT 0cargo test --lib37/37 passDeferred (separate PRs)
TypedValuemappingStatementSpec.row_limit/wait_timeoutfields (currently only on internalExecuteParams)submit()but napi needs newExecutedAsyncStatementwrapper classStack
PR 10 of the SEA stack, stacks on
msrathore/krn-max-connections(PR #74). Corresponding NodeJS side atmsrathore/sea-statement-options(PR #393).Downstream fixes / reviewer note
ExecuteOptionssurface (statementConf+queryTags) on the sync execute path.queryTimeout) and feat(sea): add gRPC transport #408 (rowLimit/ generalstatementConf).ExecuteOptionsobject forstatementConf+queryTags. The row-limit / query-timeout pieces reviewers may expect on the same object are added immediately downstream in kernel feat(statement,napi): surface row_limit + per-statement query timeout on StatementSpec #94, and positional/named parameter fields are handled separately in feat(napi): TypedValue codec for positional params #84/feat(napi): expose named query parameters (param_named) on ExecuteOptions #98.ExecuteOptionssurface later in feat(napi): async execute — submitStatement + AsyncStatement/AsyncResultHandle #76; please do not requestsubmitStatement/AsyncStatementon this base statement-options PR.Test plan
cargo buildpassescargo clippy --all-targets -- -D warningspasses — EXIT 0cargo +stable fmt --all -- --checkpasses — EXIT 0 (post round-3 chore-fmt)cargo test --lib— 37/37 pass (8 original F3 unit tests + 5 round-2 parity tests + 24 baseline)napi build --platformregeneratesindex.d.tswithExecuteOptionsinterface + updatedexecuteStatement(sql, options?)signaturetests/unit/sea/execution-query-tags.test.ts— 8 unit cases passingtests/e2e/sea/statement-options-e2e.test.ts) — 4/4 cases passing including escape-needing values + null/undef tagsDA round-2 status
Round-2 fixups force-pushed; original approvals dismissed by branch protection. Re-review pending DA verdict.