Skip to content

feat: Report coerced values once per chunk or dbFetch(), with their rows - #800

Closed
krlmlr wants to merge 34 commits into
claude/elegant-tesla-mja103-arrow-optionfrom
claude/elegant-tesla-mja103-warnings
Closed

krlmlr wants to merge 34 commits into
claude/elegant-tesla-mja103-arrow-optionfrom
claude/elegant-tesla-mja103-warnings

Conversation

@krlmlr

@krlmlr krlmlr commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Stacked on #796 (base branch claude/elegant-tesla-mja103-arrow-option), which is stacked on #795. Applies to the native Arrow path, and through #796 to data frames fetched with dbConnect(arrow = TRUE).

Values that are not of their column's Arrow type were reported with one warning per column, raised in the middle of reading a row and naming only the first offending storage class. They are now logged per column with their 1-based row numbers in the result, and reported by one warning that lists every affected column: once per chunk for an Arrow stream and dbFetchArrowChunk(), and once per dbFetch() for a data frame through Arrow, after its arrays have been conformed to the final types (a column logged as int64 that became double later in the fetch is named double). The dbFetch() warning is raised from R once the data frame is built, outside #795's busy guard, so a handler can use the result; the warning of a chunk or schema request is raised inside the fetch, where a handler that uses that result gets #795's error.

