…t converting values
The peek took the types of the next row by reading its values into a data frame of one row.
Reading converts a value, which raised warnings about values that the fetch returning the row warns about again,
such as dates that `extended_types = TRUE` can't parse or values of mixed types,
and could fail when SQLite ran out of memory for a large text value.
Reading a blob as text also turned it into text for that fetch,
which then didn't warn about a blob in a character column.
The peek now decides each column's type from the declared type and the storage class,
with the rules that a fetch uses when it stores a value,
and builds zero-row columns of those types.
The types are the same as before for every combination of declared type, storage class, `bigint` and `extended_types` tested.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
dbColumnInfo()anddbFetch(n = 0)now decide the column types of the next row without converting its values, so they raise no warnings. The types they return are unchanged.What users see: before, these peeks read the next row into a one-row data frame and threw it away. Reading converts values, so a peek warned about things that the fetch returning the row warns about again: dates, datetimes and times that
extended_types = TRUEcan't parse ("Unknown string format", "Cannot convert blob"), and values of mixed types after an earlier fetch had fixed the column types. A peek also failed with "out of memory" when SQLite couldn't convert a large text value. Reading a blob as text also turned it into text for the following fetch, which then didn't warn about a blob in a character column. Now the peeks raise none of these, and the fetch that returns the row warns exactly as it does without a peek. NEWS has a bullet under Bug fixes. BecausedbColumnInfo()no longer raises warnings, I narrowed the #934 bullet to warnings thatdbFetch()raises, and removed the test where a warning handler ofdbColumnInfo()tried to clear the result: no such handler can run any more. A new test checks thatdbColumnInfo()doesn't warn on that same data.Question for the maintainer: is it OK for these warnings to disappear from the peek? They come back in the fetch that returns the row, so users still see each of them once.
How:
DbColumnStorage::get_value_data_type()holds the rule that a fetch uses when it stores a non-NULL value: the storage class throughget_data_type()(the declared type for dates with extended types, andsqlite3_column_int64()for an INTEGER, which converts nothing), with integers widening to integer64 or double.append_data()uses the same function.DbColumn::peek_type()applies it to the current row, andDbDataFrame::peek_data()builds zero-row columns of those types withDbColumnStorage::allocate(). A peek calls nofetch_*(). This lets the Arrow layers drop the storage-class re-reading, which was only needed because a peek could convert the row.Tests: I compared the base and this branch on a matrix of 10 declared types (including no declared type and an expression) × 11 first-row values (NULL, int, int64, real, text, date/time/datetime text, blob, invalid UTF-8 blob and text) and an empty result × all four
bigintvalues ×extended_types×check_utf8, plus a second-row matrix afterdbFetch(n = 1): 8240 cases in all. ThedbColumnInfo()anddbFetch(n = 0)results are identical in every case. On the base, 1356 of the 4120 peeks warned, and in 46 cases a peek removed the mixed-type warning from the following fetch. On this branch no peek warns, and every following fetch matches the same fetch without a peek.test-column-types.Rpins this matrix: the types of the peek match those of the fetched rows, there are no warnings, and the later fetch is unaffected. ExplicitdbColumnInfo()types pin representative cases. Red → green: on the base, the matrix tests, the two focused tests (an unparsableDATE, and a blob after text in aTEXTcolumn) and the rewritten out-of-memory test (dbFetch(n = 0)under a heap limit fails with "Cannot read column 2: out of memory") fail, and on this branch they pass. Full suite withNOT_CRAN=true: FAIL 0, WARN 3 (zh_TW locale unavailable), SKIP 63, PASS 11446.Layer R4 of the rebuilt chain, planned in #880; based on #950. There is no old PR to port: this layer is new in the rebuilt chain.
Coordinating session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
Generated by Claude Code