mihaibudiu commented on code in PR #4353:
URL: https://github.com/apache/calcite/pull/4353#discussion_r2071122589
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlCoalesceFunction.java:
##########
@@ -80,4 +93,40 @@ public SqlCoalesceFunction() {
assert call.getFunctionQuantifier() == null;
return SqlCase.createSwitched(pos, null, whenList, thenList, elseExpr);
}
+
+ @Override @NonNull public RelDataType inferReturnType(
+ SqlOperatorBinding opBinding) {
+ RelDataType returnType =
getReturnTypeInference().inferReturnType(opBinding);
+ if (returnType == null
+ && opBinding instanceof SqlCallBinding
+ && ((SqlCallBinding) opBinding).isTypeCoercionEnabled()) {
+ SqlCallBinding callBinding = (SqlCallBinding) opBinding;
+ List<RelDataType> argTypes = new ArrayList<>();
+ for (SqlNode operand : callBinding.operands()) {
+ RelDataType type = SqlTypeUtil.deriveType(callBinding, operand);
+ argTypes.add(type);
+ }
+ TypeCoercion typeCoercion = callBinding.getValidator().getTypeCoercion();
+ RelDataType commonType = typeCoercion.getWiderTypeFor(argTypes, true);
+ if (null != commonType) {
+ boolean coerced = typeCoercion.caseWhenCoercion(callBinding);
Review Comment:
what we can do is to add a new API caseOrEquivalentCoercion and make the
existing one call this one, and deprecate the existing one
--
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]