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 2022/07/25 15:44:12 UTC

[GitHub] [shardingsphere] Glowdable opened a new issue, #19535: throw java.lang.NullPointerException if I use multi-level nested join

Glowdable opened a new issue, #19535:
URL: https://github.com/apache/shardingsphere/issues/19535

   ## Bug Report
   
   I got below error when I use a multi-level nested join, like this 
   
   ```
   select order_item_2019.* from order_item_2019 
   inner join 
   (select id  from (select min(id) as id from order_item_2019 where user_id = 12345678 and order_status = 0) t1 
   union (select id from (select min(id) as id from order_item_2019 where abc_user_id = 12345678  and order_status = 0) t2) tmp 
   on order_item_2019.id = tmp.id order by id asc limit 1
   ```
   
   It should be noted that  'order_item_2019 is not a shard table, just single table.
   
   
   System error - Throwable org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: Error preparing statement.  Cause: java.lang.NullPointerException
   	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:92)
   	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440)
   	at com.sun.proxy.$Proxy377.selectOne(Unknown Source)
   	at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:159)
   	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:87)
   	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:93)
   	at com.sun.proxy.$Proxy434.selectOrderByUserId(Unknown Source)
   	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:750)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
   	at org.springframework.cache.interceptor.CacheInterceptor.lambda$invoke$0(CacheInterceptor.java:53)
   	at org.springframework.cache.interceptor.CacheAspectSupport.invokeOperation(CacheAspectSupport.java:365)
   	at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:420)
   	at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:345)
   	at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
   	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)
   	at java.base/java.lang.Thread.run(Thread.java:829)
   Caused by: org.apache.ibatis.executor.ExecutorException: Error preparing statement.  Cause: java.lang.NullPointerException
   	at org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:97)
   	at org.apache.ibatis.executor.statement.RoutingStatementHandler.prepare(RoutingStatementHandler.java:59)
   	at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:87)
   	at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
   	at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324)
   	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:147)
   	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
   	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:76)
   	at jdk.internal.reflect.GeneratedMethodAccessor755.invoke(Unknown Source)
   	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
   	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426)
   Caused by: java.lang.NullPointerException
   	at org.apache.shardingsphere.infra.binder.segment.select.subquery.engine.SubqueryTableContextEngine.createSubqueryTableContexts(SubqueryTableContextEngine.java:43)
   	at org.apache.shardingsphere.infra.binder.segment.table.TablesContext.createSubqueryTables(TablesContext.java:99)
   	at org.apache.shardingsphere.infra.binder.segment.table.TablesContext.<init>(TablesContext.java:86)
   	at org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext.<init>(SelectStatementContext.java:110)
   	at org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext.createSubqueryContexts(SelectStatementContext.java:124)
   	at org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext.<init>(SelectStatementContext.java:109)
   	at org.apache.shardingsphere.infra.binder.SQLStatementContextFactory.getDMLStatementContext(SQLStatementContextFactory.java:146)
   	at org.apache.shardingsphere.infra.binder.SQLStatementContextFactory.newInstance(SQLStatementContextFactory.java:129)
   	at org.apache.shardingsphere.infra.binder.SQLStatementContextFactory.newInstance(SQLStatementContextFactory.java:114)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.<init>(ShardingSpherePreparedStatement.java:181)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.<init>(ShardingSpherePreparedStatement.java:149)
   	at org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection.prepareStatement(ShardingSphereConnection.java:80)
   	at jdk.internal.reflect.GeneratedMethodAccessor745.invoke(Unknown Source)
   	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
   	at org.apache.ibatis.logging.jdbc.ConnectionLogger.invoke(ConnectionLogger.java:55)
   	at com.sun.proxy.$Proxy236.prepareStatement(Unknown Source)
   	at org.apache.ibatis.executor.statement.PreparedStatementHandler.instantiateStatement(PreparedStatementHandler.java:86)
   	at org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:88)
   
   ### Which version of ShardingSphere did you use?
   5.1.1
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   
   ### Expected behavior
   No NullPointerException
   
   ### Actual behavior
   throw NullPointerException
   
   ### Reason analyze (If you can)
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
   ```
   select order_item_2019.* from order_item_2019 
   inner join 
   (select id  from (select min(id) as id from order_item_2019 where user_id = 12345678 and order_status = 0) t1 
   union (select id from (select min(id) as id from order_item_2019 where abc_user_id = 12345678  and order_status = 0) t2) tmp 
   on order_item_2019.id = tmp.id order by id asc limit 1
   ```
   
   Execute above sql with mybatis.  You will get NullPointerException.'order_item_2019' is not shard table, just single table.
   
   
   ### 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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] RaigorJiang closed issue #19535: throw java.lang.NullPointerException if I use multi-level nested join for single table

Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang closed issue #19535: throw java.lang.NullPointerException if I use multi-level nested join for single table
URL: https://github.com/apache/shardingsphere/issues/19535


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] linghengqian commented on issue #19535: throw java.lang.NullPointerException if I use multi-level nested join for single table

Posted by GitBox <gi...@apache.org>.
linghengqian commented on issue #19535:
URL: https://github.com/apache/shardingsphere/issues/19535#issuecomment-1195737651

   - Formatting the log in markdown will make it readable, the log is too long.
   
   - Is it normal if you switch `order_item_2019.*` to more specific fields?  Subquery joins are being handled in a SQL Federation related issue.  This issue is a duplicate of https://github.com/apache/shardingsphere/issues/8284 .


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] RaigorJiang commented on issue #19535: throw java.lang.NullPointerException if I use multi-level nested join for single table

Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang commented on issue #19535:
URL: https://github.com/apache/shardingsphere/issues/19535#issuecomment-1407637200

   As @linghengqian said, please enable federation to try.
   
   Considering this issue has been inactive for a long time, and ShardingSphere has released several new versions, so I will close it.
   Please try the latest version, and if the problem reproduces, please reopen it or submit a new one.
   
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] github-actions[bot] commented on issue #19535: throw java.lang.NullPointerException if I use multi-level nested join for single table

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on issue #19535:
URL: https://github.com/apache/shardingsphere/issues/19535#issuecomment-1272349228

   Hello , this issue has not received a reply for several days.
   This issue is supposed to be closed.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] github-actions[bot] closed issue #19535: throw java.lang.NullPointerException if I use multi-level nested join for single table

Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed issue #19535: throw java.lang.NullPointerException if I use multi-level nested join for single table
URL: https://github.com/apache/shardingsphere/issues/19535


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org