date_trunc rejects scalar timestamps that array evaluation accepts
Describe the bug
date_trunc supports a narrower timestamp range for scalar inputs than for column inputs.
For a Timestamp(Second, None) value outside the nanosecond timestamp range, truncating a scalar returns an out-of-range error while truncating the same value from a column succeeds.
To Reproduce
Scalar input:
SELECT date_trunc('second', to_timestamp_seconds(10000000000));Run the scalar query in DataFusion Fiddle
Actual result:
Execution error: Timestamp 10000000000 out of rangeThe same value provided through a column:
SELECT date_trunc('second', to_timestamp_seconds(ts))
FROM (VALUES (10000000000)) AS timestamps(ts);Run the column query in DataFusion Fiddle
Actual result:
2286-11-20T17:46:40Reproduced on commit 98b26c5f9 (development version 55.1.0).
Expected behavior
Both forms should return 2286-11-20T17:46:40. Scalar and column evaluation should support the same timestamp domain for equivalent operations.
Additional context
This also affects millisecond- and microsecond-resolution scalar timestamps outside the nanosecond-representable range. It is distinct from #25425, where scalar and array evaluation both succeed but produce different results.
Source: apache/datafusion