[ 
https://issues.apache.org/jira/browse/CALCITE-7094?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mihai Budiu resolved CALCITE-7094.
----------------------------------
    Fix Version/s: 1.41.0
       Resolution: Fixed

Fixed by 
[https://github.com/apache/calcite/commit/c437a9bbe6fe858efab146581c24cc89671408ef]
Thank you for your discussion and comments [~jensen]

> Using a type alias as a constructor function causes a validator assertion 
> failure
> ---------------------------------------------------------------------------------
>
>                 Key: CALCITE-7094
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7094
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.40.0
>            Reporter: Mihai Budiu
>            Assignee: Mihai Budiu
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 1.41.0
>
>
> Consider BigQuery: it supports an INT64 type, which is an alias for BIGINT.
> This can be described by installing INT64 in the schema:
> {code:java}
>                   ConnectionFactories.addType("INT64", typeFactory ->
>                       typeFactory.createSqlType(SqlTypeName.BIGINT))
> {code}
> Now, if you try to use (incorrectly) such a type using a constructor syntax:
> {code:sql}
> SELECT int64(0)
> {code}
> the validator crashes with an assertion failure:
> {code}
> java.lang.AssertionError: fieldList must not be null, type = BIGINT
>       at 
> org.apache.calcite.rel.type.RelDataTypeImpl.getFieldCount(RelDataTypeImpl.java:207)
>       at 
> org.apache.calcite.sql.type.ExplicitOperandTypeChecker.getOperandCountRange(ExplicitOperandTypeChecker.java:65)
>       at 
> org.apache.calcite.sql.SqlOperator.getOperandCountRange(SqlOperator.java:231)
>       at 
> org.apache.calcite.sql.SqlOperator.checkOperandCount(SqlOperator.java:793)
>       at 
> org.apache.calcite.sql.SqlOperator.validateOperands(SqlOperator.java:522)
>       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:7028)
>       at 
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:7015)
>       at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:175)
>       at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1962)
>       at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1949)
>       at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:513)
>       at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:5076)
>       at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:4068)
> {code}
> This seems to be because the validator assumes that any constructor type is 
> for a ROW type. In this case the validator should provide an error message 
> and not crash.



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

Reply via email to