Repository navigation
Conversation
With `extended_types = TRUE`, a column declared DATE, TIME, DATETIME or TIMESTAMP, as `dbFetch()` decides it, becomes date32, time64[us] or timestamp[us, UTC] in an Arrow chunk. Values are read with the parsers that `dbFetch()` uses, with a UTC offset applied in whole microseconds, and numbers are days or seconds since 1970. Text that doesn't parse, blobs, and values that the Arrow type can't hold are NULL, silently until the conversion reports exist. Ported from #861. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
…o claude/rb-arrow-dates Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
Question: should the Arrow arrays hold the values that
|
…o claude/rb-arrow-dates Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
…imes out of the day A TIME real is checked against the day before rounding, so -1e-7 and -4e-7 are NULL as -0.1 is, rather than rounding to 00:00:00. A real just before midnight still stops at the last microsecond of the day. The fraction of a second times 1e6 was rounded to a double before it was rounded to a microsecond, which turned 2.5e-6, a little more than 2.5 microseconds as a double, into 2. The error of the first rounding, exact from a fused multiply-add, now decides where it gives a half. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
No change of behavior for users: Arrow chunks are fetched only through the unexported
result_fetch_arrow_chunk()until the stream exists.With
dbConnect(extended_types = TRUE), a column declared DATE, TIME, DATETIME or TIMESTAMP, matched asdbFetch()matches it (datatype_from_decltype(), case-insensitive, exact names; an expression has no declared type and follows its values), now becomesdate32,time64[us]ortimestamp[us, UTC]in an Arrow chunk, whatever its values, also in a chunk of no rows or only NULL. Text is parsed with the parsers that the previous layer split from their warnings (parse_date(),parse_time(),parse_datetime_local()), and a UTC offset is applied in whole microseconds: a timestamp is shifted to UTC, and a time with an offset is a time of day in UTC, as SQLite'stime()anddbFetch()read it. Numbers are days (truncated toward zero) or seconds (rounded to the microsecond nearest to the value the double holds, halves to even) since 1970, asdbFetch()reads them. The fraction times 1e6 is rounded to a double first, and the exact error of that rounding (fromstd::fma()) decides where it gives a half: 2.5e-6, a little more than 2.5 µs as a double, becomes 3 µs, where CPython'sdatetime.fromtimestamp()rounds the half to 2. Text that doesn't parse and blobs are NULL wheredbFetch()warns, silently until the conversion reports exist (F4a), as for the other conversions of Arrow chunks.Where the Arrow type can't hold what
dbFetch()gives, the value is NULL, as #861 chose: a count of days beyond 32 bits (whichdbFetch()wraps), a TIME outside the day such as25:00:00or a negative number however close to zero (whichdbFetch()keeps as anhmsduration), and microseconds beyond int64. A real TIME is checked against the day before rounding, and rounding neither takes it out of the day nor brings it in: -1e-7 is NULL as -0.1 is, and a real just before midnight that would round up to 24:00:00 stops at the last microsecond of the day. The open question from #861 about these durations carries over: should a TIME column whose values aren't times of day rather be aduration[us]array, or staytime64[us]with NULL? The values turned into NULL are to be reported by F4a.Tests in
tests/testthat/test-arrow-dates.Rcompare each chunk withdbFetch(extended_types = TRUE)on a separate result where the rules agree (expect_same_chunks()inhelper-arrow.R, which also validates every chunk through nanoarrow's IPC round trip), and pin exact microseconds asinteger64: offsets (±HH:MM,Z, surrounding whitespace, offsets SQLite rejects), times with offsets compared with SQLite'stime()and timestamps withunixepoch(), fractions beyond microseconds, numbers as days or seconds including rounding of halves, of reals that hold a little more or less than a half microsecond, and of present-day timestamps, small negative TIME reals, dates and timestamps before 1970 and after 2038, values beyond the range of the Arrow types, invalid text and blobs, out-of-memory while converting UTF-16 text, NULL-only columns, mixed storage classes across chunk sizes, new executions afterdbBind(), declared types such asTimeStamp,DATETIME(6),DATE_, aliases and expressions, a UTF-16 database, and the same columns withoutextended_types. Full suite withNOT_CRAN=true: FAIL 0, WARN 3 (locale), SKIP 63, PASS 12149.Layer F3 of the rebuilt chain, planned in #880; based on #959. Ported from #861 (draft), without the parser split that already landed in the layer below and with #885's offset handling, so the old pins of negative offsets read as fractions of a second no longer apply.
Coordinating session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
Generated by Claude Code