Skip to content

docs: document cursor fetch options per backend, with kernel tests - #1091

Open
cathleeny wants to merge 4 commits into
mainfrom
cathleeny/ddf-max-rows-fetch-size-python
Open

cathleeny wants to merge 4 commits into
mainfrom
cathleeny/ddf-max-rows-fetch-size-python

Conversation

@cathleeny

@cathleeny cathleeny commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

On kernel connections (use_kernel=True), the cursor's fetch-size options behave differently from Thrift, and that
wasn't documented. This PR documents arraysize, buffer_size_bytes and row_limit for each backend and adds unit
tests that pin the kernel behavior. No runtime code changes.

What changes

  • CONNECTION_PARAMETERS.md: a new "Cursor fetch options" table.
    • arraysize: Thrift sends it to the server. The kernel picks its own batch sizes, and fetchmany(n) still
      returns exactly n rows.
    • buffer_size_bytes: Thrift only; ignored on the kernel.
    • row_limit: works on both.
    • fetchmany(size) needs an explicit size on both backends.
  • tests/unit/test_kernel_fetch_size.py: exact fetchmany sizes across kernel batches, arraysize and
    buffer_size_bytes not forwarded, and row_limit passed to the kernel.
  • One changelog line.

Testing

Live, connector from this branch with databricks-sql-kernel 1.5.0:

Case Kernel, DBSQL Kernel, Reyden Thrift, DBSQL
range(100000), arraysize=1000: fetchmany(1000) returns 100 × 1000 rows ✅ ✅ ✅
range(100000), default arraysize: all rows ✅ ✅ n/a
2M-row wide result, fetchmany(10000): 200 × 10000 rows, over CloudFetch ✅ ✅ ✅
row_limit=500: 500 rows ✅ ✅ ✅

On the kernel, batch sizes (4096 rows on DBSQL, 781 on Reyden) are the same whatever arraysize is.

Unit: tests/unit (1453 passed), the real-kernel tests, black and mypy pass.

Not run: Thrift on Reyden (Reyden doesn't support Thrift); other Python versions (CI).

Dependencies

None.

This pull request and its description were written by Isaac.

Document arraysize, buffer_size_bytes and row_limit for Thrift and Kernel.
Clarify that fetchmany(size) requires an explicit size and that kernel
fetches slice server-selected batches without forwarding fetch knobs.

Add hermetic coverage for exact fetchmany slices across kernel batches,
inert arraysize/buffer_size_bytes and row_limit forwarding.

Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
Co-authored-by: Isaac <no-reply@databricks.com>
@cathleeny
cathleeny marked this pull request as ready for review December 3, 2026 23:04

@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, with 1 low concern. The documented defaults (100000 and 104857600) and the kernel behavior (set_row_limit is forwarded, arraysize/max_bytes are ignored) match the source. The only issue is test isolation: the duplicated fake-kernel stub makes test results depend on the order test files are imported.

Comment thread tests/unit/test_kernel_fetch_size.py Resolved
test_kernel_fetch_size.py installed its own databricks_sql_kernel stub
with a separate KernelError class. When that file was imported before
test_kernel_client.py, client.py bound the wrong class and two client
tests failed. Reuse test_kernel_client.py's stub and assert both files
see the same KernelError.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.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.

cathleeny and others added 2 commits December 4, 2026 01:32
Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.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 Nit

Looks good, no blocking issues. The docs match the code: defaults are 100000 and 104857600, the kernel always calls set_row_limit, and fetchmany takes an explicit size on both backends. The test_downloader.py changes (time-mock fix and black reformatting) are not mentioned in the PR description.

Other findings

  • ⚪ Nit — Test comments say arraysize is "honored client-side" or "only slices client-side", but on the kernel it is only stored on the result set, and the explicit fetchmany(size) does the slicing. Reword the comments to match the code and the new docs. (Found by Claude Opus 5.5 · confirmed by the judge)

This branch was previously deployed

1 inactive deployment
azure-prod — f5049ad7 Deployed Dec 4, 2026 by cathleeny via review #921
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant