suibianwanwank commented on code in PR #3897:
URL: https://github.com/apache/calcite/pull/3897#discussion_r1702187341
##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -726,6 +726,31 @@ public SqlNode toSql(@Nullable RexProgram program, RexNode
rex) {
}
}
elseNode = caseNodeList.get(caseNodeList.size() - 1);
+
+ if (caseCall.getType().getSqlTypeName() == SqlTypeName.BOOLEAN
+ && !dialect.supportBooleanCaseWhen()) {
+ // Transformed when expressions of boolean type in SqlCase
+ // For example, given
+ // CASE WHEN x > 1 THEN y > 1 ELSE y < 10 END
+ // Transformed:
+ // CASE WHEN x > 1 THEN CASE WHEN y > 1 THEN 1 ELSE 0 END
+ // ELSE CASE WHEN y < 10 THEN 1 ELSE 0 END END = 1
Review Comment:
What's wrong with this, This guarantees the semantics of the bool expression
Regarding the tests expected in the comments below, Perhaps query1 in the
test fulfills these, and I used true literal in the else expression
--
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]