jxch-1024 commented on issue #23799: URL: https://github.com/apache/shardingsphere/issues/23799#issuecomment-1407627716
> @jxch-1024 I checked the grammar file in the master branch, it supports aliases, you can try the latest version 5.3.1 > > <img alt="image" width="1354" src="https://user-images.githubusercontent.com/5668787/215319310-9be41aa2-a52d-4618-a292-42f802381895.png"> The error is not reported when antlr parses the syntax tree, but when sharding merges the result set. The stack is as follows: Exception in thread "main" java.lang.IllegalStateException: Can't find index: AggregationProjection(type=COUNT, innerExpression=(1), alias=Optional.empty, databaseType=org.apache.shardingsphere.infra.database.type.dialect.SQLServerDatabaseType@126f8f24, derivedAggregationProjections=[], index=-1), please add alias for aggregate selections at com.google.common.base.Preconditions.checkState(Preconditions.java:589) at org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext.setIndexForAggregationProjection(SelectStatementContext.java:230) at org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext.setIndexes(SelectStatementContext.java:222) at org.apache.shardingsphere.sharding.merge.dql.ShardingDQLResultMerger.merge(ShardingDQLResultMerger.java:63) at org.apache.shardingsphere.infra.merge.MergeEngine.executeMerge(MergeEngine.java:78) at org.apache.shardingsphere.infra.merge.MergeEngine.merge(MergeEngine.java:67) at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.mergeQuery(ShardingSpherePreparedStatement.java:487) at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.executeQuery(ShardingSpherePreparedStatement.java:218) at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:722) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:651) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:713) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:744) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:757) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:810) at org.springframework.jdbc.core.JdbcTemplate.queryForList(JdbcTemplate.java:942) at com.luhui.shardingjdbc.demo.MainTest.main(MainTest.java:33) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
