### Describe the bug Extract from interval type failed in DF, but works in Postgres ### To Reproduce ``` select extract( year from interval '5' year); Error during planning: Coercion from [Utf8, Interval(MonthDayNano)] to the signature OneOf([Exact([Utf8, Date32]), Exact([Utf8, Date64]), Exact([Utf8, Timestamp(Second, None)]), Exact([Utf8, Timestamp(Microsecond, None)]), Exact([Utf8, Timestamp(Millisecond, None)]), Exact([Utf8, Timestamp(Nanosecond, None)]), Exact([Utf8, Timestamp(Nanosecond, Some("+00:00"))])]) failed. ``` ### Expected behavior Query should work ### Additional context Found when reviewing #6312 Possibly related to #5806
Activity
Jefffrey commentedon Dec 31, 2023
Here's some example output from postgres:
Note how
monthcontributes toyearwhen it overflows, butdaydoesn't do the same formonthAnd how
secondandminutecan overflow as well, buthourdoesn't overflow into day.Duckdb shows the same results:
Can use these as guidance for implementation for Datafusion, but keeping in mind there are three different interval types to support:
YearMonth- stores number of monthscentury,decade,year,monthwhere month overflows into year as necessaryDayTime- stores number of days and number of millisecondsweek,day,hour, and lower units, as conversion from day -> month is not well defined (see discussion Discussion: handling comparison of intervals #8468)MonthDayNano- stores number of months, number of days, and number of nanosecondsReferences
https://duckdb.org/docs/sql/functions/datepart
https://duckdb.org/docs/sql/data_types/interval.html
https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT
nrc commentedon Aug 1, 2024
The work in Arrow has landed and should be in 53, then we can progress #11501 to close this issue.