benbellick opened a new issue, #25432:
URL: https://github.com/apache/datafusion/issues/25432

   # 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:
   
   ```sql
   SELECT date_trunc('second', to_timestamp_seconds(10000000000));
   ```
   
   [Run the scalar query in DataFusion 
Fiddle](https://datafusion-fiddle.vercel.app?q=eyJzdGF0ZW1lbnQiOiIgU0VMRUNUIGRhdGVfdHJ1bmMoJ3NlY29uZCcsIHRvX3RpbWVzdGFtcF9zZWNvbmRzKDEwMDAwMDAwMDAwKSk7In0=)
   
   Actual result:
   
   ```text
   Execution error: Timestamp 10000000000 out of range
   ```
   
   The same value provided through a column:
   
   ```sql
   SELECT date_trunc('second', to_timestamp_seconds(ts))
   FROM (VALUES (10000000000)) AS timestamps(ts);
   ```
   
   [Run the column query in DataFusion 
Fiddle](https://datafusion-fiddle.vercel.app?q=eyJzdGF0ZW1lbnQiOiIgICBTRUxFQ1QgZGF0ZV90cnVuYygnc2Vjb25kJywgdG9fdGltZXN0YW1wX3NlY29uZHModHMpKVxuICAgRlJPTSAoVkFMVUVTICgxMDAwMDAwMDAwMCkpIEFTIHRpbWVzdGFtcHModHMpOyJ9)
   
   Actual result:
   
   ```text
   2286-11-20T17:46:40
   ```
   
   Reproduced 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.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to