zabetak commented on a change in pull request #1610: [CALCITE-3525] 
RexSimplify: eliminate redundant rex calls in OR
URL: https://github.com/apache/calcite/pull/1610#discussion_r356989965
 
 

 ##########
 File path: 
core/src/main/java/org/apache/calcite/rel/rules/FilterProjectTransposeRule.java
 ##########
 @@ -181,6 +183,14 @@ public void onMatch(RelOptRuleCall call) {
                 .project(project.getProjects(), 
project.getRowType().getFieldNames())
                 .build();
 
+    // if new filter is always false and none of it's inputs use
+    // correlation variables - simplify new project to empty values
+    if (newCondition.isAlwaysFalse() && newFilterRel.getInputs().stream()
+        .map(RelOptUtil::getVariablesUsed)
+        .allMatch(Collection::isEmpty)) {
+      newProjRel = relBuilder.push(newProjRel).empty().build();
 
 Review comment:
   I had a quick look in `EnumerableCorrelateTest` and it seems that it fails 
because the plan is slightly different but from what I see still semantically 
correct. Plan comparison is not that clever so it is common that you need to 
update the expected plan when such cases occur. 
   
   Other than that it does not really matter if the rule produced a new 
expression or not. Adding a new rule may also change the order that other rules 
are matched leading to changes in the expected plan which might explain why 
tests fail.  

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