juntaozhang commented on code in PR #4353:
URL: https://github.com/apache/calcite/pull/4353#discussion_r2071186848


##########
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:
   Done, thank you for your suggestion.



-- 
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]

Reply via email to