feat: Implement grouping function using grouping id #12704
+461
−1
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?
Closes #5647 .
Rationale for this change
Grouping function is supported by postgres and needed inorder to be able to run TPC-DS (#4763).
What changes are included in this PR?
This PR adds an analyzer rule that will transform the grouping aggregation function into a projection on top of grouping id (added in #12571). Since the grouping aggregation function is so specific and special (and not really a aggregation), I don't think it make sense to generalize the UDAF api to support it.
This PR currently leaves the non-functional grouping UDAF. But since it non functional and will remain so, we might want to replace it with some built in
Expr::Grouping
instead. Would love some more feedback if that should be done in this PR or some other alternative.Are these changes tested?
New slt, mostly copied from #10208 with some additional test of wrong arguments.
Are there any user-facing changes?
Yes, after this grouping function will be usable.