Repository navigation
Conversation
… unit and time zone An Arrow fetch can now request large_utf8, large_binary, date64, time32 in seconds or milliseconds, time64 in microseconds or nanoseconds, and timestamp and duration in any unit, a timestamp with any time zone or none. The requested types keep their unit and time zone, see ArrowColumnType. Large columns have no byte limit of their own: the rows that a fetch asks for bound their chunk. The time zone of a timestamp is only metadata: text without an offset is UTC, an offset shifts it to UTC. Seconds and milliseconds round reals and drop digits of text, and count these values as rounded or truncated; nanoseconds keep nine digits of text. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
… into claude/rb-arrow-requested-temporal Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
parse_time() allows a time with an offset up to 24:00:00 in microseconds, and the nanosecond digits came after that check, so '24:00:00.0000005+00:00' read as 500 ns where SQLite's time() gives NULL. The time zone of a requested timestamp stays unchecked, now said in a comment, and the comments on rounded and truncated values name the temporal units. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
…al' into claude/rb-arrow-requested-temporal Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
Question: should requested
|
Question: how should a requested timestamp with a named time zone read text without an offset?This pull request builds requested timestamps in any unit, with or without a time zone. The stored value is always the UTC epoch, and a named zone such as
Kirill decides. Until then the first option stays as implemented. Generated by Claude Code |
No change of behavior for users: this extends the internal
schemaargument of the Arrow fetches (fetch_arrow_chunk_warn(),read_arrow_stream(), from #979) to more requested types. Besides the types of #979, a fetch can now request large_utf8, large_binary, date64, time32 in seconds or milliseconds, time64 in microseconds or nanoseconds, and timestamp and duration in any unit, a timestamp with any time zone or none. The requested types now carry their unit and time zone (ArrowColumnTypeinsrc/SqliteArrowKind.h), so a later request must match them too:timestamp[ms, UTC]aftertimestamp[ms, Europe/Vienna]is refused like any other type. Half float, decimals, intervals, views, dictionaries, nested and extension types still fail before any row is read.large_utf8 and large_binary read values as utf8 and binary do, with the same warnings, but have no byte limit of their own: their 64-bit offsets address any chunk, so the number of rows that the fetch asks for (65536 per chunk for a stream by default) bounds the memory of their chunk, as it does for a data-frame fetch, and SQLite's length limit bounds each value. A chunk that memory can't hold fails with an error.
date64 is the days of date32 in milliseconds, read by the same rules as #960 (text parsed, numbers as days truncated toward zero), and NULL only beyond the range of int64 milliseconds. Times of day, timestamps and durations read the seconds that
dbFetch()reads from a TIME or DATETIME column, in their unit. The time zone of a timestamp is only metadata and is not checked, so a string that names no zone, such as "Not/AZone", is kept as it is: a check would need a time zone database that a stream's worker threads can't take from R. the value is always the time since 1970-01-01 00:00:00 UTC, so text without an offset such as '2020-01-01 12:00:00' is read as UTC and text with an offset is shifted to UTC, as SQLite'sdatetime()and #885 do, also for a timestamp without a time zone, whose wall-clock time is then UTC's. A duration is the hms duration ofdbFetch(): signed and beyond a day as written, or a time of day in UTC with an offset. Times of day keep the rules of #960 (24:00:00 and negative times are NULL, a real is checked against the day before rounding and stops at the last unit of the day), and a time or duration with an offset ends at 24:00:00 in full precision, as SQLite'stime()does: '24:00:00.0000005+00:00' is NULL like '24:00:00.000001+00:00' (fixed after review in 4fafe90, red before).Reals are rounded to the nearest unit of the value the double holds, halves to even, with the exact rounding of #960 generalized to every unit. Text keeps nine digits of the fraction for nanoseconds (the parsers stop at microseconds, so the further digits are read separately), and drops the digits that a coarser unit doesn't hold as written: a timestamp or time of day keeps the whole unit before them (so '1969-12-31 23:59:59.5' is -1 in seconds), a duration is truncated toward zero. Seconds and milliseconds count these values through #961's warnings as rounded (reals) or truncated (text), since
dbFetch()keeps them; microseconds and nanoseconds count nothing, as #960 doesn't. Values beyond int64 in the unit are NULL as out of range, such as timestamps outside 1677 to 2262 in nanoseconds, including the smallest int64, which bit64 reads as NA. All of this is R-free and runs unchanged on a worker thread (#978), whose warnings go through its queue.Tested in the new
tests/testthat/test-arrow-requested-temporal.R: large types against utf8 and binary, beyond the byte limit in one chunk while utf8 fails; date64 at its range limits; each time unit with fractions, offsets, 24:00:00, negative and out-of-day values, reals at the end of the day; timestamps in each unit with no time zone, UTC, a named zone and an offset zone, text with and without offsets, before 1970, halves of reals; nanosecond and second range edges exactly; durations in each unit, signed and beyond a day; text forms with fields of one digit, offsets after a space and ten fraction digits; declared DATE, TIME and DATETIME columns overridden; later chunks with NULL-only first chunks and refused other units or zones; and a stream read on a worker thread through #978's hook with its queued warnings. The list of unsupported types intest-arrow-requested-types.Rnow holds types that stay unsupported. Full suite withNOT_CRAN=true: FAIL 0, WARN 3 (thezh_TW.UTF-8locale is missing in the container), SKIP 64, PASS 14027. Valgrind on the new test file: 0 errors, 0 bytes definitely lost.Item 14 of the plan in #829 (comment), a layer of the rebuilt chain planned in #880; based on #979 (item 13). Not ported from an old PR: the parsing and rounding rules are those of #960 and #885, extended to other units.
Coordinating session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
Generated by Claude Code