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

ASF GitHub Bot updated CALCITE-5653:
------------------------------------
    Labels: pull-request-available  (was: )

> expended casts are missing when IdentifierExpansion is false
> ------------------------------------------------------------
>
>                 Key: CALCITE-5653
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5653
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Itiel Sadeh
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> When casts are added in {{{}SqlValidator{}}}, they are not part of the select 
> if the configuration option {{identifierExpansion}} is false. This will cause 
> the following issue
> {code:java}
> SELECT distinct sum(deptno + '1') FROM dept ORDER BY 1
> {code}
> will lead to:
> {code:java}
> From line 1, column 21 to line 1, column 54: Expression 'SUM(`DEPT`.`DEPTNO` 
> + CAST('1' AS INTEGER))' is not in the select clause
> org.apache.calcite.runtime.CalciteContextException: From line 1, column 21 to 
> line 1, column 54: Expression 'SUM(`DEPT`.`DEPTNO` + CAST('1' AS INTEGER))' 
> is not in the select clause
>     at 
> [email protected]/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>  Method)
>     at 
> [email protected]/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
>     at 
> [email protected]/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>     at 
> [email protected]/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
>     at 
> [email protected]/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
>     at 
> app//org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:505)
>     at 
> app//org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:945)
>     at 
> app//org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:930)
>     at 
> app//org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:5464)
>     at 
> app//org.apache.calcite.sql.validate.AggChecker.visit(AggChecker.java:168)
>     at 
> app//org.apache.calcite.sql.validate.AggChecker.visit(AggChecker.java:45)
>     at app//org.apache.calcite.sql.SqlCall.accept(SqlCall.java:161)
>     at 
> app//org.apache.calcite.sql.validate.AggregatingSelectScope.checkAggregateExpr(AggregatingSelectScope.java:233)
>     at 
> app//org.apache.calcite.sql.validate.AggregatingSelectScope.validateExpr(AggregatingSelectScope.java:242)
>     at 
> app//org.apache.calcite.sql.validate.OrderByScope.validateExpr(OrderByScope.java:128)
>     at 
> app//org.apache.calcite.sql.validate.SqlValidatorImpl.validateExpr(SqlValidatorImpl.java:4676)
>     at 
> app//org.apache.calcite.sql.validate.SqlValidatorImpl.validateOrderItem(SqlValidatorImpl.java:4398)
>     at 
> app//org.apache.calcite.sql.validate.SqlValidatorImpl.validateOrderList(SqlValidatorImpl.java:4341)
>     at 
> app//org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3786)
>     at 
> app//org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:61)
>     at 
> app//org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:88)
>     at 
> app//org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1135)
>     at 
> app//org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:1106)
>     at app//org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:282)
>     at 
> app//org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:1081)
>     at 
> app//org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:787)
>  {code}
> The issue is that the code in{{ AggChecker}} will search for the expanded 
> node (with the CAST) in the select list, but the select list contains only 
> the unexpanded node. 
> This can be solved through setting{{ identifierExpansion }}to true, but I 
> don't think it should be related, as it's not an identifier expansion here.



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

Reply via email to