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 2021/12/29 13:42:11 UTC

[GitHub] [shardingsphere] KoKo5858 opened a new issue #14425: java.lang.NullPointerException: null at org.apache.shardingsphere.sharding.merge.dql.orderby.OrderByValue.getOrderValuesCaseSensitiveFromTables

KoKo5858 opened a new issue #14425:
URL: https://github.com/apache/shardingsphere/issues/14425


   使用分片机制,在执行连接查询,模拟查询语句如下:
   select * from T_A a left join T_B B on a.id = B.id
   
   报空指针异常,错误信息如下:
   ```
   ERROR java.lang.Throwable - ANTLR Tool version 4.9.2 used for code generation does not match the current runtime version 4.7.2ANTLR Runtime version 4.9.2 used for parser compilation does not match the current runtime version 4.7.2ANTLR Tool version 4.9.2 used for code generation does not match the current runtime version 4.7.2ANTLR Runtime version 4.9.2 used for parser compilation does not match the current runtime version 4.7.2
   
   java.lang.NullPointerException: null
   	at org.apache.shardingsphere.sharding.merge.dql.orderby.OrderByValue.getOrderValuesCaseSensitiveFromTables(OrderByValue.java:74)
   	at org.apache.shardingsphere.sharding.merge.dql.orderby.OrderByValue.getOrderValuesCaseSensitive(OrderByValue.java:64)
   ```
   报错源码位置:
   ```
   private boolean getOrderValuesCaseSensitiveFromTables(final SelectStatementContext selectStatementContext,final ShardingSphereSchema schema, final OrderByItem eachOrderByItem) throws SQLException {
           for (SimpleTableSegment eachSimpleTableSegment : selectStatementContext.getAllTables()) {
               String tableName = eachSimpleTableSegment.getTableName().getIdentifier().getValue();
               TableMetaData tableMetaData = schema.get(tableName);
               Map<String, ColumnMetaData> columns = tableMetaData.getColumns();//由于tableName不存在导致空指针异常
               OrderByItemSegment orderByItemSegment = eachOrderByItem.getSegment();
   ```
   
   原因分析:
   在执行查询前分片机制会解析语句中使用到哪些表,并获取各表的字段属性。这里我使用到2张表,T_A表和T_B表,但由于我使用的大写的别名,分片机制错误解析成了三张表T_A表、T_B表和B表。(如果小写别名则无该问题)分片机制在获取“B”表的时候,由于该表不存在,导致空指针异常。请教大家一下,这个问题该如何解决?


-- 
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] terrymanu closed issue #14425: java.lang.NullPointerException: null at org.apache.shardingsphere.sharding.merge.dql.orderby.OrderByValue.getOrderValuesCaseSensitiveFromTables

Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #14425:
URL: https://github.com/apache/shardingsphere/issues/14425


   


-- 
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] strongduanmu commented on issue #14425: java.lang.NullPointerException: null at org.apache.shardingsphere.sharding.merge.dql.orderby.OrderByValue.getOrderValuesCaseSensitiveFromTables

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


   Hi @KoKo5858, can you translate this issue to english?


-- 
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