-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add AggregationNode.hasSingleGlobalAggregation #14559
Add AggregationNode.hasSingleGlobalAggregation #14559
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm % comment
...in/java/io/trino/sql/planner/iterative/rule/DecorrelateInnerUnnestWithGlobalAggregation.java
Show resolved
Hide resolved
a24f8b0
to
90a4e2a
Compare
@@ -119,6 +119,16 @@ public GroupingSetDescriptor getGroupingSets() | |||
return groupingSets; | |||
} | |||
|
|||
/** | |||
* Returns {@code true} if the aggregation has form GROUP BY (). | |||
* Returns {@code false} if there is more than one grouping set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove Returns {@code false}
case.
I wondder why
even if all are empty e.g. GROUP BY GROUPING SETS ((), ()).
is relevant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some places look only at getGroupingKeys().isEmpty()
and consider this a global aggregation. This includes any number of empty grouping sets.
This method only allows for a single empty grouping set and I wanted to emphasize that in the comment so it's easier to spot the difference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which places do that? That would be a bug.
There's only one possible interpretation of "single global aggregation". It must collapse all rows into a single group and produce a single row. The presence of multiple groups would immediately disqualify it as a "single" aggregation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which places do that?
The most prominent example:
io.trino.sql.planner.LocalExecutionPlanner.Visitor#visitAggregation
...
if (node.getGroupingKeys().isEmpty()) {
return planGlobalAggregation(node, source, context);
}
@@ -119,6 +119,16 @@ public GroupingSetDescriptor getGroupingSets() | |||
return groupingSets; | |||
} | |||
|
|||
/** | |||
* Returns {@code true} if the aggregation has form GROUP BY (). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be documented using @return
in the javadocs:
@return
true if the aggregation collapses all rows into a single global group (e.g., as a result of aGROUP BY ()
query). Otherwise, false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the comment
90a4e2a
to
d7aff06
Compare
flaky TestParquetReader #13633 |
d7aff06
to
ba65a86
Compare
rebased on the master to restart CI |
Description
Extract single global aggregation (
GROUP BY ()
) from multiple places to a method inAggregationNode
Non-technical explanation
Code refactoring
Release notes
( X) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
( ) Release notes are required, with the following suggested text: