fix(python): correct cursor rowcount semantics - #792
Merged
Conversation
youngsofun
marked this pull request as draft
August 6, 2026 07:57
youngsofun
force-pushed
the
codex/fix-python-cursor-rowcount-semantics
branch
from
August 6, 2026 08:17
f9a0cbc to
30c1e87
Compare
youngsofun
force-pushed
the
codex/fix-python-cursor-rowcount-semantics
branch
from
August 6, 2026 08:33
30c1e87 to
3257903
Compare
youngsofun
marked this pull request as ready for review
August 6, 2026 08:56
youngsofun
added a commit
that referenced
this pull request
Aug 6, 2026
* fix(python): expose cursor write statistics * style(python): format README code examples * fix(python): correct cursor rowcount semantics (#792) * fix(core): move tests after implementations --------- Co-authored-by: Yang Xiufeng <yangxiufeng.c@gmail.com>
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
rowcountat-1for result-producing and unclassified statementswrite_rowsfor DML, including statements that affect zero rowsServerStatsMotivation
The target branch exposes
write_rowsascursor.rowcount, but that makes a non-emptySELECTreport0. It also misses successful statements whose final response has no schema, rows, or non-zero progress, leaving zero-row DML withstats is Noneandrowcount == -1.This follow-up keeps the write-statistics behavior for DML while making result-set row counts conform to PEP 249 and retaining zero-valued final statistics. SQL classification reuses the driver's existing parser result instead of parsing again in the Python binding.
Testing
cargo fmt --all -- --checkcargo test -p databend-client --libcargo test -p databend-driver --libcargo test -p databend-python --libcargo check -p databend-pythoncargo clippy -p databend-client -p databend-driver -p databend-python --lib -- -D warningscd bindings/python && uv run ruff format --check package/databend_driver/__init__.pyi tests/cursor/steps/binding.pymake integration-bindings-pythoncd bindings/python && QUERY_RESULT_FORMAT=arrow .venv/bin/python -m behave tests/cursor --name 'Insert and Select'git diff --checkCompatibility
For a result-producing statement,
cursor.rowcountremains-1. DML continues to report affected rows immediately from server statistics.Follow-up to #791.