julianhyde commented on a change in pull request #2105:
URL: https://github.com/apache/calcite/pull/2105#discussion_r474877330
##########
File path: core/src/main/java/org/apache/calcite/plan/RelOptPredicateList.java
##########
@@ -180,4 +203,27 @@ public RelOptPredicateList shift(RexBuilder rexBuilder,
int offset) {
RexUtil.shift(leftInferredPredicates, offset),
RexUtil.shift(rightInferredPredicates, offset));
}
+
+ /** Returns whether an expression is effectively NOT NULL due to an
+ * {@code e IS NOT NULL} condition in this predicate list. */
+ public boolean isEffectivelyNotNull(RexNode e) {
+ if (!e.getType().isNullable()) {
+ return true;
+ }
+ for (RexNode p : pulledUpPredicates) {
+ if (p.getKind() == SqlKind.IS_NOT_NULL
+ && ((RexCall) p).getOperands().get(0).equals(e)) {
+ return true;
+ }
+ }
+ if (SqlKind.COMPARISON.contains(e.getKind())) {
+ // A comparison with a literal, such as 'ref < 10', is not null if 'ref'
+ // is not null.
+ RexCall call = (RexCall) e;
+ if (call.getOperands().get(1) instanceof RexLiteral) {
+ return isEffectivelyNotNull(call.getOperands().get(0));
Review comment:
I missed this comment. I'll address during CALCITE-4173.
----------------------------------------------------------------
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]