This is an automated email from the ASF dual-hosted git repository.

chengzhang 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 d8909ceec47 Remove useless parameter in ShardingRule to fix sonar 
issue (#34145)
d8909ceec47 is described below

commit d8909ceec47b99739d68df69801e0f979783a532
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Wed Dec 25 08:14:57 2024 +0800

    Remove useless parameter in ShardingRule to fix sonar issue (#34145)
    
    * Remove useless parameter in ShardingRule to fix sonar issue
    
    * fix sonar issue in ColumnDefinitionSegmentBinder and ShardingRuleTest
---
 .../checker/ShardingRouteCacheableChecker.java     |  2 +-
 .../sql/common/ShardingSupportedCommonChecker.java |  2 +-
 .../sql/ddl/ShardingAlterViewSupportedChecker.java |  2 +-
 .../sql/dml/ShardingInsertSupportedChecker.java    |  2 +-
 .../sql/util/ShardingSupportedCheckUtils.java      |  2 +-
 .../decider/ShardingSQLFederationDecider.java      |  9 ++--
 .../impl/ShardingTableTokenGenerator.java          |  2 +-
 .../engine/type/ShardingRouteEngineFactory.java    |  9 ++--
 .../ShardingTableBroadcastRouteEngine.java         |  2 +-
 .../shardingsphere/sharding/rule/ShardingRule.java | 46 ++++++++------------
 .../ShardingCreateViewSupportedCheckerTest.java    |  2 +-
 .../decider/ShardingSQLFederationDeciderTest.java  |  4 +-
 .../impl/ShardingTableTokenGeneratorTest.java      |  2 +-
 .../sharding/rule/ShardingRuleTest.java            | 49 ++++++++--------------
 .../column/ColumnDefinitionSegmentBinder.java      |  2 +-
 15 files changed, 56 insertions(+), 81 deletions(-)

diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/cache/checker/ShardingRouteCacheableChecker.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/cache/checker/ShardingRouteCacheableChecker.java
index 67b6160b7dd..e1af887254f 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/cache/checker/ShardingRouteCacheableChecker.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/cache/checker/ShardingRouteCacheableChecker.java
@@ -105,7 +105,7 @@ public final class ShardingRouteCacheableChecker {
         if (!shardingRule.isAllShardingTables(tableNames)) {
             return new ShardingRouteCacheableCheckResult(false, 
Collections.emptyList());
         }
-        if (1 != tableNames.size() && 
!shardingRule.isAllBindingTables(tableNames) || 
containsNonCacheableShardingAlgorithm(tableNames)) {
+        if (1 != tableNames.size() && 
!shardingRule.isAllConfigBindingTables(tableNames) || 
containsNonCacheableShardingAlgorithm(tableNames)) {
             return new ShardingRouteCacheableCheckResult(false, 
Collections.emptyList());
         }
         List<ShardingCondition> shardingConditions = new 
WhereClauseShardingConditionEngine(shardingRule, 
timestampServiceRule).createShardingConditions(statementContext, params);
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/common/ShardingSupportedCommonChecker.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/common/ShardingSupportedCommonChecker.java
index d3e527f0472..ed876d0f822 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/common/ShardingSupportedCommonChecker.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/common/ShardingSupportedCommonChecker.java
@@ -89,7 +89,7 @@ public final class ShardingSupportedCommonChecker {
      */
     public static void checkMultipleTable(final ShardingRule shardingRule, 
final SQLStatementContext sqlStatementContext) {
         Collection<String> tableNames = ((TableAvailable) 
sqlStatementContext).getTablesContext().getTableNames();
-        boolean isAllShardingTables = 
shardingRule.isAllShardingTables(tableNames) && (1 == tableNames.size() || 
shardingRule.isAllBindingTables(tableNames));
+        boolean isAllShardingTables = 
shardingRule.isAllShardingTables(tableNames) && (1 == tableNames.size() || 
shardingRule.isAllConfigBindingTables(tableNames));
         boolean isAllSingleTables = 
!shardingRule.containsShardingTable(tableNames);
         ShardingSpherePreconditions.checkState(isAllShardingTables || 
isAllSingleTables, () -> new 
DMLWithMultipleShardingTablesException(tableNames));
     }
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterViewSupportedChecker.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterViewSupportedChecker.java
index 285b369a8f3..81ade5d0cb6 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterViewSupportedChecker.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterViewSupportedChecker.java
@@ -62,6 +62,6 @@ public final class ShardingAlterViewSupportedChecker 
implements SupportedSQLChec
     
     private void checkBroadcastShardingView(final ShardingRule shardingRule, 
final String originView, final String targetView) {
         
ShardingSpherePreconditions.checkState(!shardingRule.isShardingTable(originView)
 && !shardingRule.isShardingTable(targetView)
-                || shardingRule.isAllBindingTables(Arrays.asList(originView, 
targetView)), () -> new 
RenamedViewWithoutSameConfigurationException(originView, targetView));
+                || 
shardingRule.isAllConfigBindingTables(Arrays.asList(originView, targetView)), 
() -> new RenamedViewWithoutSameConfigurationException(originView, targetView));
     }
 }
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingInsertSupportedChecker.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingInsertSupportedChecker.java
index 38f821a21ec..507b9b219fe 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingInsertSupportedChecker.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingInsertSupportedChecker.java
@@ -61,7 +61,7 @@ public final class ShardingInsertSupportedChecker implements 
SupportedSQLChecker
             throw new MissingGenerateKeyColumnWithInsertSelectException();
         }
         TablesContext tablesContext = sqlStatementContext.getTablesContext();
-        if (rule.containsShardingTable(tablesContext.getTableNames()) && 
!isAllSameTables(tablesContext.getTableNames()) && 
!rule.isAllBindingTables(tablesContext.getTableNames())) {
+        if (rule.containsShardingTable(tablesContext.getTableNames()) && 
!isAllSameTables(tablesContext.getTableNames()) && 
!rule.isAllConfigBindingTables(tablesContext.getTableNames())) {
             throw new InsertSelectTableViolationException();
         }
     }
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/util/ShardingSupportedCheckUtils.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/util/ShardingSupportedCheckUtils.java
index d3a6123c356..9c5abb288c5 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/util/ShardingSupportedCheckUtils.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/util/ShardingSupportedCheckUtils.java
@@ -56,7 +56,7 @@ public final class ShardingSupportedCheckUtils {
     public static boolean isShardingTablesNotBindingWithView(final 
Collection<SimpleTableSegment> tableSegments, final ShardingRule shardingRule, 
final String viewName) {
         for (SimpleTableSegment each : tableSegments) {
             String logicTable = each.getTableName().getIdentifier().getValue();
-            if (shardingRule.isShardingTable(logicTable) && 
!shardingRule.isAllBindingTables(Arrays.asList(viewName, logicTable))) {
+            if (shardingRule.isShardingTable(logicTable) && 
!shardingRule.isAllConfigBindingTables(Arrays.asList(viewName, logicTable))) {
                 return true;
             }
         }
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDecider.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDecider.java
index 9f7e6ad6126..d83c7ca15c3 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDecider.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDecider.java
@@ -52,15 +52,14 @@ public final class ShardingSQLFederationDecider implements 
SQLFederationDecider<
         if (!selectStatementContext.isContainsJoinQuery() || 
rule.isAllTablesInSameDataSource(tableNames)) {
             return false;
         }
-        if (isSelfJoinWithoutShardingColumn(selectStatementContext, rule, 
database, tableNames)) {
+        if (isSelfJoinWithoutShardingColumn(selectStatementContext, rule, 
tableNames)) {
             return true;
         }
-        return tableNames.size() > 1 && !rule.isAllBindingTables(database, 
selectStatementContext, tableNames);
+        return tableNames.size() > 1 && 
!rule.isBindingTablesUseShardingColumnsJoin(selectStatementContext, tableNames);
     }
     
-    private boolean isSelfJoinWithoutShardingColumn(final 
SelectStatementContext selectStatementContext,
-                                                    final ShardingRule rule, 
final ShardingSphereDatabase database, final Collection<String> tableNames) {
-        return 1 == tableNames.size() && 
selectStatementContext.isContainsJoinQuery() && 
!rule.isAllBindingTables(database, selectStatementContext, tableNames);
+    private boolean isSelfJoinWithoutShardingColumn(final 
SelectStatementContext selectStatementContext, final ShardingRule rule, final 
Collection<String> tableNames) {
+        return 1 == tableNames.size() && 
selectStatementContext.isContainsJoinQuery() && 
!rule.isBindingTablesUseShardingColumnsJoin(selectStatementContext, tableNames);
     }
     
     private Collection<DataNode> getTableDataNodes(final ShardingRule rule, 
final ShardingSphereDatabase database, final Collection<String> tableNames) {
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingTableTokenGenerator.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingTableTokenGenerator.java
index e870b627b8f..d9e5c90405d 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingTableTokenGenerator.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingTableTokenGenerator.java
@@ -57,7 +57,7 @@ public final class ShardingTableTokenGenerator implements 
CollectionSQLTokenGene
         Collection<String> shardingLogicTableNames = sqlStatementContext 
instanceof TableAvailable
                 ? rule.getShardingLogicTableNames(((TableAvailable) 
sqlStatementContext).getTablesContext().getTableNames())
                 : Collections.emptyList();
-        return shardingLogicTableNames.size() > 1 && 
rule.isAllBindingTables(shardingLogicTableNames);
+        return shardingLogicTableNames.size() > 1 && 
rule.isAllConfigBindingTables(shardingLogicTableNames);
     }
     
     @Override
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactory.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactory.java
index 98ac6ea8447..49de41137a3 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactory.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactory.java
@@ -98,7 +98,7 @@ public final class ShardingRouteEngineFactory {
     private static ShardingRouteEngine getCursorRouteEngine(final ShardingRule 
rule, final ShardingSphereDatabase database, final SQLStatementContext 
sqlStatementContext,
                                                             final 
HintValueContext hintValueContext, final ShardingConditions shardingConditions, 
final Collection<String> logicTableNames,
                                                             final 
ConfigurationProperties props) {
-        boolean allBindingTables = logicTableNames.size() > 1 && 
rule.isAllBindingTables(database, sqlStatementContext, logicTableNames);
+        boolean allBindingTables = logicTableNames.size() > 1 && 
rule.isBindingTablesUseShardingColumnsJoin(sqlStatementContext, 
logicTableNames);
         if (isShardingStandardQuery(rule, logicTableNames, allBindingTables)) {
             return new 
ShardingStandardRouteEngine(getLogicTableName(shardingConditions, 
logicTableNames), shardingConditions, sqlStatementContext, hintValueContext, 
props);
         }
@@ -135,13 +135,12 @@ public final class ShardingRouteEngineFactory {
         if (sqlStatementContext.getSqlStatement() instanceof DMLStatement && 
shardingConditions.isAlwaysFalse() || tableNames.isEmpty()) {
             return new ShardingUnicastRouteEngine(sqlStatementContext, 
tableNames, queryContext.getConnectionContext());
         }
-        return getDQLRouteEngineForShardingTable(rule, database, 
sqlStatementContext, queryContext.getHintValueContext(), shardingConditions, 
logicTableNames, props);
+        return getDQLRouteEngineForShardingTable(rule, sqlStatementContext, 
queryContext.getHintValueContext(), shardingConditions, logicTableNames, props);
     }
     
-    private static ShardingRouteEngine getDQLRouteEngineForShardingTable(final 
ShardingRule rule, final ShardingSphereDatabase database,
-                                                                         final 
SQLStatementContext sqlStatementContext, final HintValueContext 
hintValueContext,
+    private static ShardingRouteEngine getDQLRouteEngineForShardingTable(final 
ShardingRule rule, final SQLStatementContext sqlStatementContext, final 
HintValueContext hintValueContext,
                                                                          final 
ShardingConditions shardingConditions, final Collection<String> 
logicTableNames, final ConfigurationProperties props) {
-        boolean allBindingTables = logicTableNames.size() > 1 && 
rule.isAllBindingTables(database, sqlStatementContext, logicTableNames);
+        boolean allBindingTables = logicTableNames.size() > 1 && 
rule.isBindingTablesUseShardingColumnsJoin(sqlStatementContext, 
logicTableNames);
         if (isShardingStandardQuery(rule, logicTableNames, allBindingTables)) {
             return new 
ShardingStandardRouteEngine(getLogicTableName(shardingConditions, 
logicTableNames), shardingConditions, sqlStatementContext, hintValueContext, 
props);
         }
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingTableBroadcastRouteEngine.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingTableBroadcastRouteEngine.java
index 7b45827866d..87ae103f229 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingTableBroadcastRouteEngine.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingTableBroadcastRouteEngine.java
@@ -59,7 +59,7 @@ public final class ShardingTableBroadcastRouteEngine 
implements ShardingRouteEng
             
result.getRouteUnits().addAll(getBroadcastTableRouteUnits(shardingRule, ""));
             return result;
         }
-        if (logicTableNames.size() > 1 && 
shardingRule.isAllBindingTables(logicTableNames)) {
+        if (logicTableNames.size() > 1 && 
shardingRule.isAllConfigBindingTables(logicTableNames)) {
             
result.getRouteUnits().addAll(getBindingTableRouteUnits(shardingRule, 
logicTableNames));
         } else {
             Collection<RouteContext> routeContexts = 
getRouteContexts(shardingRule, logicTableNames);
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
index 6c3e63386ea..63300dfc59b 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
@@ -18,6 +18,7 @@
 package org.apache.shardingsphere.sharding.rule;
 
 import com.cedarsoftware.util.CaseInsensitiveMap;
+import com.cedarsoftware.util.CaseInsensitiveSet;
 import com.google.common.base.Splitter;
 import com.google.common.base.Strings;
 import lombok.Getter;
@@ -26,16 +27,13 @@ import 
org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitial
 import 
org.apache.shardingsphere.infra.algorithm.keygen.core.KeyGenerateAlgorithm;
 import 
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
 import 
org.apache.shardingsphere.infra.binder.context.statement.dml.SelectStatementContext;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeRegistry;
 import org.apache.shardingsphere.infra.datanode.DataNode;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
 import org.apache.shardingsphere.infra.instance.ComputeNodeInstanceContext;
 import 
org.apache.shardingsphere.infra.instance.ComputeNodeInstanceContextAware;
-import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.metadata.database.resource.PhysicalDataSourceAggregator;
 import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
-import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
 import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.infra.rule.attribute.RuleAttributes;
 import 
org.apache.shardingsphere.infra.rule.attribute.datasource.aggregate.AggregatedDataSourceRuleAttribute;
@@ -320,12 +318,12 @@ public final class ShardingRule implements DatabaseRule {
     }
     
     /**
-     * Judge whether logic table is all binding tables or not.
+     * Judge whether logic table is all config binding tables or not.
      *
      * @param logicTableNames logic table names
-     * @return whether logic table is all binding tables or not
+     * @return whether logic table is all config binding tables or not
      */
-    public boolean isAllBindingTables(final Collection<String> 
logicTableNames) {
+    public boolean isAllConfigBindingTables(final Collection<String> 
logicTableNames) {
         if (logicTableNames.isEmpty()) {
             return false;
         }
@@ -339,25 +337,21 @@ public final class ShardingRule implements DatabaseRule {
     }
     
     /**
-     * Judge whether logic table is all binding tables.
+     * Judge whether logic table is all config binding tables and use sharding 
columns join.
      *
-     * @param database database
      * @param sqlStatementContext sqlStatementContext
      * @param logicTableNames logic table names
-     * @return whether logic table is all binding tables
+     * @return whether logic table is all config binding tables and use 
sharding columns join
      */
-    // TODO rename the method name, add sharding condition judgement in method 
name @duanzhengqiang
-    public boolean isAllBindingTables(final ShardingSphereDatabase database, 
final SQLStatementContext sqlStatementContext, final Collection<String> 
logicTableNames) {
+    public boolean isBindingTablesUseShardingColumnsJoin(final 
SQLStatementContext sqlStatementContext, final Collection<String> 
logicTableNames) {
         if (!(sqlStatementContext instanceof SelectStatementContext && 
((SelectStatementContext) sqlStatementContext).isContainsJoinQuery())) {
-            return isAllBindingTables(logicTableNames);
+            return isAllConfigBindingTables(logicTableNames);
         }
-        if (!isAllBindingTables(logicTableNames)) {
+        if (!isAllConfigBindingTables(logicTableNames)) {
             return false;
         }
-        String defaultSchemaName = new 
DatabaseTypeRegistry(sqlStatementContext.getDatabaseType()).getDefaultSchemaName(database.getName());
         SelectStatementContext select = (SelectStatementContext) 
sqlStatementContext;
-        ShardingSphereSchema schema = 
select.getTablesContext().getSchemaName().map(database::getSchema).orElseGet(() 
-> database.getSchema(defaultSchemaName));
-        return isJoinConditionContainsShardingColumns(schema, select, 
logicTableNames, select.getWhereSegments());
+        return isJoinConditionContainsShardingColumns(logicTableNames, 
select.getWhereSegments());
     }
     
     private Optional<BindingTableRule> findBindingTableRule(final 
Collection<String> logicTableNames) {
@@ -575,10 +569,9 @@ public final class ShardingRule implements DatabaseRule {
         return null != shardingCache;
     }
     
-    private boolean isJoinConditionContainsShardingColumns(final 
ShardingSphereSchema schema, final SelectStatementContext select,
-                                                           final 
Collection<String> tableNames, final Collection<WhereSegment> whereSegments) {
-        Collection<String> databaseJoinConditionTables = new 
HashSet<>(tableNames.size(), 1F);
-        Collection<String> tableJoinConditionTables = new 
HashSet<>(tableNames.size(), 1F);
+    private boolean isJoinConditionContainsShardingColumns(final 
Collection<String> tableNames, final Collection<WhereSegment> whereSegments) {
+        Collection<String> databaseJoinConditionTables = new 
CaseInsensitiveSet<>(tableNames.size(), 1F);
+        Collection<String> tableJoinConditionTables = new 
CaseInsensitiveSet<>(tableNames.size(), 1F);
         for (WhereSegment each : whereSegments) {
             Collection<AndPredicate> andPredicates = 
ExpressionExtractor.extractAndPredicates(each.getExpr());
             if (andPredicates.size() > 1) {
@@ -610,14 +603,11 @@ public final class ShardingRule implements DatabaseRule {
             if (!leftShardingTable.isPresent() || 
!rightShardingTable.isPresent()) {
                 continue;
             }
-            ShardingStrategyConfiguration leftConfig = isDatabaseJoinCondition
-                    ? 
getDatabaseShardingStrategyConfiguration(leftShardingTable.get())
-                    : 
getTableShardingStrategyConfiguration(leftShardingTable.get());
-            ShardingStrategyConfiguration rightConfig = isDatabaseJoinCondition
-                    ? 
getDatabaseShardingStrategyConfiguration(rightShardingTable.get())
-                    : 
getTableShardingStrategyConfiguration(rightShardingTable.get());
-            if (findShardingColumn(leftConfig, 
leftColumn.getIdentifier().getValue()).isPresent()
-                    && findShardingColumn(rightConfig, 
rightColumn.getIdentifier().getValue()).isPresent()) {
+            ShardingStrategyConfiguration leftConfig =
+                    isDatabaseJoinCondition ? 
getDatabaseShardingStrategyConfiguration(leftShardingTable.get()) : 
getTableShardingStrategyConfiguration(leftShardingTable.get());
+            ShardingStrategyConfiguration rightConfig =
+                    isDatabaseJoinCondition ? 
getDatabaseShardingStrategyConfiguration(rightShardingTable.get()) : 
getTableShardingStrategyConfiguration(rightShardingTable.get());
+            if (findShardingColumn(leftConfig, 
leftColumn.getIdentifier().getValue()).isPresent() && 
findShardingColumn(rightConfig, 
rightColumn.getIdentifier().getValue()).isPresent()) {
                 
result.add(leftColumn.getColumnBoundInfo().getOriginalTable().getValue());
                 
result.add(rightColumn.getColumnBoundInfo().getOriginalTable().getValue());
             }
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateViewSupportedCheckerTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateViewSupportedCheckerTest.java
index e4a2f33984d..c0a83a3a4ea 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateViewSupportedCheckerTest.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateViewSupportedCheckerTest.java
@@ -79,7 +79,7 @@ class ShardingCreateViewSupportedCheckerTest {
     @Test
     void assertCheckWithException() {
         when(rule.isShardingTable(any())).thenReturn(true);
-        when(rule.isAllBindingTables(any())).thenReturn(false);
+        when(rule.isAllConfigBindingTables(any())).thenReturn(false);
         assertThrows(EngagedViewException.class, () -> new 
ShardingCreateViewSupportedChecker().check(rule, mock(), mock(), 
createViewStatementContext));
     }
 }
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDeciderTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDeciderTest.java
index 2cd9d471b2f..95aae4e8798 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDeciderTest.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDeciderTest.java
@@ -161,7 +161,7 @@ class ShardingSQLFederationDeciderTest {
         ShardingRule rule = createShardingRule();
         
when(rule.getShardingLogicTableNames(Collections.singleton("foo_tbl"))).thenReturn(Collections.singleton("foo_tbl"));
         ShardingSphereDatabase database = createDatabase(rule);
-        when(rule.isAllBindingTables(database, sqlStatementContext, 
Collections.singleton("foo_tbl"))).thenReturn(true);
+        when(rule.isBindingTablesUseShardingColumnsJoin(sqlStatementContext, 
Collections.singleton("foo_tbl"))).thenReturn(true);
         Collection<DataNode> includedDataNodes = new HashSet<>();
         assertFalse(decider.decide(sqlStatementContext, 
Collections.emptyList(), mock(RuleMetaData.class), database, rule, 
includedDataNodes));
         assertThat(includedDataNodes.size(), is(2));
@@ -173,7 +173,7 @@ class ShardingSQLFederationDeciderTest {
         when(sqlStatementContext.isContainsJoinQuery()).thenReturn(true);
         ShardingRule rule = createShardingRule();
         ShardingSphereDatabase database = createDatabase(rule);
-        when(rule.isAllBindingTables(database, sqlStatementContext, 
Arrays.asList("foo_tbl", "bar_tbl"))).thenReturn(true);
+        when(rule.isBindingTablesUseShardingColumnsJoin(sqlStatementContext, 
Arrays.asList("foo_tbl", "bar_tbl"))).thenReturn(true);
         Collection<DataNode> includedDataNodes = new HashSet<>();
         assertFalse(decider.decide(sqlStatementContext, 
Collections.emptyList(), mock(RuleMetaData.class), database, rule, 
includedDataNodes));
         assertThat(includedDataNodes.size(), is(4));
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingTableTokenGeneratorTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingTableTokenGeneratorTest.java
index e80460e7042..fe1edb40799 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingTableTokenGeneratorTest.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingTableTokenGeneratorTest.java
@@ -75,7 +75,7 @@ class ShardingTableTokenGeneratorTest {
     void assertIsGenerateSQLTokenWithAllBindingTables() {
         Collection<String> logicTableNames = Arrays.asList("foo_tbl", 
"bar_tbl");
         
when(rule.getShardingLogicTableNames(logicTableNames)).thenReturn(logicTableNames);
-        when(rule.isAllBindingTables(logicTableNames)).thenReturn(true);
+        when(rule.isAllConfigBindingTables(logicTableNames)).thenReturn(true);
         SelectStatementContext sqlStatementContext = 
mock(SelectStatementContext.class, RETURNS_DEEP_STUBS);
         
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(logicTableNames);
         assertTrue(generator.isGenerateSQLToken(sqlStatementContext));
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
index 9caefec97bf..83429eabfca 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
@@ -70,7 +70,6 @@ import javax.sql.DataSource;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.Map;
@@ -264,26 +263,26 @@ class ShardingRuleTest {
     
     @Test
     void assertIsAllBindingTableWhenLogicTablesIsEmpty() {
-        
assertFalse(createMaximumShardingRule().isAllBindingTables(Collections.emptyList()));
+        
assertFalse(createMaximumShardingRule().isAllConfigBindingTables(Collections.emptyList()));
     }
     
     @Test
     void assertIsNotAllBindingTable() {
-        
assertFalse(createMaximumShardingRule().isAllBindingTables(Collections.singleton("new_Table")));
-        
assertFalse(createMaximumShardingRule().isAllBindingTables(Arrays.asList("logic_Table",
 "new_Table")));
+        
assertFalse(createMaximumShardingRule().isAllConfigBindingTables(Collections.singleton("new_Table")));
+        
assertFalse(createMaximumShardingRule().isAllConfigBindingTables(Arrays.asList("logic_Table",
 "new_Table")));
     }
     
     @Test
     void assertIsAllBindingTable() {
-        
assertTrue(createMaximumShardingRule().isAllBindingTables(Collections.singleton("logic_Table")));
-        
assertTrue(createMaximumShardingRule().isAllBindingTables(Collections.singleton("logic_table")));
-        
assertTrue(createMaximumShardingRule().isAllBindingTables(Collections.singleton("sub_Logic_Table")));
-        
assertTrue(createMaximumShardingRule().isAllBindingTables(Collections.singleton("sub_logic_table")));
-        
assertTrue(createMaximumShardingRule().isAllBindingTables(Arrays.asList("logic_Table",
 "sub_Logic_Table")));
-        
assertTrue(createMaximumShardingRule().isAllBindingTables(Arrays.asList("logic_table",
 "sub_logic_Table")));
-        
assertFalse(createMaximumShardingRule().isAllBindingTables(Arrays.asList("logic_table",
 "sub_logic_Table", "new_table")));
-        
assertFalse(createMaximumShardingRule().isAllBindingTables(Collections.emptyList()));
-        
assertFalse(createMaximumShardingRule().isAllBindingTables(Collections.singleton("new_Table")));
+        
assertTrue(createMaximumShardingRule().isAllConfigBindingTables(Collections.singleton("logic_Table")));
+        
assertTrue(createMaximumShardingRule().isAllConfigBindingTables(Collections.singleton("logic_table")));
+        
assertTrue(createMaximumShardingRule().isAllConfigBindingTables(Collections.singleton("sub_Logic_Table")));
+        
assertTrue(createMaximumShardingRule().isAllConfigBindingTables(Collections.singleton("sub_logic_table")));
+        
assertTrue(createMaximumShardingRule().isAllConfigBindingTables(Arrays.asList("logic_Table",
 "sub_Logic_Table")));
+        
assertTrue(createMaximumShardingRule().isAllConfigBindingTables(Arrays.asList("logic_table",
 "sub_logic_Table")));
+        
assertFalse(createMaximumShardingRule().isAllConfigBindingTables(Arrays.asList("logic_table",
 "sub_logic_Table", "new_table")));
+        
assertFalse(createMaximumShardingRule().isAllConfigBindingTables(Collections.emptyList()));
+        
assertFalse(createMaximumShardingRule().isAllConfigBindingTables(Collections.singleton("new_Table")));
     }
     
     @Test
@@ -615,16 +614,14 @@ class ShardingRuleTest {
     @Test
     void assertIsAllBindingTableWithUpdateStatementContext() {
         SQLStatementContext sqlStatementContext = 
mock(UpdateStatementContext.class);
-        assertTrue(
-                
createMaximumShardingRule().isAllBindingTables(mock(ShardingSphereDatabase.class,
 RETURNS_DEEP_STUBS), sqlStatementContext, Arrays.asList("logic_Table", 
"sub_Logic_Table")));
+        
assertTrue(createMaximumShardingRule().isBindingTablesUseShardingColumnsJoin(sqlStatementContext,
 Arrays.asList("logic_Table", "sub_Logic_Table")));
     }
     
     @Test
     void assertIsAllBindingTableWithoutJoinQuery() {
         SelectStatementContext sqlStatementContext = 
mock(SelectStatementContext.class);
         when(sqlStatementContext.isContainsJoinQuery()).thenReturn(false);
-        assertTrue(
-                
createMaximumShardingRule().isAllBindingTables(mock(ShardingSphereDatabase.class,
 RETURNS_DEEP_STUBS), sqlStatementContext, Arrays.asList("logic_Table", 
"sub_Logic_Table")));
+        
assertTrue(createMaximumShardingRule().isBindingTablesUseShardingColumnsJoin(sqlStatementContext,
 Arrays.asList("logic_Table", "sub_Logic_Table")));
     }
     
     @Test
@@ -636,8 +633,7 @@ class ShardingRuleTest {
         
when(sqlStatementContext.getTablesContext().getSchemaName()).thenReturn(Optional.empty());
         ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, 
RETURNS_DEEP_STUBS);
         when(database.getName()).thenReturn("db_schema");
-        assertFalse(
-                createMaximumShardingRule().isAllBindingTables(database, 
sqlStatementContext, Arrays.asList("logic_Table", "sub_Logic_Table")));
+        
assertFalse(createMaximumShardingRule().isBindingTablesUseShardingColumnsJoin(sqlStatementContext,
 Arrays.asList("logic_Table", "sub_Logic_Table")));
     }
     
     @Test
@@ -658,7 +654,7 @@ class ShardingRuleTest {
         ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, 
RETURNS_DEEP_STUBS);
         when(database.getName()).thenReturn("foo_db");
         when(database.getSchema("foo_db")).thenReturn(schema);
-        assertFalse(createMaximumShardingRule().isAllBindingTables(database, 
sqlStatementContext, Arrays.asList("logic_Table", "sub_Logic_Table")));
+        
assertFalse(createMaximumShardingRule().isBindingTablesUseShardingColumnsJoin(sqlStatementContext,
 Arrays.asList("logic_Table", "sub_Logic_Table")));
     }
     
     @Test
@@ -681,7 +677,7 @@ class ShardingRuleTest {
         when(sqlStatementContext.getDatabaseType()).thenReturn(databaseType);
         ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, 
RETURNS_DEEP_STUBS);
         when(database.getName()).thenReturn("foo_db");
-        assertFalse(createMaximumShardingRule().isAllBindingTables(database, 
sqlStatementContext, Arrays.asList("LOGIC_TABLE", "SUB_LOGIC_TABLE")));
+        
assertFalse(createMaximumShardingRule().isBindingTablesUseShardingColumnsJoin(sqlStatementContext,
 Arrays.asList("LOGIC_TABLE", "SUB_LOGIC_TABLE")));
     }
     
     @Test
@@ -715,7 +711,7 @@ class ShardingRuleTest {
         ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, 
RETURNS_DEEP_STUBS);
         when(database.getName()).thenReturn("foo_db");
         when(database.getSchema("foo_db")).thenReturn(schema);
-        assertTrue(createMaximumShardingRule().isAllBindingTables(database, 
sqlStatementContext, Arrays.asList("logic_Table", "sub_Logic_Table")));
+        
assertTrue(createMaximumShardingRule().isBindingTablesUseShardingColumnsJoin(sqlStatementContext,
 Arrays.asList("logic_Table", "sub_Logic_Table")));
     }
     
     @Test
@@ -742,15 +738,6 @@ class ShardingRuleTest {
         return result;
     }
     
-    private Map<String, String> createColumnTableNameMap() {
-        Map<String, String> result = new HashMap<>(4, 1F);
-        result.put("logic_Table.user_id", "logic_Table");
-        result.put("sub_Logic_Table.user_id", "sub_Logic_Table");
-        result.put("logic_Table.order_id", "logic_Table");
-        result.put("sub_Logic_Table.order_id", "sub_Logic_Table");
-        return result;
-    }
-    
     @Test
     void assertGetDataNodesByTableName() {
         ShardingRule shardingRule = createMinimumShardingRule();
diff --git 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/column/ColumnDefinitionSegmentBinder.java
 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/column/ColumnDefinitionSegmentBinder.java
index 633bfd85821..cffab8116b3 100644
--- 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/column/ColumnDefinitionSegmentBinder.java
+++ 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/column/ColumnDefinitionSegmentBinder.java
@@ -49,7 +49,7 @@ public final class ColumnDefinitionSegmentBinder {
         ColumnSegment boundColumnSegment = 
ColumnSegmentBinder.bind(segment.getColumnName(), 
SegmentType.DEFINITION_COLUMNS, binderContext, tableBinderContexts, 
LinkedHashMultimap.create());
         ColumnDefinitionSegment result =
                 new ColumnDefinitionSegment(segment.getStartIndex(), 
segment.getStopIndex(), boundColumnSegment, segment.getDataType(), 
segment.isPrimaryKey(), segment.isNotNull(), segment.getText());
-        copy(segment, result);
+        copy(result, segment);
         segment.getReferencedTables().forEach(each -> 
result.getReferencedTables().add(SimpleTableSegmentBinder.bind(each, 
binderContext, tableBinderContexts)));
         return result;
     }


Reply via email to