[
https://issues.apache.org/jira/browse/CALCITE-6976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17946303#comment-17946303
]
Mihai Budiu commented on CALCITE-6976:
--------------------------------------
The type inference is incorrect: ReturnTypes.ARG0_NULLABLE_VARYING, since it
does not assume that an implicit cast may be applied to the first argument.
> Assertion failure while typechecking SUBSTR(TIMESTAMP, ...)
> -----------------------------------------------------------
>
> Key: CALCITE-6976
> URL: https://issues.apache.org/jira/browse/CALCITE-6976
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.39.0
> Reporter: Mihai Budiu
> Priority: Minor
>
> The following SqlOperatorTest will cause an assertion failure:
> {code:java}
> final SqlOperatorFixture f = fixture()
> .withLibrary(SqlLibrary.BIG_QUERY);
> f.checkScalar("SUBSTR(TIMESTAMP '2020-01-01 10:00:00', 10)", "", "VARCHAR
> NOT NULL");
> {code}
> Here is the stack trace:
> {code:java}
> java.lang.AssertionError: Was not expecting value 'TIMESTAMP' for enumeration
> 'org.apache.calcite.sql.type.SqlTypeName' in this context
> at org.apache.calcite.util.Util.unexpected(Util.java:1937)
> at
> org.apache.calcite.sql.type.SqlTypeTransforms$1.toVar(SqlTypeTransforms.java:207)
> at
> org.apache.calcite.sql.type.SqlTypeTransforms$1.transformType(SqlTypeTransforms.java:174)
> at
> org.apache.calcite.sql.type.SqlTypeTransformCascade.inferReturnType(SqlTypeTransformCascade.java:66)
> at
> org.apache.calcite.sql.SqlOperator.inferReturnType(SqlOperator.java:562)
> at
> org.apache.calcite.sql.SqlOperator.validateOperands(SqlOperator.java:531)
> at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:350)
> at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:232)
> at
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:7092)
> at
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:7079)
> at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:175)
> at
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:2028)
> at
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:2015)
> at org.apache.calcite.sql.SqlNode.validateExpr(SqlNode.java:277)
> at org.apache.calcite.sql.SqlOperator.validateCall(SqlOperator.java:503)
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)