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/10/28 12:19:10 UTC

[GitHub] [shardingsphere] lomoc opened a new issue #7948: Not support union in subquery

lomoc opened a new issue #7948:
URL: https://github.com/apache/shardingsphere/issues/7948


   ## Bug Report
   
   **For English only**, other languages will not accept.
   
   Before report a bug, make sure you have:
   
   - Searched open and closed [GitHub issues](https://github.com/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   Please pay attention on issues you submitted, because we maybe need more details. 
   If no response anymore and we cannot reproduce it on current information, we will **close it**.
   
   Please answer these questions before submitting your issue. Thanks!
   
   ### Which version of ShardingSphere did you use?
   5.0.0-RC1
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC 
   
   ### Expected behavior
   the SQL listed below should be parsed correctly
   
   ### Actual behavior
   Got ParseCancellationException
   
   ### Reason analyze (If you can)
   It seems union in subquery is not supported.
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
   run the following SQL:
           select count(*)
           from (
                    SELECT id
                    FROM t_table1
                    UNION
                    SELECT id
                    FROM t_table2
                ) t
   
   line 6:17 no viable alternative at input 'selectcount(*)from(SELECTidFROMt_table1UNIONSELECT'
   line 6:17 no viable alternative at input 'selectcount(*)from(SELECTidFROMt_table1UNIONSELECT'
   
   
   org.antlr.v4.runtime.misc.ParseCancellationException
   	at org.antlr.v4.runtime.BailErrorStrategy.recover(BailErrorStrategy.java:51)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.selectNoParens(PostgreSQLStatementParser.java:2926)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.select(PostgreSQLStatementParser.java:2645)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.execute(PostgreSQLStatementParser.java:837)
   	at org.apache.shardingsphere.sql.parser.postgresql.parser.PostgreSQLParser.parse(PostgreSQLParser.java:37)
   	at org.apache.shardingsphere.sql.parser.core.parser.SQLParserExecutor.twoPhaseParse(SQLParserExecutor.java:63)
   	at org.apache.shardingsphere.sql.parser.core.parser.SQLParserExecutor.execute(SQLParserExecutor.java:46)
   	at org.apache.shardingsphere.sql.parser.engine.StandardSQLParserEngine.parse0(StandardSQLParserEngine.java:72)
   	at org.apache.shardingsphere.sql.parser.engine.StandardSQLParserEngine.parse(StandardSQLParserEngine.java:54)
   	at com.yongfan.datasec.ShardingTests.testSql(ShardingTests.java:19)
   	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.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675)
   	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
   	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125)
   	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:132)
   	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:124)
   	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:74)
   	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
   	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
   	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:104)
   	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:62)
   	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:43)
   	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:35)
   	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
   	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
   	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:202)
   	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
   	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:198)
   	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135)
   	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135)
   	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
   	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
   	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
   	at java.util.ArrayList.forEach(ArrayList.java:1257)
   	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
   	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
   	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
   	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
   	at java.util.ArrayList.forEach(ArrayList.java:1257)
   	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
   	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
   	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
   	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
   	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
   	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
   	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
   	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
   	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:229)
   	at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:197)
   	at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:211)
   	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:191)
   	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
   	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
   	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
   	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
   	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
   Caused by: org.antlr.v4.runtime.NoViableAltException
   	at org.antlr.v4.runtime.atn.ParserATNSimulator.noViableAlt(ParserATNSimulator.java:2026)
   	at org.antlr.v4.runtime.atn.ParserATNSimulator.execATN(ParserATNSimulator.java:467)
   	at org.antlr.v4.runtime.atn.ParserATNSimulator.adaptivePredict(ParserATNSimulator.java:393)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.selectNoParens(PostgreSQLStatementParser.java:2764)
   	... 71 more
   
   
   
   ### Example codes for reproduce this issue (such as a github link).
   
   public class ShardingTests {
       @Test
       void testSql() {
           String sql = "        select count(*)\n" +
                   "        from (\n" +
                   "                 SELECT id\n" +
                   "                 FROM t_table1\n" +
                   "                 UNION\n" +
                   "                 SELECT id\n" +
                   "                 FROM t_table2\n" +
                   "             ) t\n";
   
           StandardSQLParserEngine standardSQLParserEngine = new StandardSQLParserEngine("PostgreSQL");
           standardSQLParserEngine.parse(sql, true);
       }
   
   }
   
   


----------------------------------------------------------------
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] Fish-Potato commented on issue #7948: Not support union in subquery for PostgreSQL

Posted by GitBox <gi...@apache.org>.
Fish-Potato commented on issue #7948:
URL: https://github.com/apache/shardingsphere/issues/7948#issuecomment-722296072


   Mysql subqueries not support union either
   version 5.0.0-RC1


----------------------------------------------------------------
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] Fish-Potato edited a comment on issue #7948: Not support union in subquery for PostgreSQL

Posted by GitBox <gi...@apache.org>.
Fish-Potato edited a comment on issue #7948:
URL: https://github.com/apache/shardingsphere/issues/7948#issuecomment-722296072


   Mysql subqueries not support union either
   version 5.0.0-RC1
   @terrymanu @jingshanglu 


----------------------------------------------------------------
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] tristaZero commented on issue #7948: Not support union in subquery for PostgreSQL

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


   @Fish-Potato Indeed, we will consider supporting it in the future.


----------------------------------------------------------------
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] lomoc commented on issue #7948: Not support union in subquery for PostgreSQL

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


   Great, thanks!


----------------------------------------------------------------
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] tristaZero closed issue #7948: Not support union in subquery for PostgreSQL

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


   


----------------------------------------------------------------
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] avalon5666 commented on issue #7948: Not support union in subquery for PostgreSQL

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


   Not supported yet


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