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
date_trunc array fast path underflows for extreme timestamps #25129
date_trunc can underflow when its array fast path truncates an extreme timestamp. In debug builds, the unchecked subtraction can panic. In release builds, it can wrap and return an incorrect timestamp.
The scalar path handles out-of-range arithmetic by returning a DataFusion error, but general_date_trunc_array_fine_granularity performs the truncation with unchecked arithmetic:
*v - i64::rem_euclid(*v, unit)
This was identified while reviewing #24501. The optimizer proposed there evaluates scalar boundary values, while normal query execution uses the array path. These paths should have consistent overflow behavior before date_trunc is used to establish partitioning guarantees.
To Reproduce
CREATETABLEextreme_timesASSELECT arrow_cast(value, 'Timestamp(Nanosecond, None)') AS ts
FROM (VALUES (-9223372036854775807-1)) AS t(value);
SELECT ts, date_trunc('microsecond', ts) AS truncated
FROM extreme_times;
Activity
benbellick commentedon Sep 9, 2026
take
fix: prevent date_trunc array underflow (apache#25131)