hsyuan commented on a change in pull request #1417: [CALCITE-3244]
RelDecorrelator unable to decorrelate expression with …
URL: https://github.com/apache/calcite/pull/1417#discussion_r318279418
##########
File path:
core/src/main/java/org/apache/calcite/rel/rules/SubQueryRemoveRule.java
##########
@@ -309,8 +311,22 @@ private RexNode rewriteExists(RexSubQuery e,
Set<CorrelationId> variablesSet,
}
builder.as("dt");
+ boolean generateNullsOnRight = true;
+ if (e.rel instanceof LogicalAggregate) {
+ // SELECT f0, count(*) FROM t GROUP BY () will always return 1 row.
+ // That means, the RHS never generates null.
+ final LogicalAggregate aggregate = (LogicalAggregate) e.rel;
+ if (aggregate.getGroupSet().isEmpty()
+ && aggregate.getAggCallList().stream()
+ .anyMatch(c -> c.getAggregation() instanceof
SqlCountAggFunction)) {
Review comment:
It doesn't need to be count, any agg function with empty groupset will
always generate 1 row.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services