Skip to content

chore: Decide where mixed data-frame and Arrow fetches on one result set get specified - #796

Closed
krlmlr wants to merge 1 commit into
mainfrom
claude/arrow-mixed-fetch-spec
Closed

krlmlr wants to merge 1 commit into
mainfrom
claude/arrow-mixed-fetch-spec

Conversation

@krlmlr

@krlmlr krlmlr commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

This PR has a single empty commit. It holds the investigation and the open question for #773: whether the behavior of mixing dbFetch() with dbFetchArrow() or dbFetchArrowChunk() on one result set belongs in the DBItest specification. Nothing here will be merged as code. The findings and the recommendation are in the question comment: #796 (comment)

Part of #773.


Generated by Claude Code

krlmlr commented Nov 29, 2026 •

Copy link
Copy Markdown
Member Author

Resolved: Where should the semantics of mixing data-frame and Arrow fetches (#773) be specified?

Situation. DBI's specification text is written only in DBItest's roxygen comments. DBI inherits it with @inherit/@inheritSection DBItest::spec_*, for example in R/dbFetchArrow.R, R/dbFetchArrowChunk.R and R/dbHasCompleted.R. vignettes/spec.md is then rebuilt from man/ by tests/testthat/helper-dev.R. So whatever the spec should say has to be written in DBItest first. DBItest 1.9.0 already requires dbFetch() with the default n to work on dbSendQueryArrow() results, in spec-meta-bind-runner.R and spec-arrow-send-query-arrow.R. It never alternates dbFetchArrowChunk() and dbFetch() on one result. It also says nothing about dbGetRowCount() or dbHasCompleted() after Arrow fetches. The typo reported in #773 ("only guaranteed to be set to FALSE") is still in spec-meta-has-completed.R in 1.9.0.

What the backends do. This was read from the released sources; none of this code was run.

  • DBI's defaults wrap a dbSendQuery() result and fetch each Arrow chunk with dbFetch(n = 256). Rows would therefore continue in order across both kinds of fetch, except that dbFetch() on an Arrow result refuses any n other than -1.
  • RSQLite 3.54.1 has no Arrow methods of its own.
  • adbi's dbFetchArrowChunk() advances the row count, so a later dbFetch() continues at the next row.
  • duckdb 2.0.1 marks a result as completed as soon as dbFetchArrow() hands over its stream. Its dbGetRowCount() on Arrow results always returns 0.

Options, with their cost.

  • (recommended) Specify in DBItest the mixes that work today, as spec text with tests, and let DBI re-inherit it. These are: Arrow chunks followed by dbFetch() with the default n, or the other way round, return every row exactly once and in order, and dbGetRowCount() and dbHasCompleted() count rows from both kinds of fetch. Every other mix, such as dbFetch(n = k) on Arrow results or Arrow fetches on dbSendQuery() results, is either implementation-defined or an error. Of the backends checked, only duckdb needs changes, to its row count and its early completion.
  • Require full mixing on Arrow results in DBItest, so that rows continue in order across every combination, and drop DBI's n = -1 guard. This is cheap for DBI's defaults and for adbi, but costly for duckdb, and column types can differ between the two kinds of fetch.
  • Fix the kind of fetch at the first fetch and make mixing an error. This is the cheapest to implement, but it contradicts DBItest's existing requirement that dbFetch() work on Arrow results.
  • Declare mixing unspecified, in DBI's documentation only. This costs nothing, but backends keep drifting apart.
  • A DBItest tweak that lets a backend declare whether it allows mixed Arrow and data-frame fetches: Add a tweak for allowing or disallowing mixed Arrow and data frame fetches DBItest#608

Proposed DBItest issue (not opened, waiting for your go): "Specify mixing of dbFetch() and dbFetchArrowChunk() on one result set (#773)". It would carry these items:

  • Spec text and a test: chunks followed by dbFetch(), and the reverse, return every row exactly once and in order.
  • dbGetRowCount() counts rows from both kinds of fetch.
  • dbHasCompleted() is TRUE once either kind of fetch has gone past the end.
  • The other mixes are implementation-defined, or an error.
  • Fix the spec_meta_has_completed typo.
  • Afterwards, DBI re-inherits the text, and follow-up issues go to the backends.

Not checked yet: whether such a DBItest issue already exists, and whether DBItest's main branch has moved past 1.9.0.

Who decides, and the default. Kirill decides. Until then, nothing is opened in DBItest, and #773 stays open.


Generated by Claude Code

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