SubhamSinghal opened a new pull request, #23177:
URL: https://github.com/apache/datafusion/pull/23177
## Which issue does this PR close?
- Closes #23085.
## Rationale for this change
PostgreSQL supports `sum()` over `interval` values via component-wise
addition; DataFusion currently
only supports `sum()` on `Duration`, so a query like
```sql
SELECT sum(value) FROM (VALUES
(interval '1 second'), (interval '1 year'), (interval '1 month'))
t(value);
```
errors with No function matches the given name and argument types
'sum(Interval(MonthDayNano))'. The
most useful real-world case is summing time-series gaps / durations
expressed as intervals, which the
issue filer calls out.
## What changes are included in this PR?
## Are these changes tested?
Yes.
## Are there any user-facing changes?
Yes — SUM(<Interval(YearMonth | DayTime | MonthDayNano)>) and SUM(DISTINCT
<interval>) are now valid;
previously they errored at planning time with No function matches. No
change to existing behavior on
any other type. No public API changes.
A note for reviewers: the rendered output for (months=13, days=0,
nanos=1e9) is 13 mons 1.000000000
secs rather than PostgreSQL's 1 years 1 mons 0 days 0 hours 0 mins 1.0
secs. The stored value is
identical; the difference is a display-formatter choice in DataFusion (it
doesn't normalize 13 mons to
1 year 1 month). Keeping that out of scope here.
--
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]