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

   ### Describe the bug
   
   Splitting out from 
https://github.com/apache/datafusion/issues/14738#issuecomment-2666570269: 
   
   
   ```sql
   SELECT date_part('seconds', interval '1 hour');
   -- returns 3600, but the result should be 0
   SELECT date_part('seconds', interval '1 hour 5 second');
   --- returns 3605, should return 5
   SELECT date_part('seconds', interval '3605 seconds');
   --- returns 3605, should return 5
   ```
   
   It seems that for intervals at least the date part is calculating based on 
the overall interval, not the specifically requested part. Postgresql has this 
note about date_part and interval:
   
   ```
   When processing an interval value, the extract function produces field 
values that match the interpretation used by the interval output function. This 
can produce surprising results if one starts with a non-normalized interval 
representation, for example:
   
   SELECT INTERVAL '80 minutes';
   Result: 01:20:00
   SELECT EXTRACT(MINUTES FROM INTERVAL '80 minutes');
   Result: 20
   ```
   
https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT
   
   ### To Reproduce
   
   _No response_
   
   ### Expected behavior
   
   I believe DataFusion should mirror PG in this behaviour.
   
   ### 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