This commit is contained in:
高铁
2021-10-03 02:13:10 +08:00
parent 91e1592d9d
commit 6a2123cbe3
2 changed files with 31 additions and 5 deletions
@@ -1077,11 +1077,11 @@ public class SQLSelectParser extends SQLParser {
|| lexer.token == Token.SEL) {
SQLSelect select = select();
accept(Token.RPAREN);
if (select.getQuery() instanceof SQLSelectQueryBlock) {
((SQLSelectQueryBlock) select.getQuery()).setParenthesized(true);
}
SQLSelectQuery selectQuery = select.getQuery();
selectQuery.setParenthesized(true);
SQLSelectQuery query = queryRest(select.getQuery(), true);
boolean acceptUnion = !(selectQuery instanceof SQLUnionQuery);
SQLSelectQuery query = queryRest(selectQuery, acceptUnion);
if (query instanceof SQLUnionQuery) {
tableSource = new SQLUnionQueryTableSource((SQLUnionQuery) query);
} else {
+27 -1
View File
@@ -13,4 +13,30 @@ from (
union
select id, collectId, c2
from (select id, collectId, c2 from table_2)
)
)
---------------------------
SELECT *
FROM (
SELECT id, collectId, 3 AS c_0
FROM (
SELECT *
FROM tc_merchant
WHERE collectId IN (
SELECT collect_id
FROM cte_merchant
)
UNION
SELECT *
FROM st_merchant
WHERE collectId IN (
SELECT collect_id
FROM st_merchant_tmp
)
)
UNION
SELECT id, collectId, c2
FROM (
SELECT id, collectId, c2
FROM table_2
)
)