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

   ### Describe the bug
   
   There is actually no implementation of `trunc` for `decimal` inputs, so we 
coerce the input to floating point. This yields incorrect/unexpected results 
for inputs above 2^53.
   
   ### To Reproduce
   
   ```
   > select trunc(CAST(9007199254740993 AS DECIMAL(20,0)));
   +--------------------------------+
   | trunc(Int64(9007199254740993)) |
   +--------------------------------+
   | 9007199254740992.0             |
   +--------------------------------+
   1 row(s) fetched.
   Elapsed 0.011 seconds.
   ```
   
   ### Expected behavior
   
   The query should return `9007199254740993`, which is what Postgres and 
DuckDB both do.
   
   ### Additional context
   
   _No response_


-- 
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