macroguo-ghy commented on code in PR #3416:
URL: https://github.com/apache/calcite/pull/3416#discussion_r1323207991
##########
core/src/main/java/org/apache/calcite/rex/RexSimplify.java:
##########
@@ -2060,6 +2060,25 @@ private RexNode simplifyOrs(List<RexNode> terms,
RexUnknownAs unknownAs) {
}
}
break;
+ case IS_NOT_TRUE:
+ if (terms.contains(((RexCall) term).getOperands().get(0))) {
+ return trueLiteral;
+ }
+ break;
+ case NOT:
+ RexNode x = ((RexCall) term).getOperands().get(0);
+ if (terms.contains(x)) {
+ if (!x.getType().isNullable()) {
+ return trueLiteral;
+ }
+
+ final RexNode isNotNull =
+ rexBuilder.makeCall(SqlStdOperatorTable.IS_NOT_NULL, x);
+ terms.set(terms.indexOf(x), simplifyIs((RexCall) isNotNull,
unknownAs));
+ terms.set(i, rexBuilder.makeNullLiteral(x.getType()));
+ i--;
Review Comment:
To simplify `null` literal in next for loop.
##########
core/src/main/java/org/apache/calcite/rex/RexSimplify.java:
##########
@@ -2060,6 +2060,25 @@ private RexNode simplifyOrs(List<RexNode> terms,
RexUnknownAs unknownAs) {
}
}
break;
+ case IS_NOT_TRUE:
+ if (terms.contains(((RexCall) term).getOperands().get(0))) {
+ return trueLiteral;
+ }
+ break;
+ case NOT:
+ RexNode x = ((RexCall) term).getOperands().get(0);
+ if (terms.contains(x)) {
Review Comment:
@kgyrtkirk Thanks for your review!
All operands in `OR` operator must be `boolean` type (base on the operand
checker), `x` could be `1 / 0 <> 0` but could not be `1 / 0`. So I think wo
don't need to care about if `x` safe or not. WDYT?
##########
core/src/main/java/org/apache/calcite/rex/RexSimplify.java:
##########
@@ -2060,6 +2060,25 @@ private RexNode simplifyOrs(List<RexNode> terms,
RexUnknownAs unknownAs) {
}
}
break;
+ case IS_NOT_TRUE:
+ if (terms.contains(((RexCall) term).getOperands().get(0))) {
+ return trueLiteral;
Review Comment:
Same viewpoint as my other comment.
--
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]