mihaibudiu commented on code in PR #4353:
URL: https://github.com/apache/calcite/pull/4353#discussion_r2072653910
##########
core/src/main/java/org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.java:
##########
@@ -422,6 +439,34 @@ protected boolean booleanEquality(SqlCallBinding binding,
return false;
}
+ /**
+ * COALESCE type coercion, collect all the branches types to find a common
type,
+ * then cast the operands to the common type when needed.
+ */
+ private boolean coalesceCoercion(SqlCallBinding callBinding) {
+ List<RelDataType> argTypes = new ArrayList<>();
+ SqlValidatorScope scope = getScope(callBinding);
+ for (SqlNode node : callBinding.operands()) {
+ argTypes.add(validator.deriveType(scope, node));
+ }
+ RelDataType widerType = getWiderTypeFor(argTypes, true);
+ if (null != widerType) {
+ return coerceOperandsType(scope, callBinding.getCall(), widerType);
+ }
+ return false;
+ }
+
+ /**
+ * NULLIF type coercion, cast the second operand type to the first operand
type when needed.
Review Comment:
it would also be nice to have a test for this diagram, but it won't be
trivial to write.
--
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]