-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Splitting out from #14738 (comment):
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
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working