You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2020/09/01 17:24:00 UTC

[jira] [Commented] (CALCITE-4207) Validation fails for positional aggregate with current_date in 'case' expression

    [ https://issues.apache.org/jira/browse/CALCITE-4207?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17188690#comment-17188690 ] 

Julian Hyde commented on CALCITE-4207:
--------------------------------------

Are you sure that you have enabled positional aggregates (i.e. {{GROUP BY 1}})?

> Validation fails for positional aggregate with current_date in 'case' expression
> --------------------------------------------------------------------------------
>
>                 Key: CALCITE-4207
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4207
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: Igor Guzenko
>            Priority: Major
>
> *Steps to reproduce: *
>  Add test to SqlValidatorTest.java
> {code:java}
>   @Test void testPositionalAggregateWithExpandedCurrentDateFunction() {
>     sql("SELECT "
>         + "CASE WHEN HIREDATE >= CURRENT_DATE "
>         + "THEN 'Forward' "
>         + "ELSE 'Actual' END AS fa,"
>         + "COUNT(*) "
>         + "FROM EMP "
>         + "GROUP BY 1").ok();
>   }
> {code}
> *Expected result*
> Validation passed successfully.
> *Actual result*
> {code:none}org.apache.calcite.sql.validate.SqlValidatorException: Expression 'HIREDATE' is not being grouped
> 	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> 	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
> 	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> 	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
> 	at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:467)
> 	at org.apache.calcite.runtime.Resources$ExInst.ex(Resources.java:560)
> 	at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:883)
> 	at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:868)
> 	at org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:5003)
> 	at org.apache.calcite.sql.validate.AggChecker.visit(AggChecker.java:113)
> 	at org.apache.calcite.sql.validate.AggChecker.visit(AggChecker.java:40)
> 	at org.apache.calcite.sql.SqlIdentifier.accept(SqlIdentifier.java:321)
> 	at org.apache.calcite.sql.util.SqlBasicVisitor$ArgHandlerImpl.visitChild(SqlBasicVisitor.java:123)
> 	at org.apache.calcite.sql.SqlOperator.acceptCall(SqlOperator.java:879)
> 	at org.apache.calcite.sql.validate.AggChecker.visit(AggChecker.java:212)
> 	at org.apache.calcite.sql.validate.AggChecker.visit(AggChecker.java:40)
> 	at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:139)
> 	at org.apache.calcite.sql.util.SqlBasicVisitor.visit(SqlBasicVisitor.java:52)
> 	at org.apache.calcite.sql.SqlNodeList.accept(SqlNodeList.java:145)
> 	at org.apache.calcite.sql.util.SqlBasicVisitor$ArgHandlerImpl.visitChild(SqlBasicVisitor.java:123)
> 	at org.apache.calcite.sql.SqlOperator.acceptCall(SqlOperator.java:879)
> 	at org.apache.calcite.sql.validate.AggChecker.visit(AggChecker.java:212)
> 	at org.apache.calcite.sql.validate.AggChecker.visit(AggChecker.java:40)
> 	at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:139)
> 	at org.apache.calcite.sql.util.SqlBasicVisitor$ArgHandlerImpl.visitChild(SqlBasicVisitor.java:123)
> 	at org.apache.calcite.sql.SqlAsOperator.acceptCall(SqlAsOperator.java:121)
> 	at org.apache.calcite.sql.validate.AggChecker.visit(AggChecker.java:212)
> 	at org.apache.calcite.sql.validate.AggChecker.visit(AggChecker.java:40)
> 	at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:139)
> 	at org.apache.calcite.sql.validate.AggregatingSelectScope.checkAggregateExpr(AggregatingSelectScope.java:212)
> 	at org.apache.calcite.sql.validate.AggregatingSelectScope.validateExpr(AggregatingSelectScope.java:221)
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)