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

 ##########
 File path: 
core/src/main/java/org/apache/calcite/rel/rules/FilterProjectTransposeRule.java
 ##########
 @@ -167,43 +165,14 @@ public void onMatch(RelOptRuleCall call) {
           .replaceIfs(RelDistributionTraitDef.INSTANCE,
               () -> Collections.singletonList(
                       
input.getTraitSet().getTrait(RelDistributionTraitDef.INSTANCE)));
-      newFilterRel = filter.copy(traitSet, input, 
simplifyFilterCondition(newCondition, call));
+      newCondition = 
RexUtil.removeNullabilityCast(relBuilder.getTypeFactory(), newCondition);
+      newFilterRel = filter.copy(traitSet, input, newCondition);
     } else {
-      newFilterRel =
-          relBuilder.push(project.getInput()).filter(newCondition).build();
+      newFilterRel = relBuilder.push(project.getInput())
+          .filter(newCondition)
+          .build();
     }
-
-    RelNode newProjRel =
-        copyProject
-            ? project.copy(project.getTraitSet(), newFilterRel,
-                project.getProjects(), project.getRowType())
-            : relBuilder.push(newFilterRel)
-                .project(project.getProjects(), 
project.getRowType().getFieldNames())
-                .build();
-
-    call.transformTo(newProjRel);
-  }
-
-  /**
-   * Simplifies the filter condition using a simplifier created by the
-   * information in the current call.
-   *
-   * <p>This method is an attempt to replicate the simplification behavior of
-   * {@link RelBuilder#filter(RexNode...)} which cannot be used in the case of
-   * copying nodes. The main difference with the behavior of that method is 
that
-   * it does not drop entirely the filter if the condition is always false.
-   */
-  private RexNode simplifyFilterCondition(RexNode condition, RelOptRuleCall 
call) {
-    final RexBuilder xBuilder = call.builder().getRexBuilder();
-    final RexExecutor executor =
-        Util.first(call.getPlanner().getContext().unwrap(RexExecutor.class),
-            Util.first(call.getPlanner().getExecutor(), RexUtil.EXECUTOR));
-    // unknownAsFalse => true since in the WHERE clause:
-    // 1>null evaluates to unknown and WHERE unknown behaves exactly like 
WHERE false
-    RexSimplify simplifier =
 
 Review comment:
   Hello @danny0405, before reverting the change I'd like to ask you to agree 
on the comment with @zabetak since the change was made according to his 
[suggestion](https://github.com/apache/calcite/pull/1610#discussion_r353678039).

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