xuzifu666 commented on code in PR #5295:
URL: https://github.com/apache/calcite/pull/5295#discussion_r4124102342
##########
core/src/main/java/org/apache/calcite/rex/RexSimplify.java:
##########
@@ -2013,11 +2013,13 @@ private <C extends Comparable<C>> RexNode
simplifyAnd2ForUnknownAsFalse(
// Simplify BOOLEAN expressions if possible
while (term.getKind() == SqlKind.EQUALS) {
RexCall call = (RexCall) term;
- if (call.getOperands().get(0).isAlwaysTrue()) {
+ if (call.getOperands().get(0).isAlwaysTrue()
+ && call.getOperands().get(1).getType().getSqlTypeName() ==
SqlTypeName.BOOLEAN) {
Review Comment:
Thanks for the suggestion @julianhyde . `isAlwaysTrue` / `isAlwaysFalse` are
already defensive: both `RexLiteral` and `RexCall` return false unless the
expression has BOOLEAN type, so the string literal 'true' already returns
false.The call-site check guards the other operand (the one that would replace
the =` term), so it can't be pushed intoisAlwaysTrue. Without it,AND(=(x,
TRUE), ...)with VARCHARxwould simplify toAND(x, ...) which is the CALCITE-5907
bug. Please correct me if I am wrong~
--
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]