Repository navigation
Conversation
`dbSendQuery()`, `dbGetQuery()` and `dbReadTable()` gain a `ptype` argument for connections opened with `arrow = TRUE`: a data frame, or a named list of vectors whose values are ignored, matched to the result columns by name, exactly. Each named column is requested from SQLite as the Arrow type that nanoarrow infers for the prototype and converted back to the prototype's type, so its type depends neither on the values, nor on the chunk size, nor on `bigint`. Factors are read as text and converted to their levels, `hms` columns are requested as `time64`, and `POSIXlt` stands for `POSIXct`. The other columns are converted as before. The prototype is validated when the query is sent, with no result left open on an error, and it outlives `dbBind()`. The error messages of the shared schema request name the argument they check. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01EpBkzNMeuMBGy4nxTafYH6
…-tesla-mja103-ptype
|
Review of this PR at 90a302d, by a Claude Code reviewer with clean context that read the diff against Checked and found sound: the prototype is validated and turned into an Arrow schema before Generated by Claude Code |
…-tesla-mja103-ptype Data frame fetches through Arrow now go through `result_fetch_arrow_df()`, which types each fetch like the default path and reports which columns needed 64-bit integers. `arrow_fetch_df()` reads the prototype from the result and passes it to `arrow_to_df()`, which converts the stream with the prototype's types. `arrow_df_int64()` takes both `wide_ints` and the columns to keep, so that a column with a prototype is neither narrowed to `integer` nor touched by `bigint`. The documentation of `ptype` moves next to the new rules for typing data frame fetches. The dependency files of #801 replace the ones with system headers that the auto-update had committed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…oss fetches The columns without a prototype are compared with the default path over sequences of `dbFetch(n)` that start with a NULL row, including `n = 0`. The columns with a prototype keep their types in each fetch, in the rows kept for a schema, and in empty fetches. An `integer64` prototype stays `integer64` for every `bigint` setting, whether the values fit an `integer` or not. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…lues A factor prototype without levels takes the levels found in the values of each fetch, and an ordered one lost its class on the way. The documentation now says that values outside the levels of a prototype become `NA`, as with `factor()`. The tests cover logical prototypes and factors with and without levels, ordered or not, across fetches. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…nverted back A prototype that nanoarrow finds no Arrow type for, such as a complex vector or `NULL`, failed with nanoarrow's message, which does not say which column it was. A prototype that nanoarrow infers a type for but can't convert back to, such as an `AsIs` vector, failed only in `dbFetch()`, after the rows were read. Both are now errors that name the column, raised before the query is sent, so that an open result is left alone. The documentation lists these errors and says that a `POSIXlt` prototype stands for `POSIXct`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…-tesla-mja103-ptype `arrow_to_df()` now converts the list that `result_fetch_arrow_df()` returns, with the formats, names and arrays of a fetch. It takes the prototype as its third argument, puts its columns into the conversion target by position, and turns the factors without levels into factors after the conversion. The columns of the prototype stay out of the narrowing of 64-bit integers and out of `bigint`, which `arrow_df_int64()` used to do and `arrow_to_df()` now does itself. The coercion warning stays where #801 raises it, after the conversion in `arrow_fetch_df()`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…path A `ptype` entry for `hms` or `POSIXct` requested `time64[us]` or `timestamp[us]`, which a data frame fetch built in microseconds and limited to a time of day. Such entries now mark their requested type with `seconds`, which `result_set_arrow_schema()` passes to the column: the type stays fixed, but a data frame fetch stores the values as doubles in seconds, like a time or timestamp decided from `extended_types`. `arrow_to_df()` then gives these columns the attributes of the prototype, its class and time zone. Times outside a day and fractions below a microsecond now come back as on the default path, also without declared types, across chunked fetches and across arrays. An Arrow stream of such a result still has `time64[us]` and `timestamp[us]` in the prototype's time zone. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
Measured on top of #802, converting every fetch of several arrays column by column took as long as the conversion of the layers below and peaked higher: 11 MB more for all five columns of five million rows and 89 MB more for the two text columns. `nanoarrow::convert_array_stream()` keeps each array until the next garbage collection, where the layers below release it as soon as it is copied. A fetch without a lazy column now takes the path of the layers below unchanged. Only a fetch with a column that stays a view splits its arrays by column, in `arrow_lazy_to_df()`, so that the view holds the strings of its own column alone. The data frames section of `?sqlite-arrow` describes the eager path as before and the split for lazy strings. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
The benchmark ran again on #802's head, on the merge that converted every fetch of several arrays column by column, and on the commit that keeps that conversion for lazy strings only. The harness now reads the peak RSS before `object.size()`, which allocates a hash table for the strings of a column and materializes a lazy one: it added up to 170 MB to the peaks of the cells with text. The README replaces the claim that the column-by-column conversion made the eager path faster and leaner, which no longer holds on the reworked layers, and updates the numbers for `lazy_strings`. A full fetch of five million rows takes 3.6 s with lazy strings, 9.4 s eager and 16.4 s on the default path. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…tesla-mja103-lazy #802 now carries the final layers below it: a data frame fetch hands R a list of struct arrays with their formats, the columns of times in seconds, and the coercion warning, which `arrow_fetch_df()` raises after the conversion. `arrow_to_df()` takes `lazy_strings` from the connection as a fourth argument and marks the text columns without a prototype or with a plain `character()` one; factors without levels stay out, since they are built from copies. A fetch with such a column and at least one array converts its columns in `arrow_lazy_columns()`, which replaces only the conversion step: factors, times in seconds, the prototypes' attributes, the narrowing of integers and `bigint` follow as for the other fetches. `arrow_split_columns()` now splits the list of arrays instead of a stream. Eager fetches and fetches of no rows take the path of the layers below unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
`ptype` reaches `dbSendQuery()` through the dots of `dbSendQueryArrow()`, which stored it on the result before the `schema` replaced its types. `dbFetch()` then converted the columns of the schema to the prototype, and failed or gave the wrong type. The combination is now an error raised before the query is sent, also for `dbGetQueryArrow()`, and the documentation of `ptype` says so. Each argument alone works as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…-tesla-mja103-ptype Brings in `dbColumnInfo()` answered from the Arrow columns, `POSIXlt` written like `POSIXct`, the CI hook for the large Arrow test, and the comparison helper that can ask `dbColumnInfo()` before each fetch. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
Superseded: Accepted limitationsSuperseded by this comment. One clean review of this pull request, at 90a302d, had no findings of its own, and the problems found while checking the description against the merged layers below are fixed up to 04fa3fc (b13570d, 844b42f, 04fa3fc). The integration review of the whole stack at 071560ec found two issues in this layer:
Generated by Claude Code |
…fo()` With `arrow = TRUE`, `dbColumnInfo()` named every column after its Arrow format, as the default path names its types. For a column of `ptype` that was wrong or failed: an `integer` prototype, requested as `int32`, failed with an internal error, a factor was named `character`, and an `integer64` was named `integer`. These columns are now named after their prototype, as `dbFetch()` returns them: the class of an object such as a factor, a `Date` or an `integer64`, and the storage type of the others. The columns without a prototype are named as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…-tesla-mja103-ptype Brings in the busy mark reset through `R_ExecWithCleanup()`, the checks of Arrow parameters, the 64-bit row counter, the UTF-16 text in binary columns, and `dbColumnInfo()` for the formats requested with `schema`. `set_arrow_schema()` runs through `run_guarded()` and passes the seconds of `ptype` on. `arrow_column_info()` names the columns of `ptype` after their prototype with `arrow_type_name()`, and the other columns of a requested format with `arrow_column_type_name()`, so both helpers stay. `src/cpp11.cpp` is regenerated. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…-tesla-mja103-ptype Brings in the bytes of a blob in a `utf8` column kept as they are, also in a UTF-16 database. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…-tesla-mja103-ptype Brings in the state of the Arrow test hooks kept in each result, with the helpers `set_bytes_limits()` and `fetch_with_bytes_limits()` in `helper-arrow.R`. `src/cpp11.cpp` is regenerated. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…-tesla-mja103-ptype Brings in Arrow streams read safely on worker threads, with the "Threads" section of `?"sqlite-arrow"`, the coercion warning reported as the stream's error off R's main thread, the scanner tests, the memory cleanup of the large tests with `helper-memory.R`, and the longjmp tests. The requested R types add no R call to the stream callbacks. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…-tesla-mja103-ptype Brings in the atomic busy mark that records the thread holding a result, the atomic row count and completion, the parked results closed from the main-thread entry points, NaN tested without R, and the tests that read streams on a thread of their own. `result_set_arrow_schema()` drops the parked results before it passes the seconds of `ptype` on. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
Accepted limitationsOne clean review of this pull request, at 90a302d, the problems found while checking the description against the merged layers below, and both integration reviews of the stack (first integration review: finding 6 fixed in 9f385a3, the
Generated by Claude Code |
…-tesla-mja103-ptype Brings in the Arrow test fixtures moved into `helper-arrow.R`, with the wrappers of the tests of `schema` renamed to `validated_dbGetQueryArrow()`, `validated_dbReadTableArrow()` and `validated_dbFetchArrowChunk()`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
|
Marked as a draft, as decided: this pull request is the reference for the reworked Arrow stack, which carries its changes in smaller, separately reviewed pull requests (see the plan). So far: #855, #856, #857, #859 to #867 (GitHub stack 851 on #830 and #850), and #852, #853, #854 and #858 from Generated by Claude Code |
|
Closed as superseded, as decided: the Arrow work is rebuilt from Generated by Claude Code |
Stacked on #801 (base branch
claude/elegant-tesla-mja103-schema), which is stacked on #800, #796 and #795.dbSendQuery(),dbGetQuery()anddbReadTable()gain aptypeargument for connections opened witharrow = TRUE, the data frame counterpart of theschemaargument of #801:ptypeis a data frame or a named list of vectors whose values are ignored, so a zero-row data frame and a list of zero-length vectors describe the same thing. Entries are matched to the result columns by name, exactly: a name not in the result, one the result carries twice, an unnamed entry, a duplicate name, a data frame column, a raw vector (the message points toblob::blob()), and a nanoarrow schema (the message points to lists and data frames) are errors raised when the query is sent, with no result left open. Withoutarrow = TRUEthe argument is an error too.nanoarrow::infer_nanoarrow_schema()gives for the prototype, through the machinery of feat: Request Arrow types for result columns withschema#801, and converted back to the prototype's type:integerasint32(values outside the range becomeNAwith the warning of feat: Report coerced values once per chunk ordbFetch(), with their rows #800),integer64asint64and it stays aninteger64whatever the values and whateverbigintsays,logicalasbool,Dateasdate32,blobasbinary.POSIXct(andPOSIXlt) andhmsare requested astimestamp[us]in the prototype's time zone andtime64[us], which fixes their type, but data frame fetches read them like the times and timestamps decided fromextended_types: as doubles in seconds with the default path's precision and range (fractions below a microsecond, times outside a day), whatever the declared type, with the prototype's class and time zone (the session's for an empty one); an Arrow stream of the result has them in microseconds. A factor is read as text and converted to its levels, values outside them becomingNAas withfactor(), or to the levels found in the values of each fetch when it has none; an ordered factor stays ordered. A prototype nanoarrow finds no Arrow type for (a complex vector,NULL), one of a type RSQLite cannot fill (difftime, which nanoarrow maps toduration), and one nanoarrow cannot convert back to (anAsIsvector, a list) are rejected with the column name before the query is sent, so that an open result is left alone.arrowargument todbConnect()to route data frames through Arrow #796), andbigintapplies only to them. The prototype is stored on the result, so it holds across chunked fetches includingn = 0, acrossdbBind()anddbBindArrow(), for empty results, and for the rows kept when an Arrow schema was requested first.schemaorptype), andresult_set_arrow_schema()takes a logicalsecondsper requested column for the times and timestamps that data frame fetches store in seconds.Tests in
test-arrow-ptype.Rcover the type table, data frame and list prototypes, matching, validation, chunking, binding, empty results, rows kept for a schema, coercion,bigint, factors anddbReadTable(), compare the columns without a prototype with the default path over sequences ofdbFetch(n), and comparePOSIXctandhmsprototypes with the default path for fractions below a microsecond and times beyond a day. The Arrow tests (with and without the arrow package), DBItest and DBItest-arrow pass on the branch.Review
A clean-context review (2026-09-27) had no findings of its own; it noted that finding 1 of the review on #796 (a small first fetch fixing NULL-first columns) applied to
ptypefetches too, which holds after merging the reworked layers below and is tested. Problems found while checking every promise above against the merged code are fixed (an ordered prototype without levels came back unordered; prototypes that cannot be requested or converted back failed late or without naming the column;POSIXctandhmsprototypes lost precision below a microsecond and times outside a day). #801 is merged up to 4614fa2; the remaining limitations will be listed in an "Accepted limitations" comment after a final clean review of the whole stack.Since the integration review:
dbSendQueryArrow()anddbGetQueryArrow()refuseptypetogether withschema(9f385a3), and witharrow = TRUE,dbColumnInfo()reports the class each prototype produces, asdbFetch(rs, n = 0)does (96cc328); abloborinteger64prototype is named by its class, while the same types without a prototype keep the default path's names (list,double).What remains is listed under Accepted limitations.
https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
Generated by Claude Code