You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Lenient .csv.read wraps out-of-range integers to the column width and turns F32 overflow into inf #1892
The default (lenient) .csv.read keeps an out-of-range number as a different value instead of a null: an integer is wrapped to the column's width, the type's minimum is stored as the null sentinel, and a float past the F32 range becomes an infinity.
(sett (.csv.read [U8 I16 I32 F32] "wrap.csv"))
(at t'u) ; [0x2c 0xff] 300 -> 44, -1 -> 255
(at t'h) ; [-25536 -32768] 40000 wraps; -32768 is NULL_I16, kept as the sentinel
(at t'i) ; [-1294967296 -2147483648]
(at t'e) ; [infe 3.40e+38e] 1e39 -> inf in an F32
An I64 overflow and 1e400 in an F64 already read as nulls; the narrower widths do not. The parse goes through fast_i64 and casts to the column's width (csv_parse_fn, the I16/I32/U8 cases), and F32 casts a finite double to float.
Decision needed
Making these nulls (as I64 and F64 already are) changes what existing reads return, so it is for the owner. {strict: true} (#1888) already refuses each of them with "300" is out of range for a U8.
The same class for TIMESTAMP, and there it is also undefined behaviour in C: an instant outside the type's range (2000-01-01 ± 292 years: 1707-09-22T00:12:43.145224193 .. 2292-04-10T23:47:16.854775807) is computed as a signed int64 that overflows.
(at (.csv.read [TIMESTAMP] "ts.csv") 'v)
; release build (dev 2ed46378d): [1815.03.31D05:56:08.066277376 2184.07.20D23:34:33.709551616]; debug build (UBSan): src/io/csv.c:713:36: runtime error: signed integer overflow:; 86400000000000 * 2921575 cannot be represented in type 'long int'
The overflow is int64_t result = (int64_t)days * NS_PER_DAY + time_ns; in fast_timestamp (src/io/csv.c:713; result -= adj; at 727 can overflow too, with a UTC offset at the ends of the range). The type-inference sampler calls fast_timestamp as well, so (.csv.read "ts.csv") without a schema reaches it. Even on the earliest day of the range (1707-09-22), where the instant fits, days * NS_PER_DAY alone overflows. {strict: true} (#1888) parses timestamps with its own checked arithmetic and refuses these as out of range; the lenient answer is part of the decision asked for above.
Activity
singaraiona commentedon Nov 28, 2026
The same class for TIMESTAMP, and there it is also undefined behaviour in C: an instant outside the type's range (2000-01-01 ± 292 years: 1707-09-22T00:12:43.145224193 .. 2292-04-10T23:47:16.854775807) is computed as a signed int64 that overflows.
The overflow is
int64_t result = (int64_t)days * NS_PER_DAY + time_ns;infast_timestamp(src/io/csv.c:713;result -= adj;at 727 can overflow too, with a UTC offset at the ends of the range). The type-inference sampler callsfast_timestampas well, so(.csv.read "ts.csv")without a schema reaches it. Even on the earliest day of the range (1707-09-22), where the instant fits,days * NS_PER_DAYalone overflows.{strict: true}(#1888) parses timestamps with its own checked arithmetic and refuses these as out of range; the lenient answer is part of the decision asked for above.