You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by me...@apache.org on 2022/06/06 23:20:19 UTC
[shardingsphere] branch master updated: Rename CombiningXXX to CombineXXX (#18205)
This is an automated email from the ASF dual-hosted git repository.
menghaoran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new ed045a2ff9b Rename CombiningXXX to CombineXXX (#18205)
ed045a2ff9b is described below
commit ed045a2ff9b758c7ed975a571967b4174803b3ce
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Tue Jun 7 07:20:05 2022 +0800
Rename CombiningXXX to CombineXXX (#18205)
---
.../engine/type/ShardingRouteEngineFactory.java | 2 +-
.../statement/dml/SelectStatementContext.java | 8 ++---
.../converter/SQLNodeConverterEngine.java | 24 +++++++--------
.../statement/impl/MySQLStatementSQLVisitor.java | 12 ++++----
.../impl/OpenGaussStatementSQLVisitor.java | 18 +++++------
.../impl/PostgreSQLStatementSQLVisitor.java | 16 +++++-----
.../{CombiningType.java => CombineType.java} | 12 ++++----
.../sql/common/extractor/TableExtractor.java | 4 +--
.../{UnionSegment.java => CombineSegment.java} | 9 ++++--
.../sql/common/statement/dml/SelectStatement.java | 4 +--
.../statement/dml/impl/SelectStatementAssert.java | 22 ++++++-------
.../{ExpectedUnion.java => ExpectedCombine.java} | 8 ++---
.../statement/dml/SelectStatementTestCase.java | 6 ++--
.../src/main/resources/case/dml/select-union.xml | 36 +++++++++++-----------
.../src/main/resources/case/dml/table.xml | 4 +--
15 files changed, 94 insertions(+), 91 deletions(-)
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactory.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactory.java
index 74d62a3ec7f..3ef2c4f450c 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactory.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactory.java
@@ -233,7 +233,7 @@ public final class ShardingRouteEngineFactory {
if (select.getPaginationContext().isHasPagination() || (shardingConditions.isNeedMerge() && shardingConditions.isSameShardingCondition())) {
return false;
}
- if (select.isContainsSubquery() || select.isContainsHaving() || select.isContainsUnion() || select.isContainsPartialDistinctAggregation()) {
+ if (select.isContainsSubquery() || select.isContainsHaving() || select.isContainsCombine() || select.isContainsPartialDistinctAggregation()) {
return true;
}
if (!select.isContainsJoinQuery() || shardingRule.isAllTablesInSameDataSource(tableNames)) {
diff --git a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/SelectStatementContext.java b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/SelectStatementContext.java
index f3c7675156c..69a02e10e52 100644
--- a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/SelectStatementContext.java
+++ b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/SelectStatementContext.java
@@ -167,12 +167,12 @@ public final class SelectStatementContext extends CommonSQLStatementContext<Sele
}
/**
- * Judge whether contains union or not.
+ * Judge whether contains combine or not.
*
- * @return whether contains union or not
+ * @return whether contains combine or not
*/
- public boolean isContainsUnion() {
- return !getSqlStatement().getUnions().isEmpty();
+ public boolean isContainsCombine() {
+ return !getSqlStatement().getCombines().isEmpty();
}
/**
diff --git a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/main/java/org/apache/shardingsphere/infra/federation/optimizer/converter/SQLNodeConverterEngine.java b/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/main/java/org/apache/shardingsphere/infra/federation/optimizer/converter/SQLNodeConverterEngine.java
index f791e5d2e69..138147eb518 100644
--- a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/main/java/org/apache/shardingsphere/infra/federation/optimizer/converter/SQLNodeConverterEngine.java
+++ b/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/main/java/org/apache/shardingsphere/infra/federation/optimizer/converter/SQLNodeConverterEngine.java
@@ -29,8 +29,8 @@ import org.apache.calcite.sql.SqlSelect;
import org.apache.calcite.sql.fun.SqlStdOperatorTable;
import org.apache.calcite.sql.parser.SqlParserPos;
import org.apache.shardingsphere.infra.federation.optimizer.converter.statement.SelectStatementConverter;
-import org.apache.shardingsphere.sql.parser.sql.common.constant.CombiningType;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.union.UnionSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.constant.CombineType;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.union.CombineSegment;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectStatement;
@@ -43,15 +43,15 @@ import java.util.TreeMap;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class SQLNodeConverterEngine {
- private static final Map<CombiningType, SqlOperator> REGISTRY = new TreeMap<>();
+ private static final Map<CombineType, SqlOperator> REGISTRY = new TreeMap<>();
static {
registerUnion();
}
private static void registerUnion() {
- REGISTRY.put(CombiningType.UNION_DISTINCT, SqlStdOperatorTable.UNION);
- REGISTRY.put(CombiningType.UNION_ALL, SqlStdOperatorTable.UNION_ALL);
+ REGISTRY.put(CombineType.UNION, SqlStdOperatorTable.UNION);
+ REGISTRY.put(CombineType.UNION_ALL, SqlStdOperatorTable.UNION_ALL);
}
/**
@@ -63,9 +63,9 @@ public final class SQLNodeConverterEngine {
public static SqlNode convertToSQLNode(final SQLStatement statement) {
if (statement instanceof SelectStatement) {
SqlNode sqlNode = new SelectStatementConverter().convertToSQLNode((SelectStatement) statement);
- for (UnionSegment each : ((SelectStatement) statement).getUnions()) {
+ for (CombineSegment each : ((SelectStatement) statement).getCombines()) {
SqlNode unionSqlNode = convertToSQLNode(each.getSelectStatement());
- return new SqlBasicCall(convertCombiningOperator(each.getCombiningType()), new SqlNode[]{sqlNode, unionSqlNode}, SqlParserPos.ZERO);
+ return new SqlBasicCall(convertCombineOperator(each.getCombineType()), new SqlNode[]{sqlNode, unionSqlNode}, SqlParserPos.ZERO);
}
return sqlNode;
}
@@ -87,15 +87,15 @@ public final class SQLNodeConverterEngine {
SqlNode rightSqlNode = ((SqlBasicCall) sqlNode).getOperandList().get(1);
SelectStatement leftSelectStatement = (SelectStatement) convertToSQLStatement(leftSqlNode);
SelectStatement rightSelectStatement = (SelectStatement) convertToSQLStatement(rightSqlNode);
- leftSelectStatement.getUnions().add(
- new UnionSegment(rightSqlNode.getParserPosition().getColumnNum() - 7, rightSqlNode.getParserPosition().getEndColumnNum() - 1, CombiningType.UNION_DISTINCT, rightSelectStatement));
+ leftSelectStatement.getCombines().add(
+ new CombineSegment(rightSqlNode.getParserPosition().getColumnNum() - 7, rightSqlNode.getParserPosition().getEndColumnNum() - 1, CombineType.UNION, rightSelectStatement));
return leftSelectStatement;
}
throw new UnsupportedOperationException("Unsupported SQL statement conversion.");
}
- private static SqlOperator convertCombiningOperator(final CombiningType combiningType) {
- Preconditions.checkState(REGISTRY.containsKey(combiningType), "Unsupported combining type: `%s`", combiningType);
- return REGISTRY.get(combiningType);
+ private static SqlOperator convertCombineOperator(final CombineType combineType) {
+ Preconditions.checkState(REGISTRY.containsKey(combineType), "Unsupported combine type: `%s`", combineType);
+ return REGISTRY.get(combineType);
}
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLStatementSQLVisitor.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLStatementSQLVisitor.java
index 61303288adc..3df4c546e44 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLStatementSQLVisitor.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLStatementSQLVisitor.java
@@ -136,7 +136,7 @@ import org.apache.shardingsphere.sql.parser.sql.common.constant.AggregationType;
import org.apache.shardingsphere.sql.parser.sql.common.constant.JoinType;
import org.apache.shardingsphere.sql.parser.sql.common.constant.OrderDirection;
import org.apache.shardingsphere.sql.parser.sql.common.constant.ParameterMarkerType;
-import org.apache.shardingsphere.sql.parser.sql.common.constant.CombiningType;
+import org.apache.shardingsphere.sql.parser.sql.common.constant.CombineType;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.constraint.ConstraintSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.index.IndexNameSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.index.IndexSegment;
@@ -183,7 +183,7 @@ import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.pagination.li
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.HavingSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.LockSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.WhereSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.union.UnionSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.union.CombineSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.AliasSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.DataTypeLengthSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.DataTypeSegment;
@@ -683,19 +683,19 @@ public abstract class MySQLStatementSQLVisitor extends MySQLStatementBaseVisitor
}
if (null != ctx.queryExpressionBody()) {
MySQLSelectStatement result = (MySQLSelectStatement) visit(ctx.queryExpressionBody());
- result.getUnions().add((UnionSegment) visitUnionClause(ctx.unionClause()));
+ result.getCombines().add((CombineSegment) visitUnionClause(ctx.unionClause()));
return result;
}
MySQLSelectStatement result = (MySQLSelectStatement) visit(ctx.queryExpressionParens());
- result.getUnions().add((UnionSegment) visitUnionClause(ctx.unionClause()));
+ result.getCombines().add((CombineSegment) visitUnionClause(ctx.unionClause()));
return result;
}
@Override
public ASTNode visitUnionClause(final UnionClauseContext ctx) {
- CombiningType combiningType = (null != ctx.unionOption() && null != ctx.unionOption().ALL()) ? CombiningType.UNION_ALL : CombiningType.UNION_DISTINCT;
+ CombineType combineType = (null != ctx.unionOption() && null != ctx.unionOption().ALL()) ? CombineType.UNION_ALL : CombineType.UNION;
MySQLSelectStatement statement = null != ctx.queryPrimary() ? (MySQLSelectStatement) visit(ctx.queryPrimary()) : (MySQLSelectStatement) visit(ctx.queryExpressionParens());
- return new UnionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), combiningType, statement);
+ return new CombineSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), combineType, statement);
}
@Override
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussStatementSQLVisitor.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussStatementSQLVisitor.java
index 3becfd89e91..2caa6c98601 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussStatementSQLVisitor.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussStatementSQLVisitor.java
@@ -105,7 +105,7 @@ import org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.Win
import org.apache.shardingsphere.sql.parser.sql.common.constant.AggregationType;
import org.apache.shardingsphere.sql.parser.sql.common.constant.OrderDirection;
import org.apache.shardingsphere.sql.parser.sql.common.constant.ParameterMarkerType;
-import org.apache.shardingsphere.sql.parser.sql.common.constant.CombiningType;
+import org.apache.shardingsphere.sql.parser.sql.common.constant.CombineType;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.constraint.ConstraintSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.index.IndexNameSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.index.IndexSegment;
@@ -149,7 +149,7 @@ import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.pagination.li
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.HavingSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.LockSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.WhereSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.union.UnionSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.union.CombineSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.AliasAvailable;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.AliasSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.DataTypeLengthSegment;
@@ -863,25 +863,25 @@ public abstract class OpenGaussStatementSQLVisitor extends OpenGaussStatementBas
}
if (null != ctx.selectClauseN() && !ctx.selectClauseN().isEmpty()) {
OpenGaussSelectStatement result = (OpenGaussSelectStatement) visit(ctx.selectClauseN(0));
- result.getUnions().add(new UnionSegment(
- ((TerminalNode) ctx.getChild(1)).getSymbol().getStartIndex(), ctx.getStop().getStopIndex(), getCombiningType(ctx), (OpenGaussSelectStatement) visit(ctx.selectClauseN(1))));
+ result.getCombines().add(new CombineSegment(
+ ((TerminalNode) ctx.getChild(1)).getSymbol().getStartIndex(), ctx.getStop().getStopIndex(), getCombineType(ctx), (OpenGaussSelectStatement) visit(ctx.selectClauseN(1))));
return result;
}
return visit(ctx.selectWithParens());
}
- private CombiningType getCombiningType(final SelectClauseNContext ctx) {
+ private CombineType getCombineType(final SelectClauseNContext ctx) {
boolean isDistinct = null == ctx.allOrDistinct() || null != ctx.allOrDistinct().DISTINCT();
if (null != ctx.UNION()) {
- return isDistinct ? CombiningType.UNION_DISTINCT : CombiningType.UNION_ALL;
+ return isDistinct ? CombineType.UNION : CombineType.UNION_ALL;
}
if (null != ctx.INTERSECT()) {
- return isDistinct ? CombiningType.INTERSECT_DISTINCT : CombiningType.INTERSECT_ALL;
+ return isDistinct ? CombineType.INTERSECT : CombineType.INTERSECT_ALL;
}
if (null != ctx.MINUS()) {
- return isDistinct ? CombiningType.MINUS_DISTINCT : CombiningType.MINUS_ALL;
+ return isDistinct ? CombineType.MINUS : CombineType.MINUS_ALL;
}
- return isDistinct ? CombiningType.EXCEPT_DISTINCT : CombiningType.EXCEPT_ALL;
+ return isDistinct ? CombineType.EXCEPT : CombineType.EXCEPT_ALL;
}
@Override
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLStatementSQLVisitor.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLStatementSQLVisitor.java
index a0961cc3578..7469ccef81b 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLStatementSQLVisitor.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLStatementSQLVisitor.java
@@ -103,7 +103,7 @@ import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParserBas
import org.apache.shardingsphere.sql.parser.sql.common.constant.AggregationType;
import org.apache.shardingsphere.sql.parser.sql.common.constant.OrderDirection;
import org.apache.shardingsphere.sql.parser.sql.common.constant.ParameterMarkerType;
-import org.apache.shardingsphere.sql.parser.sql.common.constant.CombiningType;
+import org.apache.shardingsphere.sql.parser.sql.common.constant.CombineType;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.constraint.ConstraintSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.index.IndexNameSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.index.IndexSegment;
@@ -146,7 +146,7 @@ import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.pagination.li
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.HavingSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.LockSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.WhereSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.union.UnionSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.union.CombineSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.AliasAvailable;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.AliasSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.DataTypeLengthSegment;
@@ -831,22 +831,22 @@ public abstract class PostgreSQLStatementSQLVisitor extends PostgreSQLStatementP
}
if (null != ctx.selectClauseN() && !ctx.selectClauseN().isEmpty()) {
PostgreSQLSelectStatement result = (PostgreSQLSelectStatement) visit(ctx.selectClauseN(0));
- result.getUnions().add(new UnionSegment(
- ((TerminalNode) ctx.getChild(1)).getSymbol().getStartIndex(), ctx.getStop().getStopIndex(), getCombiningType(ctx), (PostgreSQLSelectStatement) visit(ctx.selectClauseN(1))));
+ result.getCombines().add(new CombineSegment(
+ ((TerminalNode) ctx.getChild(1)).getSymbol().getStartIndex(), ctx.getStop().getStopIndex(), getCombineType(ctx), (PostgreSQLSelectStatement) visit(ctx.selectClauseN(1))));
return result;
}
return visit(ctx.selectWithParens());
}
- private CombiningType getCombiningType(final SelectClauseNContext ctx) {
+ private CombineType getCombineType(final SelectClauseNContext ctx) {
boolean isDistinct = null == ctx.allOrDistinct() || null != ctx.allOrDistinct().DISTINCT();
if (null != ctx.UNION()) {
- return isDistinct ? CombiningType.UNION_DISTINCT : CombiningType.UNION_ALL;
+ return isDistinct ? CombineType.UNION : CombineType.UNION_ALL;
}
if (null != ctx.INTERSECT()) {
- return isDistinct ? CombiningType.INTERSECT_DISTINCT : CombiningType.INTERSECT_ALL;
+ return isDistinct ? CombineType.INTERSECT : CombineType.INTERSECT_ALL;
}
- return isDistinct ? CombiningType.EXCEPT_DISTINCT : CombiningType.EXCEPT_ALL;
+ return isDistinct ? CombineType.EXCEPT : CombineType.EXCEPT_ALL;
}
@Override
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/constant/CombiningType.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/constant/CombineType.java
similarity index 87%
rename from shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/constant/CombiningType.java
rename to shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/constant/CombineType.java
index 858b577eeae..f6d31ed4c7c 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/constant/CombiningType.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/constant/CombineType.java
@@ -18,16 +18,16 @@
package org.apache.shardingsphere.sql.parser.sql.common.constant;
/**
- * Combining type.
+ * Combine type.
*/
-public enum CombiningType {
+public enum CombineType {
UNION_ALL,
- UNION_DISTINCT,
+ UNION,
INTERSECT_ALL,
- INTERSECT_DISTINCT,
+ INTERSECT,
EXCEPT_ALL,
- EXCEPT_DISTINCT,
+ EXCEPT,
MINUS_ALL,
- MINUS_DISTINCT
+ MINUS
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/extractor/TableExtractor.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/extractor/TableExtractor.java
index 7b930e3cb95..5492674678b 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/extractor/TableExtractor.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/extractor/TableExtractor.java
@@ -91,8 +91,8 @@ public final class TableExtractor {
if (SelectStatementHandler.getLockSegment(selectStatement).isPresent()) {
extractTablesFromLock(SelectStatementHandler.getLockSegment(selectStatement).get());
}
- if (!selectStatement.getUnions().isEmpty()) {
- selectStatement.getUnions().forEach(each -> extractTablesFromSelect(each.getSelectStatement()));
+ if (!selectStatement.getCombines().isEmpty()) {
+ selectStatement.getCombines().forEach(each -> extractTablesFromSelect(each.getSelectStatement()));
}
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/union/UnionSegment.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/union/CombineSegment.java
similarity index 90%
rename from shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/union/UnionSegment.java
rename to shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/union/CombineSegment.java
index 172156beae5..f631dfb3f44 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/union/UnionSegment.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/union/CombineSegment.java
@@ -19,19 +19,22 @@ package org.apache.shardingsphere.sql.parser.sql.common.segment.dml.union;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.sql.parser.sql.common.constant.CombiningType;
+import org.apache.shardingsphere.sql.parser.sql.common.constant.CombineType;
import org.apache.shardingsphere.sql.parser.sql.common.segment.SQLSegment;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectStatement;
+/**
+ * Combine segment.
+ */
@RequiredArgsConstructor
@Getter
-public class UnionSegment implements SQLSegment {
+public final class CombineSegment implements SQLSegment {
private final int startIndex;
private final int stopIndex;
- private final CombiningType combiningType;
+ private final CombineType combineType;
private final SelectStatement selectStatement;
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/dml/SelectStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/dml/SelectStatement.java
index 43d619b09bf..00b11e61d53 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/dml/SelectStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/dml/SelectStatement.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.GroupBy
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.OrderBySegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.HavingSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.WhereSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.union.UnionSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.union.CombineSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.TableSegment;
import org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
@@ -53,7 +53,7 @@ public abstract class SelectStatement extends AbstractSQLStatement implements DM
private OrderBySegment orderBy;
- private Collection<UnionSegment> unions = new LinkedList<>();
+ private Collection<CombineSegment> combines = new LinkedList<>();
/**
* Get where.
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/dml/impl/SelectStatementAssert.java b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/dml/impl/SelectStatementAssert.java
index ae7e29aa30d..f627e5bff52 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/dml/impl/SelectStatementAssert.java
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/dml/impl/SelectStatementAssert.java
@@ -21,7 +21,7 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.pagination.limit.LimitSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.LockSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.union.UnionSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.union.CombineSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.ModelSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.WindowSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.WithSegment;
@@ -76,7 +76,7 @@ public final class SelectStatementAssert {
assertTable(assertContext, actual, expected);
assertLockClause(assertContext, actual, expected);
assertWithClause(assertContext, actual, expected);
- assertUnions(assertContext, actual, expected);
+ assertCombines(assertContext, actual, expected);
assertModelClause(assertContext, actual, expected);
}
@@ -181,18 +181,18 @@ public final class SelectStatementAssert {
}
}
- private static void assertUnions(final SQLCaseAssertContext assertContext, final SelectStatement actual, final SelectStatementTestCase expected) {
- if (expected.getUnions().isEmpty()) {
+ private static void assertCombines(final SQLCaseAssertContext assertContext, final SelectStatement actual, final SelectStatementTestCase expected) {
+ if (expected.getCombine().isEmpty()) {
return;
}
- Collection<UnionSegment> unionSegments = actual.getUnions();
- assertFalse(assertContext.getText("Actual union segment should exist."), unionSegments.isEmpty());
- assertThat(assertContext.getText("Union size assertion error: "), unionSegments.size(), is(expected.getUnions().size()));
+ Collection<CombineSegment> combineSegments = actual.getCombines();
+ assertFalse(assertContext.getText("Actual union segment should exist."), combineSegments.isEmpty());
+ assertThat(assertContext.getText("Combine size assertion error: "), combineSegments.size(), is(expected.getCombine().size()));
int count = 0;
- for (UnionSegment each : unionSegments) {
- assertThat(assertContext.getText("Union type assertion error: "), each.getCombiningType().name(), is(expected.getUnions().get(count).getCombiningType()));
- SQLSegmentAssert.assertIs(assertContext, each, expected.getUnions().get(count));
- assertIs(assertContext, each.getSelectStatement(), expected.getUnions().get(count).getSelectClause());
+ for (CombineSegment each : combineSegments) {
+ assertThat(assertContext.getText("Combine type assertion error: "), each.getCombineType().name(), is(expected.getCombine().get(count).getCombineType()));
+ SQLSegmentAssert.assertIs(assertContext, each, expected.getCombine().get(count));
+ assertIs(assertContext, each.getSelectStatement(), expected.getCombine().get(count).getSelectClause());
count++;
}
}
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/segment/impl/union/ExpectedUnion.java b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/segment/impl/union/ExpectedCombine.java
similarity index 89%
rename from shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/segment/impl/union/ExpectedUnion.java
rename to shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/segment/impl/union/ExpectedCombine.java
index a7c25d713e8..5ee130c7255 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/segment/impl/union/ExpectedUnion.java
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/segment/impl/union/ExpectedCombine.java
@@ -26,15 +26,15 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
/**
- * Expected union clause.
+ * Expected combine clause.
*/
@Getter
@Setter
-public final class ExpectedUnion extends AbstractExpectedSQLSegment {
+public final class ExpectedCombine extends AbstractExpectedSQLSegment {
@XmlElement(name = "select")
private SelectStatementTestCase selectClause;
- @XmlAttribute(name = "combining-type")
- private String combiningType;
+ @XmlAttribute(name = "combine-type")
+ private String combineType;
}
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/dml/SelectStatementTestCase.java b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/dml/SelectStatementTestCase.java
index db4d69fbbdb..3754835f898 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/dml/SelectStatementTestCase.java
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/dml/SelectStatementTestCase.java
@@ -27,7 +27,7 @@ import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.projection.ExpectedProjections;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.table.ExpectedSimpleTable;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.table.ExpectedTable;
-import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.union.ExpectedUnion;
+import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.union.ExpectedCombine;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.where.ExpectedWhereClause;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.window.ExpectedWindowClause;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.with.ExpectedWithClause;
@@ -77,8 +77,8 @@ public final class SelectStatementTestCase extends SQLParserTestCase {
@XmlElement(name = "with")
private ExpectedWithClause withClause;
- @XmlElement(name = "union")
- private List<ExpectedUnion> unions = new LinkedList<>();
+ @XmlElement(name = "combine")
+ private List<ExpectedCombine> combine = new LinkedList<>();
@XmlElement(name = "model")
private ExpectedModelClause modelClause;
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dml/select-union.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dml/select-union.xml
index 960e2d8bb77..1a24e3af1af 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dml/select-union.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dml/select-union.xml
@@ -24,7 +24,7 @@
<from>
<simple-table name="table1" start-index="14" stop-index="19" />
</from>
- <union combining-type="UNION_DISTINCT" start-index="21" stop-index="46">
+ <combine combine-type="UNION" start-index="21" stop-index="46">
<select>
<projections start-index="34" stop-index="34">
<shorthand-projection start-index="34" stop-index="34" />
@@ -33,7 +33,7 @@
<simple-table name="table2" start-index="41" stop-index="46" />
</from>
</select>
- </union>
+ </combine>
</select>
<select sql-case-id="select_union">
@@ -43,7 +43,7 @@
<from>
<simple-table name="t_order" start-index="21" stop-index="27" />
</from>
- <union combining-type="UNION_DISTINCT" start-index="29" stop-index="67">
+ <combine combine-type="UNION" start-index="29" stop-index="67">
<select>
<projections start-index="42" stop-index="49">
<column-projection name="order_id" start-index="42" stop-index="49" />
@@ -52,7 +52,7 @@
<simple-table name="t_order_item" start-index="56" stop-index="67" />
</from>
</select>
- </union>
+ </combine>
</select>
<select sql-case-id="select_intersect">
@@ -62,7 +62,7 @@
<from>
<simple-table name="table1" start-index="14" stop-index="19" />
</from>
- <union combining-type="INTERSECT_DISTINCT" start-index="21" stop-index="50">
+ <combine combine-type="INTERSECT" start-index="21" stop-index="50">
<select>
<projections start-index="38" stop-index="38">
<shorthand-projection start-index="38" stop-index="38" />
@@ -71,8 +71,8 @@
<simple-table name="table2" start-index="45" stop-index="50" />
</from>
</select>
- </union>
- <union combining-type="INTERSECT_DISTINCT" start-index="52" stop-index="81">
+ </combine>
+ <combine combine-type="INTERSECT" start-index="52" stop-index="81">
<select>
<projections start-index="69" stop-index="69">
<shorthand-projection start-index="69" stop-index="69" />
@@ -81,7 +81,7 @@
<simple-table name="table3" start-index="76" stop-index="81" />
</from>
</select>
- </union>
+ </combine>
</select>
<select sql-case-id="select_except">
@@ -91,7 +91,7 @@
<from>
<simple-table name="table1" start-index="14" stop-index="19" />
</from>
- <union combining-type="EXCEPT_ALL" start-index="21" stop-index="51">
+ <combine combine-type="EXCEPT_ALL" start-index="21" stop-index="51">
<select>
<projections start-index="39" stop-index="39">
<shorthand-projection start-index="39" stop-index="39" />
@@ -100,8 +100,8 @@
<simple-table name="table2" start-index="46" stop-index="51" />
</from>
</select>
- </union>
- <union combining-type="EXCEPT_ALL" start-index="53" stop-index="83">
+ </combine>
+ <combine combine-type="EXCEPT_ALL" start-index="53" stop-index="83">
<select>
<projections start-index="71" stop-index="71">
<shorthand-projection start-index="71" stop-index="71" />
@@ -110,7 +110,7 @@
<simple-table name="table3" start-index="78" stop-index="83" />
</from>
</select>
- </union>
+ </combine>
</select>
<select sql-case-id="select_minus">
@@ -120,7 +120,7 @@
<from>
<simple-table name="table1" start-index="14" stop-index="19" />
</from>
- <union combining-type="MINUS_DISTINCT" start-index="21" stop-index="46">
+ <combine combine-type="MINUS" start-index="21" stop-index="46">
<select>
<projections start-index="34" stop-index="34">
<shorthand-projection start-index="34" stop-index="34" />
@@ -129,7 +129,7 @@
<simple-table name="table2" start-index="41" stop-index="46" />
</from>
</select>
- </union>
+ </combine>
</select>
<select sql-case-id="select_sub_union">
@@ -139,7 +139,7 @@
<from>
<simple-table name="table1" start-index="14" stop-index="19" />
</from>
- <union combining-type="UNION_DISTINCT" start-index="21" stop-index="75">
+ <combine combine-type="UNION" start-index="21" stop-index="75">
<select>
<projections start-index="35" stop-index="35">
<shorthand-projection start-index="35" stop-index="35" />
@@ -147,7 +147,7 @@
<from>
<simple-table name="table2" start-index="42" stop-index="47" />
</from>
- <union combining-type="UNION_DISTINCT" start-index="49" stop-index="74">
+ <combine combine-type="UNION" start-index="49" stop-index="74">
<select>
<projections start-index="62" stop-index="62">
<shorthand-projection start-index="62" stop-index="62" />
@@ -156,8 +156,8 @@
<simple-table name="table3" start-index="69" stop-index="74" />
</from>
</select>
- </union>
+ </combine>
</select>
- </union>
+ </combine>
</select>
</sql-parser-test-cases>
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dml/table.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dml/table.xml
index 3994534dd14..e21efe15a8d 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dml/table.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dml/table.xml
@@ -30,11 +30,11 @@
<select sql-case-id="table_union">
<simple-table name="T1" start-index="6" stop-index="7" />
- <union combining-type="UNION_DISTINCT" start-index="9" stop-index="22">
+ <combine combine-type="UNION" start-index="9" stop-index="22">
<select>
<simple-table name="T2" start-index="21" stop-index="22" />
</select>
- </union>
+ </combine>
</select>
<select sql-case-id="select_from_with_table">