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/12/25 04:21:56 UTC
[GitHub] [shardingsphere] tristaZero opened a new issue #8772: IndexOutOfBoundsException When executes `Group by` SQL
tristaZero opened a new issue #8772:
URL: https://github.com/apache/shardingsphere/issues/8772
### Which version of ShardingSphere did you use?
ShardingSphere-Proxy master branch
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
1. Start Proxy with sharding.yaml
2. Run SQL `select sum(user_id) from t_order group by order_id order by order_id limit 2;`
3. Exception occurred as below.
```
[INFO ] 2020-12-25 11:42:50.807 [ShardingSphere-Command-5] ShardingSphere-SQL - Logic SQL: select sum(user_id) from t_order group by order_id order by order_id limit 2
[INFO ] 2020-12-25 11:42:50.807 [ShardingSphere-Command-5] ShardingSphere-SQL - SQLStatement: MySQLSelectStatement(limit=Optional[org.apache.shardingsphere.sql.parser.sql.common.segment.dml.pagination.limit.LimitSegment@405d10c5], lock=Optional.empty)
[INFO ] 2020-12-25 11:42:50.807 [ShardingSphere-Command-5] ShardingSphere-SQL - Actual SQL: ds_0 ::: select sum(user_id) , order_id AS GROUP_BY_DERIVED_0 from t_order_0 group by order_id order by order_id limit 2
[INFO ] 2020-12-25 11:42:50.807 [ShardingSphere-Command-5] ShardingSphere-SQL - Actual SQL: ds_0 ::: select sum(user_id) , order_id AS GROUP_BY_DERIVED_0 from t_order_1 group by order_id order by order_id limit 2
[INFO ] 2020-12-25 11:42:50.807 [ShardingSphere-Command-5] ShardingSphere-SQL - Actual SQL: ds_1 ::: select sum(user_id) , order_id AS GROUP_BY_DERIVED_0 from t_order_0 group by order_id order by order_id limit 2
[INFO ] 2020-12-25 11:42:50.807 [ShardingSphere-Command-5] ShardingSphere-SQL - Actual SQL: ds_1 ::: select sum(user_id) , order_id AS GROUP_BY_DERIVED_0 from t_order_1 group by order_id order by order_id limit 2
[ERROR] 2020-12-25 11:43:28.888 [ShardingSphere-Command-5] o.a.s.p.f.c.CommandExecutorTask - Exception occur:
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.rangeCheck(ArrayList.java:657)
at java.util.ArrayList.get(ArrayList.java:433)
at org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeaderBuilder.getColumnName(QueryHeaderBuilder.java:93)
at org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeaderBuilder.build(QueryHeaderBuilder.java:63)
at org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.createQueryHeader(DatabaseCommunicationEngine.java:157)
at org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.createQueryHeaders(DatabaseCommunicationEngine.java:149)
at org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.processExecuteQuery(DatabaseCommunicationEngine.java:140)
at org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.execute(DatabaseCommunicationEngine.java:116)
at org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.execute(DatabaseCommunicationEngine.java:104)
at org.apache.shardingsphere.proxy.backend.text.data.impl.SchemaAssignedDatabaseBackendHandler.execute(SchemaAssignedDatabaseBackendHandler.java:55)
at org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:57)
at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:100)
at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:76)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
```
### Reason analyze (If you can)
Incorrect index calculation for the `derived projection`, FYI.
<img width="1220" alt="WX20201225-114525@2x" src="https://user-images.githubusercontent.com/27757146/103117859-52595100-46a7-11eb-8f94-5a45f9d7d744.png">
### Others
The following familiar SQLs failed as well.
```sql
select avg(user_id) v1 from t_order group by order_id order by avg(user_id) limit 2;
select avg(user_id) from t_order group by order_id order by order_id limit 2;
select sum(user_id) from t_order group by order_id order by order_id limit 2;
```
----------------------------------------------------------------
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
[GitHub] [shardingsphere] menghaoranss closed issue #8772: IndexOutOfBoundsException When executes `Group by` SQL
Posted by GitBox <gi...@apache.org>.
menghaoranss closed issue #8772:
URL: https://github.com/apache/shardingsphere/issues/8772
----------------------------------------------------------------
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