Mihai Budiu created CALCITE-7195:
------------------------------------

             Summary: COALESCE type inference rejects legal arguments
                 Key: CALCITE-7195
                 URL: https://issues.apache.org/jira/browse/CALCITE-7195
             Project: Calcite
          Issue Type: Bug
          Components: core
    Affects Versions: 1.40.0
            Reporter: Mihai Budiu


The following test fails in SqlValidatorTest:

{code:java}
    final String sql2 = "select coalesce(NULL, ARRAY[1])";
    sql(sql2)
        .withValidatorCallRewrite(false)
        .ok();
{code}

The top of the stack trace is:

{code}
org.apache.calcite.sql.validate.SqlValidatorException: Parameters must be of 
the same type
        at 
java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)
        at 
java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
        at 
java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:484)
        at 
org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:511)
        at org.apache.calcite.runtime.Resources$ExInst.ex(Resources.java:605)
        at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:960)
        at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:945)
        at 
org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:5960)
        at 
org.apache.calcite.sql.SqlCallBinding.newValidationError(SqlCallBinding.java:421)
        at 
org.apache.calcite.sql.type.SameOperandTypeChecker.checkOperandTypesImpl(SameOperandTypeChecker.java:102)
        at 
org.apache.calcite.sql.type.SameOperandTypeChecker.checkOperandTypes(SameOperandTypeChecker.java:61)
        at 
org.apache.calcite.sql.SqlOperator.checkOperandTypes(SqlOperator.java:784)
{code}

This bug is masked by the fact that in general the validator rewrites COALESCE 
as CASE.




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to