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 67b6160b7dd92..e1af887254fb2 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 @@ private ShardingRouteCacheableCheckResult checkSelectCacheable(final SelectState 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 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 d3e527f0472b0..ed876d0f82200 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 static void checkTableNotExist(final ShardingSphereSchema schema, final C */ public static void checkMultipleTable(final ShardingRule shardingRule, final SQLStatementContext sqlStatementContext) { Collection 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 285b369a8f31d..81ade5d0cb6d5 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 @@ private void checkAlterViewShardingTables(final ShardingRule shardingRule, final 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 38f821a21ecf1..507b9b219fed5 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 void check(final ShardingRule rule, final ShardingSphereDatabase database 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 d3a6123c3568c..9c5abb288c5df 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 static boolean isSchemaContainsIndex(final ShardingSphereSchema schema, f public static boolean isShardingTablesNotBindingWithView(final Collection 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 9f7e6ad61268f..d83c7ca15c3e1 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 boolean decide(final SelectStatementContext selectStatementContext, final 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 tableNames) { - return 1 == tableNames.size() && selectStatementContext.isContainsJoinQuery() && !rule.isAllBindingTables(database, selectStatementContext, tableNames); + private boolean isSelfJoinWithoutShardingColumn(final SelectStatementContext selectStatementContext, final ShardingRule rule, final Collection tableNames) { + return 1 == tableNames.size() && selectStatementContext.isContainsJoinQuery() && !rule.isBindingTablesUseShardingColumnsJoin(selectStatementContext, tableNames); } private Collection getTableDataNodes(final ShardingRule rule, final ShardingSphereDatabase database, final Collection 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 e870b627b8fb2..d9e5c90405d01 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 @@ private boolean isAllBindingTables(final SQLStatementContext sqlStatementContext Collection 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 98ac6ea844755..49de41137a3cf 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 @@ private static ShardingRouteEngine getDDLRouteEngine(final ShardingSphereDatabas private static ShardingRouteEngine getCursorRouteEngine(final ShardingRule rule, final ShardingSphereDatabase database, final SQLStatementContext sqlStatementContext, final HintValueContext hintValueContext, final ShardingConditions shardingConditions, final Collection 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 @@ private static ShardingRouteEngine getDQLRouteEngine(final ShardingRule rule, fi 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 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 7b45827866dbc..87ae103f229a1 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 RouteContext route(final ShardingRule shardingRule) { 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 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 6c3e63386eacf..63300dfc59bc5 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.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 ShardingTable getShardingTable(final String logicTableName) { } /** - * 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 logicTableNames) { + public boolean isAllConfigBindingTables(final Collection logicTableNames) { if (logicTableNames.isEmpty()) { return false; } @@ -339,25 +337,21 @@ public boolean isAllBindingTables(final Collection logicTableNames) { } /** - * 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 logicTableNames) { + public boolean isBindingTablesUseShardingColumnsJoin(final SQLStatementContext sqlStatementContext, final Collection 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 findBindingTableRule(final Collection logicTableNames) { @@ -575,10 +569,9 @@ public boolean isShardingCacheEnabled() { return null != shardingCache; } - private boolean isJoinConditionContainsShardingColumns(final ShardingSphereSchema schema, final SelectStatementContext select, - final Collection tableNames, final Collection whereSegments) { - Collection databaseJoinConditionTables = new HashSet<>(tableNames.size(), 1F); - Collection tableJoinConditionTables = new HashSet<>(tableNames.size(), 1F); + private boolean isJoinConditionContainsShardingColumns(final Collection tableNames, final Collection whereSegments) { + Collection databaseJoinConditionTables = new CaseInsensitiveSet<>(tableNames.size(), 1F); + Collection tableJoinConditionTables = new CaseInsensitiveSet<>(tableNames.size(), 1F); for (WhereSegment each : whereSegments) { Collection andPredicates = ExpressionExtractor.extractAndPredicates(each.getExpr()); if (andPredicates.size() > 1) { @@ -610,14 +603,11 @@ private Collection getJoinConditionTables(final Collection 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 2cd9d471b2faf..95aae4e87983b 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 @@ void assertDecideWithSelfJoinAndShardingColumn() { 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 includedDataNodes = new HashSet<>(); assertFalse(decider.decide(sqlStatementContext, Collections.emptyList(), mock(RuleMetaData.class), database, rule, includedDataNodes)); assertThat(includedDataNodes.size(), is(2)); @@ -173,7 +173,7 @@ void assertDecideWithAllBindingTables() { 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 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 e80460e70423e..fe1edb407991a 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 @@ void assertIsNotGenerateSQLTokenWithNotTableAvailable() { void assertIsGenerateSQLTokenWithAllBindingTables() { Collection 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 9caefec97bf8f..d44a82a11fd41 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 @@ -264,26 +264,26 @@ void assertGetTableRuleFailure() { @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 +615,14 @@ private ShardingTableRuleConfiguration createTableRuleConfigWithComplexStrategie @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 +634,7 @@ void assertIsAllBindingTableWithJoinQueryWithoutJoinCondition() { 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 +655,7 @@ void assertIsAllBindingTableWithJoinQueryWithDatabaseJoinCondition() { 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 +678,7 @@ void assertIsAllBindingTableWithJoinQueryWithDatabaseJoinConditionInUpperCaseAnd 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 +712,7 @@ void assertIsAllBindingTableWithJoinQueryWithDatabaseTableJoinCondition() { 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