shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

SS 3.1.0.M1 count sql throw an error,3.1.0 works well

Open a598070240 opened this issue 7 years ago • 1 comments

Bug Report

For English only, other languages will not accept. With the Configration #1653

The sql throw an exception with 3.1.0.M1 and works well with 3.0.0

SELECT COUNT(1) FROM ( 
     SELECT
        r.`channel` as `channel_code`,
        r.`channel_name` as `channel_name`,
        COUNT(r.id) `total_cnt`,
        COUNT(r.connect_flag = "Y") `connected_cnt`
        FROM record_callin r
        LEFT JOIN sys_org_tree_rel tree ON tree.teamid = r.teamid
        LEFT JOIN sys_user u ON u.brokerid = r.brokerid
        where
        r.create_time >= '2018-01-01 00:00:00' and r.create_time <=  '2019-01-01 00:00:00'
        GROUP BY 
        r.`channel` 
) TOTAL

this throws an error:

Caused by: java.lang.IllegalStateException: DQL must have sharding column with subquery.
	at com.google.common.base.Preconditions.checkState(Preconditions.java:444) ~[guava-20.0.jar:na]
	at io.shardingsphere.core.routing.router.sharding.ParsingSQLRouter.checkAndMergeShardingValue(ParsingSQLRouter.java:157) ~[sharding-core-3.1.0.M1.jar:na]
	at io.shardingsphere.core.routing.router.sharding.ParsingSQLRouter.route(ParsingSQLRouter.java:127) ~[sharding-core-3.1.0.M1.jar:na]
	at io.shardingsphere.core.routing.PreparedStatementRoutingEngine.route(PreparedStatementRoutingEngine.java:66) ~[sharding-core-3.1.0.M1.jar:na]
	at io.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.sqlRoute(ShardingPreparedStatement.java:241) ~[sharding-jdbc-core-3.1.0.M1.jar:na]
	at io.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.executeQuery(ShardingPreparedStatement.java:111) ~[sharding-jdbc-core-3.1.0.M1.jar:na]
	at com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor.queryTotal(PaginationInterceptor.java:207) ~[mybatis-plus-extension-3.0.6.jar:3.0.6]
	... 116 common frames omitted

#1653 reason is I used single quote mark with column alias but this issue reason is different

a598070240 avatar Dec 21 '18 08:12 a598070240

sharding table is empty,let it go on

codefairy08 avatar Dec 25 '18 09:12 codefairy08