Warning message:
Mixed types in 2 columns, values converted to the column types:
• Column `x` (double): 1 string value converted (row 3)
• Column `y` (utf8): 1 integer value converted (row 3); 1 blob value not valid UTF-8, NA (row 4)
  • The warning has class RSQLite_warning_coercion and carries the structured details in its coercions field (column, type, and per storage class and reason the count and rows), so consumer packages and tests can inspect it without parsing the message.
  • Long row lists are truncated the way cli does it: the first rows, an ellipsis, and the last two, for example rows 2, 3, …, 19, …, 30, and 31. The C++ log keeps only the first 20 and the last 2 row numbers per column and reason, so memory stays bounded, also across the arrays of a data frame fetch. Row numbers are printed in full (row 100000, not 1e+05); the coercions field keeps them numeric; they restart with each execution after dbBind().
  • cli is used when it is installed, checked once per session: rlang formats the bullets through cli (local_use_cli(format = TRUE, inline = FALSE), so column names with braces are safe), and cli::ansi_collapse() joins the rows. Without cli, rlang's own bullets and a plain join give the same text. cli was already in Suggests, so no new dependency.
  • The date, time and timestamp parsers no longer raise one warning per value: failures are dropped to NULL and listed in the same warning with reason unparsable. The default data frame path keeps its per-value warnings, untouched.
  • The values that feat: Implement the DBI Arrow interface natively #795 makes NULL (times outside a day, times and timestamps beyond the int64 microseconds, text that is not valid UTF-8 without NUL bytes) are logged too, with reasons out_of_range and invalid_utf8, instead of one warning per column.
  • Text and blobs in a utf8 column that are not valid UTF-8 without NUL bytes become NULL (since feat: Implement the DBI Arrow interface natively #795) and are logged with reason invalid_utf8; on the data frame path text is cut at its first NUL and not checked, as on the default path, while blobs are checked as in a stream. This is the Arrow-path counterpart of fix: Validate blobs that are read into a text column #799, sharing the same src/utf8.h validator; with fix: Validate blobs that are read into a text column #799 merged, both data frame paths return the same values.
  • Values in a column of the null type (a first chunk of only NULL without a declared type, in a stream or in data frame fetches after a stream or chunk fixed the types) are dropped and listed with reason null_type, "dropped by the null type, NA".
  • For a lazy stream the warning surfaces when the chunk is fetched from the result: when the array is requested, or for the first chunk when the schema is requested before it. Documented in ?"sqlite-arrow", together with how the data frame path differs from the default path, which warns on the same fetches but once per column.
  • A coercion warning that an exiting handler or options(warn = 2) turns into an exit leaves the result usable: a data frame fetch through Arrow reopens its columns before warning, and the schema request of a stream keeps the first chunk before warning, so a retry returns the schema and every row.
  • Each fetch starts with an empty coercion log, so values logged by a fetch that failed (an error of the statement or an interrupt) are not reported by the next one.
  • On the data frame path, a string or blob converted to an integer that needs 64 bits keeps the column integer64 (following bigint) in later fetches too, as an integer of that size does; the default path truncates such a value to integer, which ?"sqlite-arrow" lists among the differences.
  • A fetch of no rows never warns through Arrow, since it returns no value; the default path warns there about the next row. Documented, and the comparison of both paths in test-arrow-df.R spells this exception out.
  • The Arrow test helpers, including feat: Add arrow argument to dbConnect() to route data frames through Arrow #796's, moved to tests/testthat/helper-arrow.R so the new test-arrow-coercion.R can use them. The comparison of both data frame paths in test-arrow-df.R now also checks that they warn on the same fetches.

Review

Two clean-context reviews: the first (2026-09-27) found two Low issues, the second confirmed those fixes and found two Medium issues (a warning that exits a fetch left a NULL-only column null-typed, and a warning that exits a stream's schema request lost the first chunk) and four Low ones; all are fixed or documented. #796 is merged up to cbac340; the remaining limitations will be listed in an "Accepted limitations" comment after a final clean review of the whole stack.

On a worker thread, where R can't be called (arrow's scanner, Acero, write_dataset()), the coercion warning becomes the error of the stream, with the warning's text as R shows it without cli followed by "(an error instead of a warning, …)", like the other warnings of #795 (c7327be); on R's main thread nothing changes.

What remains is listed under Accepted limitations.

https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE


Generated by Claude Code

krlmlr and others added 2 commits September 26, 2026 11:17
Values that are not of their column's Arrow type were reported with one
warning per column, raised while the row was read and naming only the first
offending storage class.
They are now logged per column while a chunk is built,
with their 1-based row numbers in the result,
and reported once per chunk by a single warning of class
`RSQLite_warning_coercion` that lists every column and the rows,
truncated like cli does it, and carries the details in its `coercions` field.
cli formats the bullets when it is installed, checked once per session,
rlang's own formatting is used otherwise.

The date, time and timestamp parsers now report failures the same way
instead of one warning per value,
and a blob in a text column is kept only if it is valid UTF-8 without
NUL bytes, otherwise it becomes NULL and is listed in the warning.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EpBkzNMeuMBGy4nxTafYH6
The build regenerates the stubs of sources that are newer than them
with absolute paths, and the development roxygen2 drops an import
that `import(DBI)` covers anyway.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EpBkzNMeuMBGy4nxTafYH6

krlmlr commented Sep 27, 2026

Copy link
Copy Markdown
Member Author

Review of this PR at 64a83c3, by a Claude Code reviewer with clean context that read the diff against claude/elegant-tesla-mja103-arrow-option, ran targeted R snippets against a build of the whole stack, and posted nothing itself. Line numbers refer to that commit.

Low

1. rlang::warn(..., call = NULL) in R/warn-coercion.R:37. warn() has no call formal (rlang 1.3.0), so the argument becomes a harmless field of the condition. Drop it, or pass it through rlang::warn(..., .frame = ) semantics if a call was meant to be suppressed.

2. Values that land in a null-typed column are logged with reason converted (src/SqliteArrowColumn.cpp:469-471 on the stack's head), so they appear under the header "values converted to the column types" although they are dropped to NULL. A reason of its own, or the out_of_range-style "NA" wording, would describe what happened. Together with finding 1 of the review on #796, that path is where a NULL-first chunk silently loses data.

Checked and found sound

  • warn_coercions() runs before chunk.move(out), so an unwind raised by the warning (with options(warn = 2) or an exiting handler) releases the chunk; verified by running both through as.data.frame(dbGetQueryArrow()) and through dbFetchArrowChunk(), and the session stays healthy afterwards.
  • One warning per fetched chunk, the coercions field carries the structured details, the row lists are bounded in C++, and the cli formatting is optional and checked once.
  • test-arrow-coercion.R passes on the build of the whole stack.

Generated by Claude Code

@krlmlr krlmlr left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one code-level finding of the clean-context review, placed where it applies; the summary comment above carries the rest.


Generated by Claude Code

Comment thread R/warn-coercion.R Resolved
…legant-tesla-mja103-warnings

The coercion log takes over #795's design of the current row:
the storage class comes from `read_row()` and the bytes of a text value from `fetch_bytes()`,
so the UTF-8 check of a blob in a text column reads the bytes that the byte limits counted.
`append_row()` keeps the 1-based row number as its only argument, computed after the byte check,
so a row held back to the next chunk is logged with its own number.
The `AK_INT64` branch logs where it warned, after reading the value once.
The Arrow test helpers of #796 move to `helper-arrow.R` with the others,
and the tests that matched the old warning text match its class or its new text.
The dependency files are regenerated through the fixed rule, without absolute paths.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
`rlang::warn()` has no `call` formal, so `call = NULL` became a field of the condition through `...`.
The condition has no call either way, the message and the snapshot are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
A data frame fetch through Arrow reads several arrays, one per 65,536 rows and one per byte cut of the strings and blobs.
Each array raised its own warning, naming the type the column had while it was built, `int64` for a column that became `double` later in the fetch.
The columns now keep their log across the arrays of a fetch,
and `fetch_arrow_df()` raises one warning after the arrays have been conformed to the final types.
An Arrow stream and `dbFetchArrowChunk()` keep one warning per chunk,
raised by `fetch_arrow()` and by `arrow_schema()` for the chunk kept for the schema, before the chunk is handed out or kept.
The default path raises one warning per column with mixed types on the same fetches,
which the comparison of both paths in `test-arrow-df.R` now checks instead of suppressing the warnings.
The documentation says when each warning is raised and how the paths differ.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
A column whose first chunk held only `NULL`, without a declared type, is of the null type for the rest of an Arrow stream,
and for the data frame fetches after a stream or `dbFetchArrowChunk()` has fixed the types.
Its values become `NULL`, but they were logged with the reason `converted`,
and listed as converted to the column type.
They now have the reason `null_type` and read "dropped by the null type, NA" in the warning.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
@krlmlr krlmlr changed the title feat: Report coerced values once per chunk, with their rows feat: Report coerced values once per chunk or dbFetch(), with their rows Nov 10, 2026

krlmlr commented Nov 10, 2026

Copy link
Copy Markdown
Member Author

Review of the fixes at 4a4e580 (the merge of #796 in 9a5cfc2 and the three commits after it), by a Claude Code reviewer with clean context that read the PR description, the first review, the combined diff of the merge and the three commits, ran test-arrow*.R and the DBItest files (all pass), ran targeted R snippets and a randomized comparison of both data frame paths on a build of that commit, reverted two fixes locally to see their tests fail, and posted nothing itself. Line numbers refer to that commit. "Confirmed" means reproduced by running code.

The first review's findings

  • rlang::warn(..., call = NULL): fixed: a5f157a drops the argument (R/warn-coercion.R:34-38); no test covers it, and none is needed.
  • Values in a null-typed column logged as converted: fixed: 4a4e580 logs them with reason null_type and the wording "dropped by the null type, NA" (src/SqliteArrowColumn.cpp:510-515, R/warn-coercion.R:57), confirmed for a stream, dbFetchArrowChunk() and a data frame fetch after a chunk; reverting the one line makes the new test fail (4 expectations). The header of the warning still reads "values converted to the column type" when every listed value was dropped, which is a wording remainder only.
  • The first review's "an unwind raised by the warning releases the chunk, the session stays healthy": holds for memory and for the session, but see new findings 1 and 2 for what the unwind leaves behind in the result.

New findings

Medium

1. A coercion warning that exits dbFetch() through Arrow leaves an all-NULL column fixed as the null type, and the next fetch drops its values. Confirmed. In fetch_arrow_df(), warn_coercions() (src/SqliteResultImpl.cpp:395) runs before the loop that calls reopen() (src/SqliteResultImpl.cpp:397-401), so when the warning unwinds (an exiting handler or options(warn = 2)), a column that decide_from_decltype() just set to the null type stays that way although nothing froze it. Reproduction with dbConnect(arrow = TRUE): CREATE TABLE t (x, y), rows (1,NULL),('a',NULL),(2,5),(3,'z'), tryCatch(dbFetch(rs, 2), warning = function(w) "caught"), then dbFetch(rs) returns y = NA, NA with "Column y (null): 1 integer value dropped by the null type, NA (row 3); 1 string value dropped ... (row 4)". The default path returns y = 5, 0 after the same sequence. Suggested fix: reopen the columns before warn_coercions(); an open column of the null type never has log entries, so the type named in the warning does not change. Tried locally: the reproduction then matches the default path and test-arrow*.R still pass. A test with an exiting handler on the first of two fetches would pin it.

2. A warning that exits the schema request of a stream silently loses the first chunk. Confirmed. arrow_schema() fetches the first chunk, warns, and only then keeps the chunk (src/SqliteResultImpl.cpp:241-247); the comment says the unwinding releases it. The rows are consumed from the statement by then and the columns are frozen (fetch_arrow_rows() freezes at src/SqliteResultImpl.cpp:634-636), so the next schema request succeeds without fetching, and the stream continues with the second chunk. Reproduction: table u (x) with 1, 'a', 2, 3, 4, stream <- dbFetchArrow(rs, chunk_size = 2), tryCatch(stream$get_schema(), warning = function(w) "caught") (or try() under options(warn = 2)), then as.data.frame(stream) returns 2, 3, 4 with no warning or error, and dbGetRowCount(rs) is 2 right after the failed schema request. A caller who asked for a schema, not for rows, has no reason to expect rows to be gone. Suggested fix: keep the chunk first, then warn after freeze_arrow_columns() at the end of the if (!arrow_frozen_) block; an error then leaves the chunk waiting and a retry returns the schema and all rows. Tried locally: the reproduction returns all five rows after the caught warning, and test-arrow*.R still pass.

Low

3. The data frame path does not warn on dbFetch(n = 0) where the default path does, against "The default path warns on the same fetches" (R/arrow.R:96). Confirmed. The default path peeks the next row for n = 0 and warns if its storage class differs from the column's type; the Arrow path only types the columns there (src/SqliteResultImpl.cpp:333-345) and logs nothing. Reproduction: CREATE TABLE t (a BLOB, b), rows (1,1),('1.7',2),(NULL,'12'), fetches n = 2, 0, 1: the default path warns on all three, the Arrow path on the first and third only. A randomized comparison (1500 tables of two columns, random fetch sequences, chunk_size default, 1 and 2) found this in roughly one case in ten when sequences contain zeros, and no disagreement on values or on which fetches warn once zeros and the documented case of a real number after a wide integer are left out. Suggested fix: document that a fetch of no rows never warns through Arrow (it returns no value, so this is arguably the better behaviour), and add such a sequence to the test with the exception spelled out.

4. Row numbers that are round multiples of 100000 print in scientific notation. Confirmed. The rows reach R as doubles (src/CoercionLog.cpp:46-49) and are pasted or passed to cli::ansi_collapse() as they are (R/warn-coercion.R:67-93). A query of 300000 rows with strings at rows 100000, 200000 and 300000 warns "3 string values converted (rows 1e+05, 2e+05, and 3e+05)". Suggested fix: format once in format_coercion_rows(), for example format(rows, scientific = FALSE, trim = TRUE), for rows and last; the coercions field can stay numeric.

5. The coercion log of a fetch that fails is reported by the next fetch. Confirmed. The log is cleared only by coercions() (src/SqliteArrowColumn.cpp:285-296); start_chunk() keeps it, as it must between the arrays of one data frame fetch. When step() throws or an interrupt arrives, the entries of the rows read so far stay. Reproduction: a failing dbFetchArrowChunk(rs, chunk_size = 10) ("integer overflow" in a later row), and the next dbFetchArrowChunk(rs, chunk_size = 2) warns "1 string value converted (row 2)" for a chunk that holds no string; the same through dbFetch() with arrow = TRUE. Suggested fix: discard the logs at the start of fetch_arrow(), of fetch_arrow_df() and of the fetch in arrow_schema(). Tried locally with a discarding call at the first two: the stray warning is gone and the tests pass.

6. A string too large for 32 bits in an integer column gives an integer64 column through Arrow and a truncated integer on the default path. Confirmed. SELECT 1 AS x UNION ALL SELECT '99999999999' UNION ALL SELECT '1.9' returns integer64 1, 99999999999, 1 with arrow = TRUE and int 1, 1215752191, 1 on the default path; both warn. The Arrow value is the better one, but it is a difference in values and in column type that the description of the data frame path does not list, and since note_integer() only sees values of storage class integer (src/SqliteArrowColumn.cpp:408-413), the next fetch of the same result goes back to integer. Suggested fix: list it among the documented differences, or call note_integer() for converted values too so the column stays integer64 for later fetches.

Checked and found sound

  • The merge's resolutions in src/SqliteArrowColumn.* and src/SqliteResultImpl.*: the storage class logged is the one read_row() read before any conversion, the UTF-8 check reads the bytes that fetch_bytes() counted, and the row number is computed after the byte check. Confirmed with arrow_set_bytes_limits(8, 10): chunks cut by either limit and rows held back to the next chunk are logged once, in the chunk that holds them, with their own row numbers, for dbFetchArrowChunk(), a stream with the schema requested first, and data frame fetches of several sizes.
  • One warning per chunk for a stream and dbFetchArrowChunk(); the first chunk warns once, at the schema request when that comes first, and not again when the kept chunk is handed out. One warning per dbFetch() through Arrow across several arrays, naming the type after the conform step. Reverting the source changes of 49d98a4 makes two tests fail (5 and 8 failures).
  • invalid_utf8: blobs with NUL bytes or invalid sequences become NA and are listed, an empty blob and a valid one are kept and listed as converted. With arrow = TRUE the values differ from the default path for such blobs until fix: Validate blobs that are read into a text column #799 is merged, as the description says.
  • Dates, times and timestamps with extended_types = TRUE: same values on both data frame paths, one warning through Arrow where the default path gives one per value.
  • options(warn = 2) and exiting handlers: no crash or leak signs through dbFetchArrowChunk(), as.data.frame(stream), dbGetQuery() and dbFetch() with arrow = TRUE, arrow::as_arrow_table(), and dbAppendTableArrow() reading one of the package's own streams; the connection works afterwards. A new dbBind() starts with an empty log and row numbers that count from 1.
  • The row lists stay bounded, and the truncated message is right at 20, 21, 22 and 23 values.
  • test-arrow.R, test-arrow-coercion.R, test-arrow-df.R, test-DBItest.R and test-DBItest-arrow.R pass on the build of 4a4e580.

Generated by Claude Code

…s warning

The warning of a data frame fetch through Arrow came before `reopen()`.
A warning that exits the fetch, through an exiting handler or `options(warn = 2)`,
left a column that had seen only `NULL` fixed as the null type,
and the next fetch dropped its values where the default path types them.
The warning now comes last, after the columns are reopened.
A reopened column held no values, so the types named in the warning are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
The schema request of an Arrow stream fetched the first chunk, warned about its values, and only then kept it.
A warning that exits the request had consumed the rows and frozen the types,
so a retry returned the schema and the stream went on with the second chunk.
The chunk is now kept and the types frozen before the warning,
so a retry returns the schema and every row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
The columns keep their coercion log across the arrays of a data frame fetch, until the warning reports it.
A fetch that failed, by an error of the statement or an interrupt, left the values it had logged,
and the next fetch reported them with rows it did not return.
`fetch_arrow()`, `fetch_arrow_df()` and the fetch for a schema in `arrow_schema()` now start with an empty log.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
The row numbers reach R as doubles, and pasting them printed 100000 as `1e+05`.
`format_coercion_rows()` now formats the first rows and the last two as whole numbers.
The `coercions` field keeps them as numbers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
… 64 bits

Through Arrow, a string or blob in an `int64` column is converted to a 64-bit integer.
One that needs 64 bits made the column follow `bigint` in that fetch,
but `note_integer()` only saw values stored as integers, so the next fetch went back to `integer`.
Converted values are now noted too, so the column stays wide like after such an integer.
The default path truncates these values to an `integer`, which the documentation now lists among the differences.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
The default path types the columns of a fetch of no rows from the next row,
and warns when that row holds a value of another storage class.
The Arrow path types the columns the same way but logs nothing, since the fetch returns no value.
The documentation now lists this among the differences of the warnings,
and the comparison of both paths spells it out, with a sequence where the default path warns on the fetch of no rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
krlmlr pushed a commit that referenced this pull request Nov 10, 2026
…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
krlmlr pushed a commit that referenced this pull request Nov 10, 2026
…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
krlmlr pushed a commit that referenced this pull request Nov 10, 2026
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
krlmlr pushed a commit that referenced this pull request Nov 10, 2026
…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
…legant-tesla-mja103-warnings

Brings in the second round of the data frame path through Arrow
(times as doubles in seconds, types carried across `dbBind()`, text cut at its first NUL,
the arrays handed to R as a list, the busy guard of the data frame fetch)
and the fixes of the Arrow interface since the last merge,
among them NULL for times and timestamps out of range and for text that is not valid UTF-8.

The direct warnings of the Arrow interface for values out of range and text that is not valid UTF-8
go to the coercion log, with the reasons `out_of_range` and `invalid_utf8`,
and the members and functions that raised them are gone.
In a text column, the data frame path cuts text at its first NUL and does not check it,
and both paths check blobs, now with the ASCII fast path of the Arrow interface.
For a time or timestamp, a value that can't be parsed is logged first,
then the data frame path appends the seconds,
and only a stream converts them to microseconds and checks their range.
A data frame fetch selects its arrays before it discards the log of an earlier fetch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…he coercion warning

The data frame path through Arrow now carries times and timestamps as doubles in seconds
and starts a new binding from the types of the last one.
Unparsable times and timestamps in seconds are reported once per fetch,
on the same fetches as the default path, and values outside a day or beyond the microseconds keep their value.
After a new binding, values converted to the carried type are reported with row numbers counted from the binding,
also across several fetches.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…legant-tesla-mja103-warnings

Brings in arrow in Suggests, for the test that runs Arrow's full validation behind a skip.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…ning of a fetch

The data frame section still said that such a blob becomes `NA` with a warning of its own,
and the sentence on handlers of the warning of a chunk now says plainly that they get an error.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
krlmlr pushed a commit that referenced this pull request Nov 10, 2026
…nt-tesla-mja103-schema

Brings in #800 at dc4776e, with #796 and #795 below it.
The column builder takes #800's open typing of data frame fetches (`data_frame`, `storage_kind()`, `seconds_class()`, `carry_over()`, `get_kind()`, `discard_coercions()`) and keeps this branch's kinds, unit, time zone and `append_*()` functions.
`append_string()` takes #800's NUL cut for text in a data frame and its UTF-8 check of text and blobs in a stream, for `utf8` and `large_utf8`; numbers into text stay silent here.
`append_time()` replaces #795's time branch: it parses, then hands a data frame its seconds, then checks the range of the unit and the day, for decided and requested types alike.
A requested type wins: a new `requested` flag keeps it out of the seconds storage of a data frame fetch and out of `carry_over()` after `dbBind()`.
`DbResult::set_arrow_schema()` and `get_column_names()` take `BusyScope` like the other entry points.
`arrow_df_column_ptype()` falls back to nanoarrow's prototype for the other formats that a requested type gives, `uint64` is an `integer64`, and `large_utf8` columns are copied like `utf8` before their array goes.
The arrow-schema test reads the arrays of a data frame fetch from the new list of `result_fetch_arrow_df()`.
The generated dependency files are unchanged, and NAMESPACE keeps the import that the development roxygen2 drops.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
krlmlr pushed a commit that referenced this pull request Nov 10, 2026
…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
krlmlr pushed a commit that referenced this pull request Nov 10, 2026
…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
…legant-tesla-mja103-warnings

Brings in `dbColumnInfo()` answered from the Arrow columns, `POSIXlt` written like `POSIXct`,
the note on the cost of small fetches, and the CI hook for the large Arrow test.

The comparison of both data frame paths keeps both layers:
`fetch_sequence()` asks `dbColumnInfo()` before each fetch when asked to and counts the warnings of each fetch,
those of `dbColumnInfo()` aside, and `expect_same_fetches()` checks data and warnings with and without it.
The documentation of the data frame path keeps the sentence on `dbColumnInfo()` and the three differences.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…umnInfo()`

The merge of the data frame path's `dbColumnInfo()` paired each data frame of `fetch_sequence()` with its answer,
also when it was not asked, which changed the shape that the tests of the layers above read.
The pair is now built only with `info = TRUE`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE

krlmlr commented Nov 10, 2026 •

Copy link
Copy Markdown
Member Author

Superseded: Accepted limitations

Superseded by this comment.

Two clean reviews of this pull request, at 64a83c3 and 4a4e580, are addressed up to dc4776e, and every High and Medium finding is fixed. The integration review of the whole stack at 071560ec found nothing that belongs to this layer: the row numbers beyond 32 bits in the warning (its finding 5) come from the row counter of #795. These remain:

  • R/arrow.R#L109: on the data frame path, a string or blob that SQLite converts to an integer too large for an integer makes the column follow bigint in this and every later fetch of the result, as such an integer does, where the default path truncates it to a 32-bit integer ('99999999999' comes back as 1215752191). Relevance: low; reviewer's confidence: high. (recorded)
  • R/arrow.R#L127: a data frame fetch of no rows through Arrow never warns, since it returns no value, where the default path warns about the next row, from which it types the columns. Relevance: low; reviewer's confidence: high. (recorded)
  • R/warn-coercion.R#L31: the header of the coercion warning says "values converted to the column types" also when the values it lists were made NA (not valid UTF-8, not in the expected format, out of range, dropped by the null type); only the bullets say what happened. Relevance: low; reviewer's confidence: high.
  • src/CoercionLog.h#L24: per column and reason, the log keeps the count but only the first 20 and the last two row numbers, so that its memory stays bounded; neither the message nor the coercions field of the warning can name every affected row of a large fetch. Relevance: low; reviewer's confidence: high. (recorded)

Generated by Claude Code

…legant-tesla-mja103-warnings

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.
The row number of the coercion log keeps its cast, now redundant with the 64-bit counter.

The result columns section follows the new order of the Arrow interface,
where the sentences on text come after the paragraph on `chunk_size`, whose "therefore" refers to the conversion before it,
and keeps the coercion warning: converted and dropped values, text in a binary column among the former,
are reported once per chunk.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…F-16 database

The merged test of the Arrow interface expected its direct mixed-type warning,
which this branch reports as one coercion warning per chunk.
It now checks that warning, with the converted strings in rows 2 and 3.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…legant-tesla-mja103-warnings

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
…-16 database

The merged test of the Arrow interface expected its direct warnings,
which this branch reports as one coercion warning per chunk:
the valid blobs as converted, in rows 2, 3 and 5, and the one with a NUL byte as not valid UTF-8, in row 4.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…legant-tesla-mja103-warnings

Brings in the state of the Arrow test hooks kept in each result,
set with `result_set_bytes_limits()` and read with `result_rethrown_unwinds()`.

The new test helpers `set_bytes_limits()` and `fetch_with_bytes_limits()` replace `local_arrow_bytes_limits()`
in `helper-arrow.R`, where this branch keeps the Arrow test helpers, instead of `test-arrow.R`.
The merged tests keep the coercion warning: the held-back blob is checked in its warning,
and the unwind tests expect "Mixed types".
The data frame test of arrays cut short calls `set_bytes_limits()`,
and `src/result.dd` no longer lists `CoercionLog.h`, which `result.cpp` no longer reaches.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…legant-tesla-mja103-warnings

Brings in Arrow streams read safely on worker threads, with the "Threads" section of `?"sqlite-arrow"`,
the scanner tests, the memory cleanup of the large tests with `helper-memory.R`, and the longjmp tests.

The direct warnings of the Arrow interface stay gone, so their `rsqlite_warning()` calls go with them,
and the parsers of dates and times keep reporting failures through `ok`.
The default path's warning of an unparsable value goes through `rsqlite_warning()`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
Arrow streams are read on worker threads by arrow's scanner, Acero and `write_dataset()`, where R can't be called.
Once a value had been logged, `warn_coercions()` built the entries as R lists and called `warn_coercion()` in R on that thread,
which overflowed the C stack and hung the session.
Off R's main thread it now builds the text of the warning in C++ from the logs,
as R shows it without cli, and `rsqlite_warning()` fails the stream with it,
like #795 does for the other warnings.
On R's main thread the warning is unchanged.
The worker-thread test of #795 expects this text,
and a new test compares the error with the warning of the same rows on R's main thread.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…legant-tesla-mja103-warnings

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.

The date and time branches keep the coercion log of this branch and test for NaN with `std::isnan()`.
The coercion logs are written and read inside the busy mark of their result,
in `fetch_arrow()`, `arrow_schema()` and the data frame fetch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…on another thread

The merged test expected the direct warnings of the Arrow interface,
which this branch reports as one coercion warning per chunk,
off R's main thread as the error of the stream.
It now expects that text for the string in an integer column and for the unparsable date,
and the coercion warning when the same date is read on R's main thread.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE

krlmlr commented Nov 10, 2026

Copy link
Copy Markdown
Member Author

Accepted limitations

Two clean reviews of this pull request, at 64a83c3 and 4a4e580, and both integration reviews of the stack (first integration review, second integration review) are addressed up to 86a0342, which closes the review rounds for the stack. Every High and Medium finding is fixed; on a worker thread the coercion warning becomes the stream's error with the same text (c7327be), so this layer calls no R API there either. These remain:

  • R/arrow.R#L109: on the data frame path, a string or blob that SQLite converts to an integer too large for an integer makes the column follow bigint in this and every later fetch of the result, as such an integer does, where the default path truncates it to a 32-bit integer ('99999999999' comes back as 1215752191). Relevance: low; reviewer's confidence: high. (recorded)
  • R/arrow.R#L127: a data frame fetch of no rows through Arrow never warns, since it returns no value, where the default path warns about the next row, from which it types the columns. Relevance: low; reviewer's confidence: high. (recorded)
  • R/warn-coercion.R#L31: the header of the coercion warning says "values converted to the column types" also when the values it lists were made NA (not valid UTF-8, not in the expected format, out of range, dropped by the null type); only the bullets say what happened. Relevance: low; reviewer's confidence: high.
  • src/CoercionLog.h#L24: per column and reason, the log keeps the count but only the first 20 and the last two row numbers, so that its memory stays bounded; neither the message nor the coercions field of the warning can name every affected row of a large fetch. Relevance: low; reviewer's confidence: high. (recorded)
  • src/SqliteResultImpl.cpp#L765-L766: on a worker thread, such as arrow's scanner and Acero use, a fetch with a coercion fails the stream instead of warning, so the rows of that chunk are not delivered, and the error carries the warning's text as R shows it without cli but not its structured coercions field. Relevance: low; confidence: high. (recorded)

Generated by Claude Code

…legant-tesla-mja103-warnings

Brings in the Arrow test fixtures moved into `helper-arrow.R`.
`helper-arrow.R` keeps the helpers of this branch, `coercion_warnings()` among them,
and `fetch_sequence()` there counts the warnings of each fetch, as it did in `test-arrow-df.R` on this branch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
`expect_same_fetches()` moves from the top of `test-arrow-df.R` into `helper-arrow.R`, next to `fetch_sequence()`, and gains a line saying what it is for.
`pkgload::load_all()` sources that file, so 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

krlmlr commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

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 main. It will be closed once its replacements are merged.


Generated by Claude Code

krlmlr commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

Closed as superseded, as decided: the Arrow work is rebuilt from main as a chain of smaller pull requests, planned on #880. The data-frame path through Arrow that this stack carries (group D) is tracked in #881. The branch stays as a reference.


Generated by Claude Code

@krlmlr krlmlr closed this Nov 30, 2026
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