Repository navigation
Conversation
`dbSendQueryArrow()`, `dbGetQueryArrow()` and `dbReadTableArrow()` take a `schema` that fixes the Arrow types of some or all result columns before the first row is read: a struct nanoarrow schema, an arrow Schema, or a named list of column types, matched to the result columns by name, exactly. A requested type is used without looking at the values, so it does not depend on the chunk size or on NULL rows, and it is kept when the query is executed again with `dbBind()`. The column builder fills every integer, floating point, text, binary, date, time and timestamp type of Arrow, with a range check for the narrow integer types. Values of another storage class follow one set of rules for requested and decided types alike: integers into floating point and text types and text into binary types are silent, text and blobs into numeric types and reals into integer types are converted with the warning, and a blob that is not valid UTF-8, a number out of range and an unparsable date or time become NULL. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01EpBkzNMeuMBGy4nxTafYH6
…nt-tesla-mja103-schema
|
Review of this PR at 4b49166, by a Claude Code reviewer with clean context that read the diff against Low1. 2. Nit. In Checked and found sound
Generated by Claude Code |
krlmlr
left a comment
There was a problem hiding this comment.
The findings of the clean-context review, placed on the code they concern; the summary comment above carries the full report and the checks that came out sound.
Generated by Claude Code
…nt-tesla-mja103-schema Brings in the reworked layers below, at 4a4e580. The column builder keeps the kinds, the unit and the time zone of this branch on top of the state of #800: the storage class read once per row by `read_row()`, the bytes read once by `fetch_bytes()`, the open typing of data frame fetches, `wide_ints`, and the `null_type` reason. `append_integer()`, `append_string()` and `append_binary()` read the current row's value like #800 does, and `fetch_bytes()` also serves `large_utf8` and `large_binary`. `set_type()` and `init_array()` become const members, since the time types take the column's unit and time zone. A requested type freezes its column from the start, so `reopen()`, `peek_value()` and `conform_chunk()` leave it alone. `DbResult::set_arrow_schema()` keeps its `is_active()` check, which #800 dropped from the reads of a stream. The generated dependency files are those of #800, regenerated through `src/Makevars.deps`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…e converts exactly This branch converts integers and reals into a text column and text into a blob column without a warning, the default path warns for them. Since #800, `?"sqlite-arrow"` says that both paths warn on the same fetches apart from truncated reals, and a test compares them on a blob column that receives text. The documentation now names these silent conversions as a second exception, and that test puts a number into the blob column, which both paths report. A new test pins the difference for text and blob columns. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
The method was registered for character names only, so an `Id()` reached DBI's default method, which drops `schema` with the rest of `...`. It is now registered for any name, quotes it with `dbQuoteIdentifier()` and rejects a name that does not quote to a single identifier, like DBI's default. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…ne step The first term of the old condition was always true for a matched name, so only the count of each name in the result decided. A requested name is now ambiguous if it is among the duplicated result names, with the same error. The tests add several ambiguous names, and a duplicated result name that is not requested. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
When a column without a requested type makes the schema fetch the first chunk, a later fetch with a smaller `chunk_size` copies its rows. The copy knew only the storage types of the decided types and failed with an internal error for `bool`, the narrow and unsigned integers, `float`, `large_utf8` and `large_binary`. It now copies the storage types of every type that can be requested. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
A requested `time32` failed the whole stream with "Can't append to Arrow array" for a value beyond 2^31 units, such as a number of seconds. A timestamp in nanoseconds outside the years 1677 to 2262 overflowed the cast to a 64-bit integer, which is undefined and wrapped in practice. Both are now `NULL` with the coercion warning and the `out_of_range` reason, like an integer outside the range of a narrow type. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
The review found that a value in a column of the null type was reported as converted, although it becomes `NULL`. Since #800 such values have the reason `null_type`, worded as "dropped by the null type, NA", and this holds for a null type requested with `schema` too. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…e fetches When every column has a requested type, the schema of a stream reads no rows, so the warning for the first chunk comes with its array. `?"sqlite-arrow"` said that the schema always fetches the first chunk, in the sections on result columns and on chunking. It also said that each data frame fetch through Arrow decides the types of its columns, while a column with a requested type keeps it, and nanoarrow converts it. The list of values that become `NULL` now includes those of a column of the null type. New tests pin the schema that reads no rows, and data frame fetches of one or several chunks that keep a requested null type and `int64`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…yte limits The byte limits of #795 keep the 32-bit offsets of `utf8` and `binary` from overflowing. The 64-bit offsets of the large types need no cut, so a requested `large_utf8` or `large_binary` column reads its bytes once per value but reports none for the limits. The test runs the limits test of #795 with each requested string and binary type. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…quested Since #800 the warning names a column's type when it is raised, from the kind of the column builder. Each value of another storage class into each requested type now checks that name. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
… no rows A data frame fetch through Arrow keeps a column as `integer64` once one of its integers has needed 64 bits, like the default path. The append of a value notes this for `int64` and a requested `uint64`, the look at the next row of a fetch of no rows noted it for `int64` only. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
|
Review of the fixes at 30592db (the merge of #800 in 9fa916c and the ten commits after it), by a Claude Code reviewer with clean context that read the PR description, the first review, the merge's combined diff and the ten commits, built the commit with The first review's findings
New findingsMedium1. A real or text value beyond 64 bits saturates in a requested 2. A number beyond 32 bits in a requested 3. The requested Low4. An error in evaluating the 5. Times and timestamps are scaled in double precision, so the edges of the nanosecond unit and exact large integers are off. Confirmed: 6. A requested 7. On the data frame path, a requested Checked and found sound
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
…ed integer type SQLite saturates a real or the integer at the start of a text at 64 bits, so `int64` took `1e30` as `2^63 - 1` and reported it as converted. `uint64` saturated the same way, and could not hold any value above `2^63 - 1`. A real is now truncated and checked against the range of the type before the cast, and a saturated text or blob is read again digit by digit. Values beyond the range become `NULL` with the `out_of_range` reason, and `uint64` takes reals and text up to `2^64 - 1`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
… beyond its range The parser shared with the default path reads a number in a date column with the 32-bit `sqlite3_column_int()`, so a requested `date32` or `date64` wrapped a number beyond 32 bits into a wrong date, without a warning. The Arrow column now reads the number itself, as a 64-bit integer or a truncated real, and leaves the shared parser alone. A count of days whose `date32` days or `date64` milliseconds don't fit the type becomes `NULL` with the `out_of_range` reason. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
Arrow's `time32` and `time64` hold a time of day, from 0 up to 24 hours excluded, and `ValidateFull()` rejects other values. The column checked only the range of the storage integer, so a negative number, 24 hours or more, text such as `'24:00:00'`, and `'23:59:59.6'` rounded to `time32[s]` gave arrays that Arrow rejects. A time outside the day now becomes `NULL` with the `out_of_range` reason, and rounding stops at the last tick of the day. The new test helper `arrow_validated()` checks arrays with `ValidateFull()` where arrow is installed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
Times and timestamps were scaled to their unit in double precision. A timestamp in nanoseconds was off by up to a few hundred nanoseconds for current dates, the edges of its range were wrong in both directions, and integers above `2^53` seconds lost their last digits. An integer is now scaled with a checked 64-bit multiplication, and text is parsed to whole microseconds and scaled or rounded in integers, with the parsers of `extended_types`. A real is still rounded in double precision, as documented. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…d read a real into `bool` as a real A finite double beyond the range of `float` became infinite without a warning, through a cast that C++ leaves undefined. It now becomes `NULL` with the `out_of_range` reason, while an infinite real stays infinite. A requested `bool` truncated a real to an integer first, so `0.5` became false; a real is now true unless it is zero, still reported as converted. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
A data frame fetch through Arrow keeps a column as `integer64` once one of its values has needed 64 bits, like the default path. Only values stored as integers were noted, so a requested `int64` or `uint64` column fell back to `integer` in the next fetch when the wide value was a real or text. Every value appended to such a column is now noted, also when a fetch of no rows looks at the next row. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…ypes of data frame fetches Since #800, a data frame fetch through Arrow holds decided times and timestamps as seconds, and starts a new binding from the types of the last one. The merge lets a requested type take precedence over both. A requested `time32` and `timestamp` give their unit, time zone and time of day in a data frame, and a requested `int32` holds for every binding where the default path would carry text over. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…quested Since #800, a data frame fetch through Arrow converts its arrays by their formats, which the merge extends with nanoarrow's prototypes for the formats of requested types. The test fetches every requestable type through `dbFetch()`, in one array and in arrays of two rows, and checks the R values. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…ke text itself Since #795, a stream also makes text that is not valid UTF-8 `NULL`, which the section on result columns says. The list of rules for requested types named only blobs. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
`nanoarrow::as_nanoarrow_array()` of a stream needs arrow, which is only suggested and missing from CI's smoke job. Five schema tests failed without it. They now take the array through the new helper `single_array()`, which collects the stream with nanoarrow alone. 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
…ata frame path With `extended_types = TRUE`, the default path reads a number in a `DATE` column as days in 32 bits and wraps a larger one into another date without a warning. Since b99d110 the Arrow path reads the number in full and makes a number of days beyond 32 bits `NA`, reported as out of range. `?"sqlite-arrow"` now lists this as the fourth difference of the data frame path and as an exception to the default path warning on the same fetches. Numbers in `TIME` and `TIMESTAMP` columns are seconds as doubles on both paths and show no such gap. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…mns with the default path The comparison of unparsable times through Arrow gains a `DATE` column and a row with numbers beyond 32 bits. Its days beyond 32 bits are wrapped silently on the default path and `NA` with one out-of-range warning per fetch through Arrow, over several fetch sequences. The `TIME` and `TIMESTAMP` columns hold the same numbers and stay identical on both paths. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…nt-tesla-mja103-schema 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. The documentation of the data frame path keeps the sentence on `dbColumnInfo()` and the four differences. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
Accepted limitationsTwo clean reviews of this pull request, at 4b49166 and 30592db, and both integration reviews of the stack (first integration review, its finding 2 fixed in 4293d3f and 91b31f7; second integration review, its parser finding fixed here in c5d9c5f) are addressed up to 10b65d2, which closes the review rounds for the stack. Every High and Medium finding is fixed; since the first integration review, a requested
Generated by Claude Code |
…th `schema` With `arrow = TRUE`, `dbColumnInfo()` names the types of a fetch of no rows, and knew only the formats of decided types. For a result sent with `schema`, it failed with "Internal error: unexpected Arrow format". `uint64` is now named like `int64`, and the other requested formats by the R type that the data frame fetch converts them to, named like the default path names it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
A data frame fetch through Arrow converts a `uint64` column to `integer64` like an `int64` one. nanoarrow wraps a value beyond `2^63 - 1` in that conversion, so `1e19` came back as `-8446744073709551616` and `2^64 - 1` as `-1`, without a warning and whatever `bigint` said. The data frame fetch now rebuilds the chunks of such a column as doubles once one of its values is beyond, and keeps it a double in the later fetches of the execution, like the data frame path widens an integer column for a real. No value is dropped, the double rounds it to 53 bits, and this covers the rows kept for a schema, whose storage classes an out-of-range warning could no longer name. The stream holds the exact values as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
… a schema can request With `arrow = TRUE`, `dbColumnInfo()` answers from the Arrow columns, and failed for requested formats until 9789588. The test requests every type, every time unit and timestamps with and without a time zone, and checks that `dbColumnInfo()` names the R types of `dbFetch(rs, n = 0)` and of the full fetch, like the default path names them. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…nt-tesla-mja103-schema Brings in the busy mark reset through `R_ExecWithCleanup()`, the checks of Arrow parameters, the 64-bit row counter and the UTF-16 text in binary columns, with the coercion warning of the layer below. `get_column_names()` and `set_arrow_schema()` run their bodies through `run_guarded()`, like the other guarded methods of `DbResult`, since `BusyScope` is gone. `fetch_bytes()` reads text as UTF-8 for the requested `large_utf8` too, and for text in any binary column, requested or not. The result columns section keeps the note that a `schema` fixes the types up front in the paragraph on `chunk_size`, which moved before the sentences on text. `src/cpp11.cpp` is regenerated with both new entry points. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
The merged test expected a coercion warning for the strings in a binary column, but this branch reads text into a binary type silently, as its bytes, as `?"sqlite-arrow"` lists it. The test keeps its check of the UTF-8 bytes on both paths. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…nt-tesla-mja103-schema Brings in the bytes of a blob in a `utf8` column kept as they are, also in a UTF-16 database. `fetch_bytes()` takes the new rule of the Arrow interface, which goes by the storage class: a blob is read as a blob, everything else as UTF-8 text, which covers the requested `large_utf8` and binary types as well. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…nt-tesla-mja103-schema 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. The test of the requested types with 32-bit offsets reads its streams through `fetch_with_bytes_limits()` instead of lowering the global limits, and keeps checking every array with `ValidateFull()` through `arrow_validated()`, as the `dbGetQueryArrow()` of these tests does. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…nt-tesla-mja103-schema 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 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
…nt-tesla-mja103-schema 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. `DbResult` keeps `set_arrow_schema()` next to the new parameters of `arrow_schema()` and `fetch_arrow()`. The column builders keep the per-type functions of this branch, where the merged change of the layers below, `std::isnan()` in the date and time branches, has no lines of its own. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
The builders of the requested date, time and timestamp types still used R's `ISNAN()`, which the column builders no longer call, as an Arrow stream may be read on a thread other than R's main thread. They now use `std::isnan()` like the rest of them. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…mn names `result_set_arrow_schema()` and `result_column_names()` are entry points on R's main thread that use a result, like `result_fetch()`, which now first destroys the results that Arrow streams let go of on other threads. They do so too, so that such a result does not keep its statement and read transaction open until another call. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…nt-tesla-mja103-schema Brings in the Arrow test fixtures moved into `helper-arrow.R`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
`query_formats()` and `expect_int64_bits()` move from the top of `test-arrow-schema.R` into `helper-arrow.R`, which `pkgload::load_all()` sources. The wrappers that checked every array with `arrow_validated()` masked `dbGetQueryArrow()`, `dbReadTableArrow()` and `dbFetchArrowChunk()` in that file. In the helper file they would mask them for every test file, so they move as `validated_dbGetQueryArrow()`, `validated_dbReadTableArrow()` and `validated_dbFetchArrowChunk()`, and the tests of `schema` call them by these names. Every `test_that()` block now runs on its own after `load_all()`. 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 #800 (base branch
claude/elegant-tesla-mja103-warnings), which is stacked on #796 and #795.dbSendQueryArrow(),dbGetQueryArrow()anddbReadTableArrow()gain aschemaargument that fixes the Arrow types of some or all result columns before the first row is read:schemais a structnanoarrow_schema, an arrowSchema, or a named list of column types. Entries are matched to the result columns by name, exactly: a name that is not in the result, a name the result carries twice, an unnamed entry, and a data frame (usenanoarrow::infer_nanoarrow_schema(), or the upcomingptype) are errors. The form ofschemais evaluated and checked before the query is sent, the names and types once it has been sent, so a statement with side effects has run when they fail; no result is left open either way.chunk_sizeor on NULL first rows, and its declared type andextended_typesplay no part. The other columns are typed as before. The request outlivesdbBind(), so a query executed several times keeps its types. When every column has a requested type,get_schema()no longer reads the first chunk, so the warning for the first chunk comes with its array.dbConnect(arrow = TRUE),dbFetch()of a result sent withschemakeeps the requested types: they take precedence over the seconds in which a data frame fetch holds decided times and timestamps, so a requested time or timestamp has its unit, time zone and time of day, and over the types carried over to a new binding afterdbBind(). Every requested format is converted to R by nanoarrow's prototypes,uint64likeint64.null,bool,int8toint64,uint8touint64,float,double,utf8,large_utf8,binary,large_binary,date32,date64,time32andtime64in any unit,timestampin any unit and time zone (read as UTC, labelled with the zone). Dictionary, decimal, nested and extension types are rejected with the column name. The large types never end a chunk at feat: Implement the DBI Arrow interface natively #795's byte limits, since their 64-bit offsets cannot overflow; the rows kept for a schema are split correctly for every requested type. A number in a date column is a count of days, truncated; in a time or timestamp column it is a count of seconds. Times and timestamps are rounded to the nearest tick of their unit, a time to the last tick of the day at most: exactly for integers and for text, which is read to the microsecond, and in double precision for reals. Every array the tests build passes arrow'sValidateFull()where arrow is installed.?"sqlite-arrow": integers into floating point and text types, reals into text types and text into binary types are silent; text and blobs into numeric types, reals into integer types (truncated) and intobool(true unless zero) are converted with the warning from feat: Report coerced values once per chunk ordbFetch(), with their rows #800; text or a blob that is not valid UTF-8 without NUL bytes becomesNULLin a stream (in a data frame, text ends at its first NUL, as on the default path), and a number outside the range of an integer type (including a real or text beyond 64 bits, which SQLite would saturate), a finite number beyondfloat, a date outside its type, a time outside a day (0 up to 24 hours excluded), a timestamp outside the range of its unit, an unparsable date or time, and any value in a null column becomeNULLwith the warning (invalid_utf8,out_of_range,null_type).uint64reads reals and text up to 2^64 − 1. Three tests of the layers below relied on these warnings and were updated: two of feat: Report coerced values once per chunk ordbFetch(), with their rows #800 on an integer-into-text warning, and the comparison of the data frame path with the default path, which now puts a number rather than text into a blob column. Unlike the default path, data frame fetches through Arrow don't warn for these exact conversions, as?"sqlite-arrow"now says.dbGetQueryArrow()anddbReadTableArrow()get explicit methods, since DBI's defaults would passschemaon todbFetchArrow()or drop it;dbReadTableArrow()takes any name thatdbQuoteIdentifier()takes, such as a string,SQL()orId().dbColumnInfo()is not touched; a new internalresult_column_names()reads the names from the prepared statement without stepping it.The
ptypecounterpart for data frames fetched withdbConnect(arrow = TRUE)follows in the next PR of the stack.Review
Two clean-context reviews: the first (2026-09-27) found one Low issue and two nits; the second confirmed those fixes and three bugs found on the way, and found three Medium issues (reals and text beyond 64 bits saturating in
int64/uint64, numbers beyond 32 bits wrapping into wrong dates,time32/time64arrays that Arrow rejects for values outside a day) and four Low ones. All are fixed. #800 is merged up to dc4776e; the remaining limitations will be listed in an "Accepted limitations" comment after a final clean review of the whole stack.Since the integration review: a requested
uint64makes a data frame column adoubleonce a value is beyond 2^63 - 1, instead of wrapping it to a negative number (bed2527; the stream keeps the exact value);dbColumnInfo()names, for every format a schema can request, the R type thatdbFetch()returns (9789588, 221b2f3); and a number of days beyond 32 bits in aDATEcolumn,NAwith a warning here and a wrapped date on the default path, is listed among the documented differences (4293d3f, 91b31f7).What remains is listed under Accepted limitations.
The test fixtures this pull request adds live in
tests/testthat/helper-arrow.R, so everytest_that()block runs on its own right afterload_all(). The wrappers that validate every Arrow result intest-arrow-schema.Rare namedvalidated_dbGetQueryArrow(),validated_dbReadTableArrow()andvalidated_dbFetchArrowChunk(), so that they do not mask DBI's functions in other test files.https://claude.ai/code/session_01EpBkzNMeuMBGy4nxTafYH6
Generated by Claude Code