Fix a missing negation in MergeLimitWithDistinct#isDistinct
@@ -45,7 +45,7 @@ public class MergeLimitWithDistinct
AggregationNode child = (AggregationNode) input;
- if (isDistinct(child)) {
+ if (!isDistinct(child)) {
return Optional.empty();
}
@@ -64,8 +64,8 @@ public class MergeLimitWithDistinct
*/
private boolean isDistinct(AggregationNode node)
{
- return !node.getAggregations().isEmpty() ||
- node.getOutputSymbols().size() != node.getGroupingKeys().size() ||
- !node.getOutputSymbols().containsAll(node.getGroupingKeys());
+ return node.getAggregations().isEmpty() &&
+ node.getOutputSymbols().size() == node.getGroupingKeys().size() &&
+ node.getOutputSymbols().containsAll(node.getGroupingKeys());
}
}
