mihaibudiu commented on code in PR #4465:
URL: https://github.com/apache/calcite/pull/4465#discussion_r2380468109


##########
core/src/main/java/org/apache/calcite/rel/metadata/RelMdPredicates.java:
##########
@@ -318,12 +318,19 @@ public RelOptPredicateList getPredicates(Filter filter, 
RelMetadataQuery mq) {
     final RelNode input = filter.getInput();
     final RexBuilder rexBuilder = filter.getCluster().getRexBuilder();
     final RelOptPredicateList inputInfo = mq.getPulledUpPredicates(input);
-
+    List<RexNode> predicates =
+        
RexUtil.retainDeterministic(RelOptUtil.conjunctions(filter.getCondition()));
+    RelOptCluster cluster = filter.getCluster();
+    final RexExecutor executor =
+        Util.first(cluster.getPlanner().getExecutor(), RexUtil.EXECUTOR);
+    RexSimplify simplify = new RexSimplify(rexBuilder, 
RelOptPredicateList.EMPTY, executor);
+    // The RelOptPredicateList data structure requires this invariant: no 
comparisons with null
+    List<RexNode> simplified = predicates.stream()

Review Comment:
   Putting this in the Filter constructors is difficult, because these 
constructors need to create a "False" literal, and they have no access to a 
builder or type system.
   
   But it seems to be sufficient to simplify such predicates in 
SqlToRelConverter. It seems that the builder or other simplification operations 
never introduce such conjuncts. I cannot be 100% that one cannot write a 
predicate in SQL, e.g., using disjunctions, which gets simplified into an 
"illegal" one, but none of the tests hits this.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to