kgyrtkirk commented on code in PR #3279:
URL: https://github.com/apache/calcite/pull/3279#discussion_r1241723952
##########
core/src/main/java/org/apache/calcite/plan/RelOptPredicateList.java:
##########
@@ -236,14 +236,18 @@ public boolean isEffectivelyNotNull(RexNode e) {
}
}
if (SqlKind.COMPARISON.contains(e.getKind())) {
- // A comparison with a (non-null) literal, such as 'ref < 10', is not
null if 'ref'
- // is not null.
+ // A comparison with a (non-null) literal, such as 'ref < 10', or '10 <
ref',
+ // is not null if 'ref' is not null.
List<RexNode> operands = ((RexCall) e).getOperands();
// We can have just one operand in case e.g. of a RexSubQuery with IN
operator.
if (operands.size() > 1 && operands.get(1) instanceof RexLiteral
&& !((RexLiteral) operands.get(1)).isNull()) {
return isEffectivelyNotNull(operands.get(0));
}
+ if (operands.size() > 1 && operands.get(0) instanceof RexLiteral
+ && !((RexLiteral) operands.get(0)).isNull()) {
+ return isEffectivelyNotNull(operands.get(1));
+ }
Review Comment:
I wonder if it would make sense to instead of this:
* push those `RexLiteral` related stuff as part of `isEffectivelyNotNull`
somewhere at the beginning
* replace this block with something like:
```
for(int i=0;i<operands.size();i++) {
if(!isEffectivelyNotNull(operands.get(0)) {
return false;
}
}
return true;
```
so that it will handle `x > y is not true` ; in case `x` and `y` is known to
be not null
--
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]