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

 ##########
 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:
   If I am not mistaken, this simplification would have already taken place in 
the "else" block (copyFilter=false, line 175), because the RelBuilder#filter 
method already performs it, so it seems kind of redundant in that case. I think 
we would only need to add it to the "if" block (copyFilter=true).
   Now, the problem is that I'm not sure we could use this simplification 
(which uses the relBuilder) in the case of copyFilter, as stated in the javadoc 
description of the private simplifyFilterCondition method.
   There was some discussion about this rule and the condition simplification 
in https://issues.apache.org/jira/browse/CALCITE-2582 ; maybe @zabetak , who in 
the end committed that fix, can help. 

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

Reply via email to