Skip to content

fix(statement): populate affected-row counts on direct completion - #431

Merged
aakash-saravanan-db merged 1 commit into
mainfrom
aakash-saravanan-db/fix-direct-dml-rowcount
Nov 17, 2026
Merged

aakash-saravanan-db merged 1 commit into
mainfrom
aakash-saravanan-db/fix-direct-dml-rowcount

Conversation

@aakash-saravanan-db

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

Copy link
Copy Markdown
Collaborator

Feature or gap

When Node executes DML with runAsync: false and the initial response completes the statement, status().numModifiedRows is unset even though fetching returns the correct counter row. An UPDATE affecting two rows, for example, returns {num_affected_rows: 2} without a status count.

What this PR addresses

Reuse the existing non-consuming counter reader when direct execution completes without a status count. Preserve zero counts, server-provided counts, and the fetched counter row. If the optional count read fails, execution still returns its successful handle and fetching reports the read error.

The existing schema-based inference can still interpret a SELECT column named num_affected_rows as an affected-row count.

Dependencies

None.

Tests and validation

  • Focused regressions cover direct-completion counts, zero, server-count precedence, preserved rows, and read-error replay across async, nonblocking, and owned fetches.
  • Full Rust unit, integration, and doc-test suite: 1,313 passed, zero failed; 64 ignored.
  • All-target Clippy with warnings denied, formatting, and whitespace checks passed.
  • Built the release native library and verified that published Node 3.0.0 loaded it. All 36 live checks passed against a SQL warehouse, including 12 directly completed synchronous DML variants, zero counts, parameter binding, preserved counter rows, independent table-content checks, and Thrift/async controls.
  • Security Scan is blocked by six findings from three existing Quinn dependency advisories, matching the scan on the base main commit.

Five alternating measured runs per side after one warmup, using warm sessions and consuming results, met the ±10% parity threshold:

Sync DML Thrift median Kernel median Change
INSERT 645 ms 660 ms +2.4%
UPDATE 1,022 ms 1,046 ms +2.3%
DELETE 1,012 ms 989 ms −2.2%
MERGE 1,873 ms 1,960 ms +4.6%

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

Looks good: one low-severity concern. The fix calls the same non-consuming DML count reader and uses the same is_none() check as the synchronous execute path (mutable.rs:420-422), and the wiremock test covers SUCCEEDED and CLOSED responses, zero counts, multi-column counters, an existing status count, and a non-counter result. The one issue is how an error from the peek is propagated.

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

Verdict: 1 Low

Looks good overall: one low concern about how errors are handled. The change matches the existing sync execute() path, the SQL-classification check prevents treating a SELECT alias as a DML count, and both new wiremock tests also check that the counter row can still be fetched. A nit: no test covers the case where status.num_modified_rows is already set, which should skip inference.

Comment thread src/statement/mutable.rs Resolved
@aakash-saravanan-db
aakash-saravanan-db force-pushed the aakash-saravanan_data/fix-select-alias-rowcount branch from f62ad30 to 77288a1 Compare November 10, 2026 22:26
@aakash-saravanan-db
aakash-saravanan-db force-pushed the aakash-saravanan-db/fix-direct-dml-rowcount branch from 6806d66 to ccdfe80 Compare November 10, 2026 22:32

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

Looks good overall, with one low-severity telemetry-timing concern. The shared completed_statement helper, the buffering and replay of peek errors on all three read paths (next_batch, try_next_batch, OwnedBatchIter), and the separate error policies for execute() vs execute_direct() are consistent, and the wiremock and unit tests cover them well.

Comment thread src/result_stream.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.

✅ No issues identified by the review bot.

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

✅ No issues identified by the review bot.

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

✅ No issues identified by the review bot.

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

The change looks correct: ResultStream now buffers and replays the peek outcome (batch or error) consistently across next_batch, try_next_batch, into_owned_batches and Drop telemetry, and the shared completed_statement helper keeps each API's error contract. Wiremock tests cover the DML-count, SELECT-alias, server-count and both error policies, plus unit tests for replay. The only finding is a misleading debug log message on the status path.

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.

✅ No issues identified by the review bot.

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.

✅ No issues identified by the review bot.

This branch was previously deployed

1 inactive deployment
azure-prod — 0bfe0caf Deployed Nov 15, 2026 by aakash-saravanan-db via PyO3 build + test (Python 3.13) #798
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-coverage Skip the coverage fan-out for this PR (no tracking issue opened in databricks-driver-test)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants