Skip to content

Date - Date returns a type inconsistent with other databases #19528

@Omega359

Description

@Omega359

Describe the bug

As uncovered in #19460, SELECT '2001-09-28'::date - '2001-08-12'::date returns a Duration type whereas other systems return an int:

https://www.postgresql.org/docs/current/functions-datetime.html
https://duckdb.org/docs/stable/sql/data_types/interval#arithmetic-with-timestamps-dates-and-intervals
https://dev.mysql.com/doc/refman/8.4/en/expressions.html#temporal-intervals

Datafusion should adhere to common conventions for operation types unless there is a really good reason to deviate.

IOW, this should work:

query T
SELECT arrow_typeof('2001-09-28'::date - '2001-08-12'::date)
----
Int64

To Reproduce

See sql above

Expected behavior

date - date should return an int of the days difference between the two dates, not a duration.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions