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_r353631567
 
 

 ##########
 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:
   The rules that are using the copy bring some extra headache and many of them 
end up creating problems but let's not open this discussion again here. 
   
   Now regarding the change, I think it is not safe to do it here. If our input 
was an `EnumerableFilter` and `EnumerableProject` then the way is the code 
right now we may end up creating an `EnumerableProject` over a `LogicalValues` 
which may end up being worse than an `EnumerableFilter` that is always false. 
   
   Given that the code even before this change retained a filter that is always 
false in the case of copying I would suggest to keep this behavior in order to 
advance faster this PR. It may be better to discuss the removal of the filter 
under another issue.

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