substrait-io / substrait

A cross platform way to express data transformation, relational algebra, standardized record expression and plans.
https://substrait.io
Apache License 2.0
1.14k stars 148 forks source link

Inconsistent type inference for date add/subtract interval operations #576

Open LeonidChistov opened 9 months ago

LeonidChistov commented 9 months ago

Discussed in https://github.com/substrait-io/substrait/discussions/574

Following operations are defined in Substrait prototypes:

add(date, interval_year): -> timestamp
add(date, interval_day): -> timestamp
subtract(date, interval_year): -> date
subtract(date, interval_day): -> date

It looks like add and subtract behavior need to be consistent with regards to result type.

However, different databases/frameworks have different type inference for these operations:

Probably it is not so important which type inference approach will be used by Substrait, because type casts from/to timestamp for operands/result can be used to adjust to specific DB semantics.

But there is no reason to let add and subtract have different type inference.