Skip to content

feat(statement): support native parameter-set execution - #479

Merged
aakash-saravanan-db merged 13 commits into
mainfrom
aakash-saravanan_data/feat/native-parameter-batch-20261117
Nov 30, 2026
Merged

aakash-saravanan-db merged 13 commits into
mainfrom
aakash-saravanan_data/feat/native-parameter-batch-20261117

Conversation

@aakash-saravanan-db

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

Copy link
Copy Markdown
Collaborator

Feature or gap

Statements can snapshot ordered parameter sets and submit atomic parameterized INSERT batches in one request.

What this PR addresses

Adds StatementSpec::add_parameter_set and kernel_statement_add_parameter_set, sends parameter_sets separately from scalar parameters, and reports aggregate affected counts when available. SQL reset clears snapshots. Server limits propagate without client chunking.

Tests and validation

cargo test passes, including 1,110 unit tests and 56 execution wire tests, along with formatting and warnings-denied Clippy on all targets. Live aggregate counts, exact values and atomic failure pass on a DBSQL warehouse.

@aakash-saravanan-db
aakash-saravanan-db force-pushed the aakash-saravanan_data/feat/native-parameter-batch-20261117 branch from 56eb54f to 594171d Compare November 18, 2026 03:06
@aakash-saravanan-db aakash-saravanan-db changed the title Native parameter-set execution feat(statement): support native parameter-set execution Nov 18, 2026

@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 Terra), checked by a judge model (Claude Sonnet 5.5).

Verdict: 2 High · 2 Medium · 3 Low · 1 Nit

Looks solid. I found 1 medium and 2 low concerns. Serialization, the zero-based ordinals and the no-replay error handling are well covered by the wiremock tests. The remaining gaps are binding coverage and some edge cases in count decoding.

This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge and GPT-6.1 Terra added findings it doesn't mention — see the findings below.

Other findings

  • 🟠 High — Disputed by the cross-check judge (it quotes RequestType::ExecuteStatement,); a human should decide. Original finding: Batch execution still uses the ordinary execute retry policy, which resubmits the POST on 429 and 503 with Retry-After despite the promised no-replay guarantee. Disable HTTP-level retries for parameter-set submissions and test those responses with a one-request assertion. (Found by GPT-6.1 Terra · disputed by the judge)
  • 🟡 Medium — Async polling and reader-construction errors occur before this batch decoder and retain their original retryable flag, unlike synchronous batch errors, even though the write may already have committed. Apply the batch non-retryable classification to errors from status, await_result, and fetch_result as well. (Found by GPT-6.1 Terra · the judge couldn't confirm it)
  • 🟡 Medium — The new protocol and aggregate-count behavior is only covered by synthetic wiremock responses, so the manually verified warehouse behavior cannot be rerun as a repository regression test. Add an ignored live-warehouse test covering native batch values, atomic failures, and affected counts. (Found by GPT-6.1 Terra · the judge couldn't confirm it)
  • ⚪ Nit — The check batch.schema().fields() != schema.fields() compares nullability and field metadata, so a reader whose advertised (manifest or logical) schema differs only in nullability from the attachment batches would turn a committed batch into a DataLoss error. Compare only the names and data types of the count columns, or add a test where the manifest nullability differs. (Found by Claude Opus 5.5 · the judge couldn't confirm it)
🔀 1 finding considered and dismissed by the judge
  • 🟡 Medium src/statement/spec.rs:257 — Native parameter sets are exposed only through Rust and the C ABI; the napi, PyO3 and ADBC wrappers still have no way to snapshot a set, so ADBC bulk binds stil
    Judge's evidence: pub fn add_parameter_set(&mut self) -> &mut Self {

Comment thread src/statement/executed_async.rs Resolved
Comment thread src/types/sea.rs Resolved
Comment thread src/statement/executed_async.rs Resolved
Comment thread src/statement/dml_count.rs 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 Terra), checked by a judge model (Claude Sonnet 5.5).

Verdict: 2 High · 1 Medium · 1 Nit

Looks good: 1 medium and 1 low concern. Count decoding, the no-replay error paths, and the snapshot/reset semantics are careful and well covered by wiremock. The new wire behaviour has no live-warehouse test in the repo.

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

Other findings

  • 🟠 High — Disputed by the cross-check judge (it quotes let response = self.http_client.execute(request, request_type).await?;); a human should decide. Original finding: Batch POSTs still use the normal execute retry policy, so a 429, a 503 with Retry-After, or a configured retryable 500 resubmits the entire write despite the no-replay guarantee. Dispatch batch POSTs with retries disabled and test these responses through the HTTP client. (Found by GPT-6.1 Terra · disputed by the judge)
  • ⚪ Nit — add_parameter_set is exposed on StatementSpec and the C ABI only. The CHANGELOG mentions that scope but nothing says the napi and PyO3 wrappers lack it. State the difference explicitly in the docs, or wire it through the wrappers. (Found by Claude Opus 5.5 · confirmed by the judge)
  • 🟠 High — Disputed by the cross-check judge (it quotes error.retryable = false;); a human should decide. Original finding: After submit returns a batch handle, polling and result-materialization transport errors can still escape as retryable even though the write may have committed, inviting callers to submit it again. Apply the batch no-replay error policy to asynchronous status and result failures too. (Found by GPT-6.1 Terra · disputed by the judge)

Comment thread src/statement/mutable.rs Resolved
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>
@aakash-saravanan-db
aakash-saravanan-db force-pushed the aakash-saravanan_data/feat/native-parameter-batch-20261117 branch from 2aa0924 to fe6423e Compare November 24, 2026 20:04
@aakash-saravanan-db

Copy link
Copy Markdown
Collaborator Author

Rebased onto main. The current revision retains known statement IDs on batch failures and adds an owning-kernel live regression; the open inline findings have individual replies. The CHANGELOG explicitly scopes snapshots to Rust and the C ABI.

The HTTP retry finding does not apply to the reachable batch configuration. Session builds its own client in build_retry_configs_for_session; HttpConfig exposes retry budgets and attempt counts, but no override_retryable_codes setting. That field stays at RetryConfig::default() for statement execution, and Session exposes no custom transport/client injection. A configured-500 counterexample against the low-level HTTP client therefore cannot be constructed through StatementSpec batch execution. The existing non-idempotent policy allows safe 429/503-with-Retry-After admission retries and excludes ambiguous read/decode failures. The existing HTTP tests and batch one-POST failure tests cover these boundaries.

Async status and result operations use the existing statement ID. Retrying those reads does not resubmit an INSERT; their retry flags retain the same meaning as ordinary asynchronous execution. No retry-policy change is needed.

The test audit retained distinct compatibility, count, schema, failure, C ABI and driver-manager boundaries, while combining overlapping fixtures and removing redundant assertions. All 1,110 unit tests and 57 wire tests pass, along with clippy and the named live kernel regression.

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

✅ No issues identified.

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 Medium · 2 Low

Mostly solid, with one medium and two low concerns. The wire shape, binding reset and reporting of server limits look correct and are well tested. The main risk is how failures to read the batch's affected-row count are handled after the server has already committed the batch.

Comment thread src/statement/mutable.rs Resolved
Comment thread src/statement/spec.rs Resolved
Comment thread src/statement/dml_count.rs 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 Medium · 2 Low

Mostly solid, with 1 medium and 1 low concern. Wire shape, SQL reset and C ABI plumbing are well tested. The direct-execute path can return an error for a committed batch when reading the optional affected-row count fails.

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/statement/mutable.rs Resolved
Comment thread src/statement/mutable.rs Resolved
Comment thread src/statement/spec.rs Resolved
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 Low

Looks good overall, with 1 medium concern. Scalar and batch wire separation, zero-based ordinals, reset semantics and the C ABI entry point all look consistent and well tested. The one concern is that in the direct path a failed count read turns a successful batch into an error.

This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge and GPT-6.1 Sol added findings it doesn't mention — see the findings below.

🔀 1 finding considered and dismissed by the judge
  • 🟡 Medium src/statement/mutable.rs:684 — In the execute_direct Completed arm, the batch branch passes read_batch_affected_rows errors up with ?, while the scalar branch right below discards count
    Judge's evidence: error.retryable = false;

Comment thread src/statement/mutable.rs Resolved
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

Looks good — 1 low concern. The wire shape, SQL-reset semantics, non-retryable failure marking and aggregate counting are consistent across the sync, direct and async paths, with wiremock, C ABI and e2e coverage.

This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge and GPT-6.1 Sol added findings it doesn't mention — see the findings below.

🔀 1 finding considered and dismissed by the judge
  • 🔵 Low src/statement/spec.rs:282 — add_parameter_set is exposed through Rust and the C ABI, but neither the PyO3 nor the napi wrapper exposes it, so Python and Node hosts can't use native batch
    Judge's evidence: pub fn add_parameter_set(&mut self) -> &mut Self {

Comment thread src/statement/executed_async.rs Resolved
…ails

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

✅ No issues identified.

🔀 3 findings considered and dismissed by the judge
  • 🟡 Medium src/statement/mutable.rs:690 — In execute_direct, the batch branch reads the count with read_batch_affected_rows(...).await?. If that peek fails, a batch the server already committed come
    Judge's evidence: error.retryable = false;
  • 🔵 Low src/statement/mutable.rs:443 — When parameter sets are present, status.num_modified_rows is always replaced by the batch read, even when the server's status already carries a count. When th
    Judge's evidence: if parameter_set_count != 0 { status.num_modified_rows = crate::statement::dml_count::read_batch_affected_rows(
  • 🔵 Low src/statement/spec.rs:284 — add_parameter_set is exposed through Rust and the C ABI only. The PyO3 and napi wrappers get no equivalent and nothing documents the gap, so binding users can
    Judge's evidence: pub fn add_parameter_set(&mut self) -> &mut Self {

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 Low

Looks solid, with 1 medium and 1 low concern. The wire shape, ordinal rebasing, the SQL reset and marking failures non-retryable are all well tested across the sync, async, direct and C ABI paths. The main gap: in the direct path, a failed count read can turn a batch the server already committed into an error.

This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge and GPT-6.1 Sol added findings it doesn't mention — see the findings below.

🔀 2 findings considered and dismissed by the judge
  • 🔵 Low src/c_abi/statement.rs:210 — add_parameter_set is exposed through Rust and the C ABI, but the diff adds nothing to the PyO3 or napi wrappers, so Python and JS hosts can't submit native ba
    Judge's evidence: stmt.spec().add_parameter_set();
  • 🟡 Medium src/statement/mutable.rs:685 — In execute_direct's Completed arm, the batch branch propagates read_batch_affected_rows(...).await?, so a failure peeking the count batch fails the whole ca
    Judge's evidence: error.retryable = false;

Comment thread src/statement/mutable.rs Resolved
let pending = self.pending_result.lock().ok();
if let Ok(mut guard) = self.latest_status.lock() {
// Status polls never carry a batch's aggregate count; keep the one read from the result.
if self.parameter_set_count != 0 {

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.

For batch handles this always keeps the prior count, which is None until a result read sets it. So submit → poll status() to Succeeded → num_modified_rows() returns None (C ABI: -1), while a scalar INSERT on the same path returns the count. That contradicts the module contract at L39-45. Could status() decode the saved response with read_batch_affected_rows when the batch reaches Succeeded? Either way, a status-only test would pin it down; the current test calls await_result first.

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.

Good catch. Status polls derive scalar DML counts in the transport, but a batch result carries repeat and needs the handle's set count, so status-only polling never set it. Fixed in 8ae95dd: status() now reads the batch count from a successful terminal response, best-effort like the scalar path; result reads still report reader errors. native_batch_direct_and_async_use_aggregate_counts now checks the count after status() alone, before await_result().

status() now reads a succeeded batch's aggregate count from the polled
response, so status-only polling reports it as it does for scalar DML.
Read errors leave the count unknown; result reads still report them.

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

Mostly solid: 1 medium and 1 low concern. Wire shape, binding reset, retry suppression and count aggregation are well tested. However, async status polling can rebuild the result over and over when no batch count can be derived.

This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge and GPT-6.1 Sol added findings it doesn't mention — see the findings below.

🔀 1 finding considered and dismissed by the judge
  • 🔵 Low src/statement/spec.rs:283 — add_parameter_set is exposed in Rust and the C ABI only. napi already passes rawParams through to param_raw (napi/src/connection.rs:232), but it gets no b
    Judge's evidence: pub fn add_parameter_set(&mut self) -> &mut Self {

Comment thread src/statement/executed_async.rs Resolved
Comment thread src/statement/executed_async.rs Resolved
status() now reads a batch's count only when the polled response carries
its entire result inline. A CloudFetch or multi-chunk result no longer
triggers downloads during a status poll; the result read fills the count.
The count is recorded before the success status that reports it.

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

Mostly solid, with 1 medium and 2 low concerns. Wire shape, reset semantics and test coverage look good. The main risk is how errors are reported once a batch may already be committed.

This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge and GPT-6.1 Sol added findings it doesn't mention — see the findings below.

🔀 1 finding considered and dismissed by the judge
  • 🔵 Low src/statement/spec.rs:283 — add_parameter_set is exposed through Rust and the C ABI only. pyo3/src and napi/src have no parameter-set binding, so Python and Node callers can't use native
    Judge's evidence: pub fn add_parameter_set(&mut self) -> &mut Self {

Comment thread src/statement/mutable.rs Resolved
Comment thread src/statement/mutable.rs Resolved
Comment thread src/statement/executed_async.rs Resolved
A count-less saved response no longer clears the aggregate count that
status() read. Result reads record a batch count only when one is found.

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

Mostly solid: 1 medium and 2 low concerns. The wire shape, binding reset and no-replay behaviour are well tested. The concerns are how batch count-read failures are reported and how retryability is documented.

This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge — see the findings below.

🔀 1 finding considered and dismissed by the judge
  • 🔵 Low src/statement/dml_count.rs:113 — read_batch_affected_rows never checks that the result is a DML count (unlike manifest_is_dml_count). A batch whose result happens to have num_affected_rows<br>Judge's evidence: (represented == parameter_set_count).then_some(total)`

Comment thread src/statement/mutable.rs
if self.spec.parameter_sets.is_empty() {
return;
}
error.retryable = false;

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 — finish_failed_batch marks every batch error non-retryable, including pre-dispatch failures such as transient auth errors where no POST was sent. Track whether submission could have occurred and keep the original retryability for earlier failures.

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

Agreed that a token-endpoint timeout before the POST is retryable and never reached the server. Distinguishing it needs a never-sent signal on Error, which is a public, intentionally exhaustive struct, so that belongs in a separate API change. The only batch caller today, ODBC, doesn't read retryable, so this keeps the conservative override.

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 f8564d8: line 751 still forces retryable=false. A private submission flag set before the POST would avoid changing the public Error API.

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.

Agreed that a private flag avoids changing Error. This is broader than batches: no statement records whether its POST was sent. Scalar statements keep the transport's flag, so a POST that times out (504) surfaces as retryable even though an INSERT may have run, while batches force retryable = false. A send flag set inside the HTTP client's retry loop, where auth runs right before each send, would fix both, so I'll track it as a follow-up across statement types and keep the batch path conservative here.

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 f8564d8: mutable.rs:751 still forces retryable=false for pre-dispatch failures. Deferring it to a follow-up is reasonable, so this thread stays open to track it.

Comment thread src/statement/mutable.rs Resolved
execute_direct now handles a failed batch count read the way it handles
a scalar one: the count stays unknown and the error surfaces on fetch.

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

Mostly solid: the request shape, ordinal rebasing, reset semantics and non-retryable marking are well tested. I found 1 medium and 2 low issues: count-read failures are handled differently in the sync and direct paths, status() re-decodes the result on every terminal poll, and the napi and PyO3 bindings don't expose the new call.

This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge and GPT-6.1 Sol added findings it doesn't mention — see the findings below.

Other findings

  • 🟡 Medium — This unconditionally makes transient credential-acquisition failures non-retryable for batches, even when authentication failed before any statement POST, preventing safe recovery from temporary auth outages. Track whether submission may have occurred and preserve retryability for provably pre-send failures while keeping uncertain submissions and post-commit count failures non-retryable. (Found by GPT-6.1 Sol · the judge couldn't confirm it)
🔀 1 finding considered and dismissed by the judge
  • 🔵 Low src/statement/spec.rs:283 — add_parameter_set is exposed through the C ABI but not through the napi or PyO3 wrappers. napi already routes rawParams through param_raw at napi/src/conn
    Judge's evidence: pub fn add_parameter_set(&mut self) -> &mut Self {

Comment thread src/statement/executed_async.rs Resolved
Comment thread src/statement/mutable.rs Resolved

This branch was successfully deployed

1 active deployment
azure-prod — f8564d85 Deployed Nov 30, 2026 by aakash-saravanan-db via followup #4439
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.

2 participants