danny0405 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_r323538224
 
 

 ##########
 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:
   Thanks, Julian, let me have a try :)

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to