[ https://issues.apache.org/jira/browse/CALCITE-4207?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Igor Guzenko updated CALCITE-4207: ---------------------------------- Description: *Steps to reproduce: * Add test to SqlValidatorTest.java {code:java} @Test void testPositionalAggregateWithExpandedCurrentDateFunction() { SqlConformance defaultPlusOrdinalGroupBy = new SqlDelegatingConformance(SqlConformanceEnum.DEFAULT) { @Override public boolean isGroupByOrdinal() { return true; } }; sql("SELECT HIREDATE >= CURRENT_DATE, COUNT(*) " + "FROM EMP GROUP BY 1") .withConformance(defaultPlusOrdinalGroupBy) .ok(); } {code} *Expected result* Validation passed successfully. *Actual result* {code:none}org.apache.calcite.sql.validate.SqlValidatorException: Expression 'EMP.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) {code} was: *Steps to reproduce: * Add test to SqlValidatorTest.java {code:java} @Test void testPositionalAggregateWithExpandedCurrentDateFunction() { SqlConformance defaultPlusOrdinalGroupBy = new SqlDelegatingConformance(SqlConformanceEnum.DEFAULT) { @Override public boolean isGroupByOrdinal() { return true; } }; sql("SELECT " + "CASE WHEN HIREDATE >= CURRENT_DATE " + "THEN 'Forward' " + "ELSE 'Actual' END AS fa," + "COUNT(*) " + "FROM EMP " + "GROUP BY 1") .withConformance(defaultPlusOrdinalGroupBy) .ok(); } {code} *Expected result* Validation passed successfully. *Actual result* {code:none}org.apache.calcite.sql.validate.SqlValidatorException: Expression 'EMP.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) {code} > 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 > Assignee: Igor Guzenko > Priority: Major > Labels: pull-request-available > Time Spent: 10m > Remaining Estimate: 0h > > *Steps to reproduce: * > Add test to SqlValidatorTest.java > {code:java} > @Test void testPositionalAggregateWithExpandedCurrentDateFunction() { > SqlConformance defaultPlusOrdinalGroupBy = > new SqlDelegatingConformance(SqlConformanceEnum.DEFAULT) { > @Override public boolean isGroupByOrdinal() { > return true; > } > }; > sql("SELECT HIREDATE >= CURRENT_DATE, COUNT(*) " > + "FROM EMP GROUP BY 1") > .withConformance(defaultPlusOrdinalGroupBy) > .ok(); > } > {code} > *Expected result* > Validation passed successfully. > *Actual result* > {code:none}org.apache.calcite.sql.validate.SqlValidatorException: Expression > 'EMP.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) > > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)