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


##########
core/src/main/java/org/apache/calcite/sql/fun/SqlCoalesceFunction.java:
##########
@@ -80,4 +88,30 @@ public SqlCoalesceFunction() {
     assert call.getFunctionQuantifier() == null;
     return SqlCase.createSwitched(pos, null, whenList, thenList, elseExpr);
   }
+
+  @Override public RelDataType inferReturnType(

Review Comment:
   you are missing some `@Nullable` annotations



##########
core/src/main/java/org/apache/calcite/sql/validate/implicit/TypeCoercion.java:
##########
@@ -134,6 +134,14 @@ boolean rowTypeCoercion(
    */
   boolean caseWhenCoercion(SqlCallBinding binding);
 
+  /**
+   * Coerces COALESCE statement to one common type.
+   *
+   * <p>Rules: Find common type for all the operands,

Review Comment:
   The rules should not be specified here, they are really up to the type 
system, i.e., implementations of this API.
   Since the validator assumes that COALESCE can be translated to a CASE, this 
requires some consistency between `caseWhenCoercion` and `coalesceCoercion`. In 
an ideal world, you would not need this function, and you could just call 
`caseWhenCoercion` to perform the coercion, but I don't know if that's possible.



##########
core/src/main/java/org/apache/calcite/sql/SqlOperator.java:
##########
@@ -556,10 +556,28 @@ protected void preValidateCall(SqlValidator validator,
    * {@link SqlCall})
    * @return inferred return type
    */
-  public RelDataType inferReturnType(
-      SqlOperatorBinding opBinding) {
+  public RelDataType inferReturnType(SqlOperatorBinding opBinding) {

Review Comment:
   are these changes really necessary?
   why can't coalesce just override this function?



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