suibianwanwank commented on code in PR #3897:
URL: https://github.com/apache/calcite/pull/3897#discussion_r1702602324
##########
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:
good idea, i have added this part about parentheses.
In Oracle, would there be a difference between then and else expression
statements, also in the default implementation of calcite this would throw the
error "Illegal mixing of types in CASE or COALESCE statement"
--
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]