Description
Describe the bug
date_bin returns NULL when a valid non-null timestamp’s computed bin falls outside the output timestamp type’s range.
#22215 requested an error instead of a panic. Its fix, #22408, prevented the panic but returned NULL instead.
To Reproduce
SELECT date_bin(
INTERVAL '3 nanoseconds',
arrow_cast(-9223372036854775808, 'Timestamp(Nanosecond, None)'),
TIMESTAMP '1970-01-01 00:00:00'
);Currently returns NULL because the containing bin starts below the minimum representable nanosecond timestamp.
Expected behavior
Return an error for an unrepresentable bin, matching PostgreSQL’s behavior.
Preserve the scalar/array consistency established by #22528 and #22610. Equivalent scalar and column inputs should return the same valid bin or both error. NULL timestamp inputs should remain NULL, and representable bins should continue to succeed even when intermediate arithmetic requires a wider type.
Additional context
Related to the audit in #25344. This change does not enable date_bin range-locality analysis.
Willingness to contribute
I plan to contribute a fix for this bug independently
Activity
benbellick commentedon Oct 22, 2026
take
fix(datetime): error on out-of-range date_bin timestamp bins (apache#…