Skip to content

Commit

Permalink
Cleanup AggreggationNode#producesDistinctRows
Browse files Browse the repository at this point in the history
  • Loading branch information
pettyjamesm committed Oct 16, 2024
1 parent c561d3e commit 8c7d277
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class RemoveRedundantDistinctAggregation
implements Rule<AggregationNode>
{
private static final Pattern<AggregationNode> PATTERN = aggregation()
.matching(RemoveRedundantDistinctAggregation::isDistinctOnlyAggregation);
.matching(AggregationNode::producesDistinctRows);

@Override
public Pattern<AggregationNode> getPattern()
Expand All @@ -72,11 +72,6 @@ public Result apply(AggregationNode aggregationNode, Captures captures, Context
}
}

private static boolean isDistinctOnlyAggregation(AggregationNode node)
{
return node.producesDistinctRows() && node.getGroupingSetCount() == 1;
}

private static boolean isDistinctOverGroupingKeys(PlanNode node, Lookup lookup, Set<Symbol> parentSymbols)
{
return switch (node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ public boolean producesDistinctRows()
{
return aggregations.isEmpty() &&
!groupingSets.getGroupingKeys().isEmpty() &&
outputs.size() == groupingSets.getGroupingKeys().size();
groupingSets.getGroupingSetCount() == 1 &&
outputs.size() == groupingSets.getGroupingKeys().size(); // grouping keys are always added to the outputs list, so a size match guarantees the two contain the same elements
}

public boolean isDecomposable(Session session, Metadata metadata)
Expand Down

0 comments on commit 8c7d277

Please sign in to comment.