You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/03/18 12:23:01 UTC
[GitHub] [incubator-shardingsphere] linyuliang opened a new issue #4830: Exception“Must have sharding column with subquery” when use nonesharding
linyuliang opened a new issue #4830: Exception“Must have sharding column with subquery” when use nonesharding
URL: https://github.com/apache/incubator-shardingsphere/issues/4830
## Bug Report
### Which version of ShardingSphere did you use?
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-jdbc-core</artifactId>
<version>4.0.1</version>
</dependency>
### Which project did you use? Sharding-JDBC or Sharding-Proxy?
Sharding-JDBC
### Expected behavior
sql execute ok, and return the result
### Actual behavior
### SQL: SELECT * from test_user where id = ( select test_user_id from test_user_bind where uid =? and start_time <= now() and end_time > now() order by id desc limit 1 )
### Cause: java.lang.IllegalStateException: Must have sharding column with subquery.
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:149)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:76)
at sun.reflect.GeneratedMethodAccessor910.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426)
... 108 more
Caused by: java.lang.IllegalStateException: Must have sharding column with subquery.
at com.google.common.base.Preconditions.checkState(Preconditions.java:444)
at org.apache.shardingsphere.core.route.router.sharding.ShardingRouter.checkSubqueryShardingValues(ShardingRouter.java:148)
at org.apache.shardingsphere.core.route.router.sharding.ShardingRouter.route(ShardingRouter.java:109)
at org.apache.shardingsphere.core.route.PreparedStatementRoutingEngine.route(PreparedStatementRoutingEngine.java:63)
at org.apache.shardingsphere.core.PreparedQueryShardingEngine.route(PreparedQueryShardingEngine.java:59)
at org.apache.shardingsphere.core.BaseShardingEngine.executeRoute(BaseShardingEngine.java:85)
at org.apache.shardingsphere.core.BaseShardingEngine.shard(BaseShardingEngine.java:68)
at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.shard(ShardingPreparedStatement.java:249)
at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.execute(ShardingPreparedStatement.java:190)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:64)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)
at sun.reflect.GeneratedMethodAccessor825.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63)
at com.sun.proxy.$Proxy202.query(Unknown Source)
at com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.doQuery(MybatisSimpleExecutor.java:67)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
at com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.query(MybatisCachingExecutor.java:163)
at com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.query(MybatisCachingExecutor.java:90)
at sun.reflect.GeneratedMethodAccessor823.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63)
at com.sun.proxy.$Proxy199.query(Unknown Source)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)
... 114 more
### Reason analyze (If you can)
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
dataSources:
ds_user: !!com.mchange.v2.c3p0.ComboPooledDataSource
driverClass: @jdbc.driverClassName@
jdbcUrl: @jdbc.db_user.url@
user: @jdbc.db_user.user@
password: @jdbc.db_user.password@
ds0: !!com.mchange.v2.c3p0.ComboPooledDataSource
driverClass: @jdbc.driverClassName@
jdbcUrl: @jdbc.db0.url@
user: @jdbc.db0.user@
password: @jdbc.db0.password@
ds1: !!com.mchange.v2.c3p0.ComboPooledDataSource
driverClass: @jdbc.driverClassName@
jdbcUrl: @jdbc.db1.url@
user: @jdbc.db1.user@
password: @jdbc.db1.password@
shardingRule:
tables:
zoom_user_bind:
actualDataNodes: ds_user.zoom_user_bind
databaseStrategy:
none: {}
tableStrategy:
none: {}
zoom_user:
actualDataNodes: ds_user.zoom_user
databaseStrategy:
none: {}
tableStrategy:
none: {}
defaultDataSourceName: ds_user
defaultDatabaseStrategy:
none: {}
defaultTableStrategy:
none: {}
props:
sql.show: false
### Example codes for reproduce this issue (such as a github link).
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] terrymanu commented on issue #4830: Exception“Must have sharding column with subquery” when use nonesharding
Posted by GitBox <gi...@apache.org>.
terrymanu commented on issue #4830: Exception“Must have sharding column with subquery” when use nonesharding
URL: https://github.com/apache/incubator-shardingsphere/issues/4830#issuecomment-600604676
Duplicate with #4722
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] terrymanu closed issue #4830: Exception“Must have sharding column with subquery” when use nonesharding
Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #4830: Exception“Must have sharding column with subquery” when use nonesharding
URL: https://github.com/apache/incubator-shardingsphere/issues/4830
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services