feat(functions-aggregate): support sum(interval)#23177
Open
SubhamSinghal wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
PostgreSQL supports
sum()overintervalvalues via component-wise addition; DataFusion currentlyonly supports
sum()onDuration, so a query likeerrors 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 ) 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.