Lordeath opened a new issue #6910:
URL: https://github.com/apache/shardingsphere/issues/6910
exception was thrown when i excute this SQL:
`select a.XXX from ( select '1' as 'XXX' from dual ) a
where a.XXX = 1
`
Its just an example, my bussiness situation is something like this
### this worked in 4.0.1 but not in 4.1.1
the exception message is: Can not find owner from table.
I read the document, and I found this should be supported, so this might be
a BUG.
[https://shardingsphere.apache.org/document/current/cn/features/sharding/use-norms/sql/
](https://shardingsphere.apache.org/document/current/cn/features/sharding/use-norms/sql/
)`SELECT subquery_alias.col1 FROM (select tbl_name.col1 from tbl_name where
tbl_name.col2=?) subquery_alias
`
here is the error trace:
```
### The error occurred while setting parameters
### SQL: select a.XXX from ( select '1' as 'XXX' from dual
) a where a.XXX = 1
### Cause: java.lang.IllegalStateException: Can not find owner from table.
at
org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at
org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:434)
... 27 common frames omitted
Caused by: java.lang.IllegalStateException: Can not find owner from table.
at
org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext.findTableNameFromSQL(TablesContext.java:96)
at
org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext.findTableName(TablesContext.java:68)
at
org.apache.shardingsphere.sharding.route.engine.condition.engine.WhereClauseShardingConditionEngine.createRouteValueMap(WhereClauseShardingConditionEngine.java:101)
at
org.apache.shardingsphere.sharding.route.engine.condition.engine.WhereClauseShardingConditionEngine.createShardingConditions(WhereClauseShardingConditionEngine.java:89)
at
org.apache.shardingsphere.sharding.route.engine.condition.engine.WhereClauseShardingConditionEngine.createShardingConditions(WhereClauseShardingConditionEngine.java:73)
at
org.apache.shardingsphere.sharding.route.engine.ShardingRouteDecorator.getShardingConditions(ShardingRouteDecorator.java:82)
at
org.apache.shardingsphere.sharding.route.engine.ShardingRouteDecorator.decorate(ShardingRouteDecorator.java:62)
at
org.apache.shardingsphere.sharding.route.engine.ShardingRouteDecorator.decorate(ShardingRouteDecorator.java:53)
at
org.apache.shardingsphere.underlying.route.DataNodeRouter.executeRoute(DataNodeRouter.java:91)
at
org.apache.shardingsphere.underlying.route.DataNodeRouter.route(DataNodeRouter.java:76)
at
org.apache.shardingsphere.underlying.pluggble.prepare.PreparedQueryPrepareEngine.route(PreparedQueryPrepareEngine.java:54)
at
org.apache.shardingsphere.underlying.pluggble.prepare.BasePrepareEngine.executeRoute(BasePrepareEngine.java:96)
at
org.apache.shardingsphere.underlying.pluggble.prepare.BasePrepareEngine.prepare(BasePrepareEngine.java:83)
at
org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.prepare(ShardingPreparedStatement.java:183)
at
org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.execute(ShardingPreparedStatement.java:143)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at
org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59)
at com.sun.proxy.$Proxy142.execute(Unknown Source)
at
org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:63)
at
org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)
at
org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63)
at
org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
at
org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
at
org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
... 33 common frames omitted
```
----------------------------------------------------------------
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:
[email protected]