You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2026/09/04 01:32:10 UTC
(shardingsphere) branch master updated: Preserve dotted Single table identity through load and unload (#39720)
This is an automated email from the ASF dual-hosted git repository.
terrymanu 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 f46fffd2207 Preserve dotted Single table identity through load and unload (#39720)
f46fffd2207 is described below
commit f46fffd2207a11c9efb71ec20a53df9dd08021ba
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Fri Sep 4 09:32:03 2026 +0800
Preserve dotted Single table identity through load and unload (#39720)
---
.../single/datanode/SingleTableDataNodeLoader.java | 125 ++++++++++++++-------
.../datanode/SingleTableDataNodeLoaderTest.java | 48 ++++++++
.../handler/update/UnloadSingleTableExecutor.java | 38 +++++--
.../update/UnloadSingleTableExecutorTest.java | 82 +++++++++++---
.../StandaloneMetaDataManagerPersistService.java | 8 +-
...tandaloneMetaDataManagerPersistServiceTest.java | 27 +++--
6 files changed, 249 insertions(+), 79 deletions(-)
diff --git a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/datanode/SingleTableDataNodeLoader.java b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/datanode/SingleTableDataNodeLoader.java
index 3a6a5bf6e67..8baf9e9c2c1 100644
--- a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/datanode/SingleTableDataNodeLoader.java
+++ b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/datanode/SingleTableDataNodeLoader.java
@@ -18,14 +18,18 @@
package org.apache.shardingsphere.single.datanode;
import com.cedarsoftware.util.CaseInsensitiveSet;
+import com.google.common.base.Splitter;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.database.connector.core.metadata.data.loader.type.SchemaMetaDataLoader;
import org.apache.shardingsphere.database.connector.core.metadata.identifier.DefaultSchemaNameResolver;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import org.apache.shardingsphere.database.connector.core.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.database.DatabaseTypeEngine;
import org.apache.shardingsphere.infra.datanode.DataNode;
+import org.apache.shardingsphere.infra.exception.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.exception.kernel.metadata.datanode.InvalidDataNodeFormatException;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.single.constant.SingleTableConstants;
import org.apache.shardingsphere.single.exception.SingleTablesLoadingException;
@@ -35,10 +39,12 @@ import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
@@ -51,6 +57,8 @@ import java.util.stream.Collectors;
@Slf4j
public final class SingleTableDataNodeLoader {
+ private static final String DELIMITER = ".";
+
/**
* Load single table data nodes.
*
@@ -75,14 +83,17 @@ public final class SingleTableDataNodeLoader {
warnIfSingleTableLoadedFromMultipleDataSources(databaseName, result);
return result;
}
- Collection<DataNode> configuredDataNodes = getConfiguredDataNodes(splitTables);
- Collection<String> configuredDataSources = getConfiguredDataSources(configuredDataNodes);
- Collection<String> includedTables = getIncludedTables(dataSourceMap, configuredDataNodes, featureRequiredSingleTables);
+ Collection<String> configuredDataSources = getConfiguredDataSources(splitTables);
Map<String, DataSource> validDataSources = dataSourceMap.entrySet().stream().filter(entry -> configuredDataSources.contains(entry.getKey()))
.collect(Collectors.toMap(Entry::getKey, Entry::getValue));
Map<String, DatabaseType> validStorageTypes = validDataSources.entrySet().stream().collect(Collectors.toMap(Entry::getKey, each -> DatabaseTypeEngine.getStorageType(each.getValue())));
+ Map<DatabaseType, Boolean> schemaAvailability = new HashMap<>(validStorageTypes.size() + 1, 1F);
+ checkConfiguredDataNodeTiers(splitTables, validStorageTypes, schemaAvailability);
+ Collection<DataNode> configuredDataNodes = getConfiguredDataNodes(databaseName, protocolType, splitTables, validDataSources, validStorageTypes);
+ Collection<String> includedTables = getIncludedTables(
+ dataSourceMap, validStorageTypes, schemaAvailability, splitTables, configuredDataNodes, featureRequiredSingleTables);
Map<String, Collection<DataNode>> actualDataNodes = load(databaseName, validDataSources, includedTables, excludedTables, validStorageTypes);
- Map<String, Map<String, Collection<String>>> configuredTableMap = getConfiguredTableMap(databaseName, protocolType, splitTables, validDataSources, validStorageTypes);
+ Map<String, Map<String, Collection<String>>> configuredTableMap = getConfiguredTableMap(configuredDataNodes);
Map<String, Collection<DataNode>> result = loadSpecifiedDataNodes(actualDataNodes, featureRequiredSingleTables, configuredTableMap);
warnIfSingleTableLoadedFromMultipleDataSources(databaseName, result);
return result;
@@ -137,21 +148,74 @@ public final class SingleTableDataNodeLoader {
}
}
- private static Collection<DataNode> getConfiguredDataNodes(final Collection<String> splitTables) {
- return splitTables.stream().map(DataNode::new).collect(Collectors.toList());
+ private static Collection<String> getConfiguredDataSources(final Collection<String> configuredTables) {
+ Collection<String> result = new HashSet<>(configuredTables.size(), 1F);
+ for (String each : configuredTables) {
+ checkConfiguredDataNodeFormat(each);
+ result.add(getConfiguredDataSourceName(each));
+ }
+ return result;
}
- private static Collection<String> getConfiguredDataSources(final Collection<DataNode> configuredDataNodes) {
- Collection<String> result = new HashSet<>(configuredDataNodes.size(), 1F);
- for (DataNode each : configuredDataNodes) {
- result.add(each.getDataSourceName());
+ private static void checkConfiguredDataNodeFormat(final String dataNode) {
+ Collection<String> segments = Splitter.on(DELIMITER).splitToList(dataNode);
+ ShardingSpherePreconditions.checkState(segments.size() >= 2 && segments.stream().noneMatch(each -> each.trim().isEmpty())
+ && !dataNode.contains(" " + DELIMITER) && !dataNode.contains(DELIMITER + " "), () -> new InvalidDataNodeFormatException(dataNode));
+ }
+
+ private static String getConfiguredDataSourceName(final String dataNode) {
+ return dataNode.substring(0, dataNode.indexOf(DELIMITER));
+ }
+
+ private static void checkConfiguredDataNodeTiers(final Collection<String> configuredTables, final Map<String, DatabaseType> storageTypes,
+ final Map<DatabaseType, Boolean> schemaAvailability) {
+ for (String each : configuredTables) {
+ Collection<String> segments = Splitter.on(DELIMITER).splitToList(each);
+ ShardingSpherePreconditions.checkState(segments.size() <= 3
+ || isDottedTableNameSupported(storageTypes, schemaAvailability, getConfiguredDataSourceName(each)), () -> new InvalidDataNodeFormatException(each));
+ }
+ }
+
+ private static boolean isDottedTableNameSupported(final Map<String, DatabaseType> storageTypes, final Map<DatabaseType, Boolean> schemaAvailability,
+ final String dataSourceName) {
+ DatabaseType storageType = storageTypes.get(dataSourceName);
+ return null != storageType && !isSchemaAvailable(storageType, schemaAvailability);
+ }
+
+ private static boolean isSchemaAvailable(final DatabaseType databaseType, final Map<DatabaseType, Boolean> schemaAvailability) {
+ return schemaAvailability.computeIfAbsent(databaseType,
+ each -> new DatabaseTypeRegistry(each).getDialectDatabaseMetaData().getSchemaOption().isSchemaAvailable());
+ }
+
+ private static Collection<DataNode> getConfiguredDataNodes(final String databaseName, final DatabaseType protocolType, final Collection<String> configuredTables,
+ final Map<String, DataSource> validDataSources, final Map<String, DatabaseType> validStorageTypes) {
+ Map<String, String> defaultSchemaNames = getDefaultSchemaNames(databaseName, validDataSources, validStorageTypes);
+ return configuredTables.stream().map(each -> getConfiguredDataNode(databaseName, protocolType, validStorageTypes, defaultSchemaNames, each)).collect(Collectors.toList());
+ }
+
+ private static Map<String, String> getDefaultSchemaNames(final String databaseName, final Map<String, DataSource> dataSources, final Map<String, DatabaseType> storageTypes) {
+ Map<String, String> result = new LinkedHashMap<>(dataSources.size(), 1F);
+ for (Entry<String, DataSource> entry : dataSources.entrySet()) {
+ DatabaseType storageType = storageTypes.get(entry.getKey());
+ result.put(entry.getKey(), DefaultSchemaNameResolver.resolveStorage(storageType, entry.getValue(), databaseName));
}
return result;
}
- private static Collection<String> getIncludedTables(final Map<String, DataSource> dataSourceMap, final Collection<DataNode> configuredDataNodes,
+ private static DataNode getConfiguredDataNode(final String databaseName, final DatabaseType protocolType, final Map<String, DatabaseType> storageTypes,
+ final Map<String, String> defaultSchemaNames, final String dataNode) {
+ String dataSourceName = getConfiguredDataSourceName(dataNode);
+ return defaultSchemaNames.containsKey(dataSourceName)
+ ? DataNode.createWithDefaultSchemaName(defaultSchemaNames.get(dataSourceName), storageTypes.get(dataSourceName), dataNode)
+ : new DataNode(databaseName, protocolType, dataNode);
+ }
+
+ private static Collection<String> getIncludedTables(final Map<String, DataSource> dataSourceMap, final Map<String, DatabaseType> storageTypes,
+ final Map<DatabaseType, Boolean> schemaAvailability, final Collection<String> configuredTables,
+ final Collection<DataNode> configuredDataNodes,
final Collection<String> featureRequiredSingleTables) {
- if (!isSafeToFilterBeforeLoad(configuredDataNodes) || !isSingleDataSource(dataSourceMap) && !featureRequiredSingleTables.isEmpty()) {
+ if (!isSafeToFilterBeforeLoad(storageTypes, schemaAvailability, configuredTables)
+ || !isSingleDataSource(dataSourceMap) && !featureRequiredSingleTables.isEmpty()) {
return Collections.emptySet();
}
Collection<String> result = new CaseInsensitiveSet<>(configuredDataNodes.size() + featureRequiredSingleTables.size(), 1F);
@@ -162,9 +226,12 @@ public final class SingleTableDataNodeLoader {
return result;
}
- private static boolean isSafeToFilterBeforeLoad(final Collection<DataNode> configuredDataNodes) {
- for (DataNode each : configuredDataNodes) {
- if (null != each.getSchemaName() && !SingleTableConstants.ASTERISK.equals(each.getSchemaName())) {
+ private static boolean isSafeToFilterBeforeLoad(final Map<String, DatabaseType> storageTypes, final Map<DatabaseType, Boolean> schemaAvailability,
+ final Collection<String> configuredTables) {
+ for (String each : configuredTables) {
+ List<String> segments = Splitter.on(DELIMITER).splitToList(each);
+ if (3 == segments.size() && !SingleTableConstants.ASTERISK.equals(segments.get(1))
+ && !isDottedTableNameSupported(storageTypes, schemaAvailability, segments.get(0))) {
return false;
}
}
@@ -216,15 +283,12 @@ public final class SingleTableDataNodeLoader {
return result;
}
- private static Map<String, Map<String, Collection<String>>> getConfiguredTableMap(final String databaseName, final DatabaseType protocolType, final Collection<String> configuredTables,
- final Map<String, DataSource> validDataSources, final Map<String, DatabaseType> validStorageTypes) {
- if (configuredTables.isEmpty()) {
+ private static Map<String, Map<String, Collection<String>>> getConfiguredTableMap(final Collection<DataNode> configuredDataNodes) {
+ if (configuredDataNodes.isEmpty()) {
return Collections.emptyMap();
}
- Map<String, Map<String, Collection<String>>> result = new LinkedHashMap<>(configuredTables.size(), 1F);
- Map<String, String> defaultSchemaNames = getDefaultSchemaNames(databaseName, validDataSources, validStorageTypes);
- for (String each : configuredTables) {
- DataNode dataNode = getConfiguredDataNode(databaseName, protocolType, validStorageTypes, defaultSchemaNames, each);
+ Map<String, Map<String, Collection<String>>> result = new LinkedHashMap<>(configuredDataNodes.size(), 1F);
+ for (DataNode dataNode : configuredDataNodes) {
Map<String, Collection<String>> schemaTables = result.getOrDefault(dataNode.getDataSourceName(), new LinkedHashMap<>());
Collection<String> tables = schemaTables.computeIfAbsent(dataNode.getSchemaName(),
ignored -> SingleTableConstants.ASTERISK.equals(dataNode.getSchemaName()) ? new CaseInsensitiveSet<>() : new LinkedHashSet<>());
@@ -234,23 +298,6 @@ public final class SingleTableDataNodeLoader {
return result;
}
- private static Map<String, String> getDefaultSchemaNames(final String databaseName, final Map<String, DataSource> dataSources, final Map<String, DatabaseType> storageTypes) {
- Map<String, String> result = new LinkedHashMap<>(dataSources.size(), 1F);
- for (Entry<String, DataSource> entry : dataSources.entrySet()) {
- DatabaseType storageType = storageTypes.get(entry.getKey());
- result.put(entry.getKey(), DefaultSchemaNameResolver.resolveStorage(storageType, entry.getValue(), databaseName));
- }
- return result;
- }
-
- private static DataNode getConfiguredDataNode(final String databaseName, final DatabaseType protocolType, final Map<String, DatabaseType> storageTypes,
- final Map<String, String> defaultSchemaNames, final String dataNode) {
- String dataSourceName = new DataNode(dataNode).getDataSourceName();
- return defaultSchemaNames.containsKey(dataSourceName)
- ? DataNode.createWithDefaultSchemaName(defaultSchemaNames.get(dataSourceName), storageTypes.get(dataSourceName), dataNode)
- : new DataNode(databaseName, protocolType, dataNode);
- }
-
/**
* Load schema table names.
*
diff --git a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/datanode/SingleTableDataNodeLoaderTest.java b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/datanode/SingleTableDataNodeLoaderTest.java
index 830baa280dc..4d9eb596014 100644
--- a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/datanode/SingleTableDataNodeLoaderTest.java
+++ b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/datanode/SingleTableDataNodeLoaderTest.java
@@ -25,6 +25,7 @@ import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.database.connector.core.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.database.DatabaseTypeEngine;
import org.apache.shardingsphere.infra.datanode.DataNode;
+import org.apache.shardingsphere.infra.exception.kernel.metadata.datanode.InvalidDataNodeFormatException;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.rule.attribute.RuleAttributes;
import org.apache.shardingsphere.infra.rule.attribute.table.TableMapperRuleAttribute;
@@ -71,6 +72,7 @@ import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockConstruction;
import static org.mockito.Mockito.mockStatic;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@ExtendWith(LogCaptureExtension.class)
@@ -80,6 +82,8 @@ class SingleTableDataNodeLoaderTest {
private final DatabaseType protocolDatabaseType = TypedSPILoader.getService(DatabaseType.class, "Oracle");
+ private final DatabaseType schemaAvailableProtocolDatabaseType = TypedSPILoader.getService(DatabaseType.class, "PostgreSQL");
+
private final DatabaseType storageDatabaseType = TypedSPILoader.getService(DatabaseType.class, "MySQL");
private Map<String, DataSource> dataSourceMap;
@@ -311,6 +315,43 @@ class SingleTableDataNodeLoaderTest {
}
}
+ @Test
+ void assertLoadWithDottedTableName() throws SQLException {
+ DataSource dataSource = mock(DataSource.class);
+ Map<String, DataSource> localDataSourceMap = Collections.singletonMap("foo_ds", dataSource);
+ Map<String, Collection<String>> schemaTableNames = Collections.singletonMap("foo_db", Collections.singleton("foo_tbl.part.item"));
+ try (
+ MockedStatic<DatabaseTypeEngine> databaseTypeEngine = mockStatic(DatabaseTypeEngine.class);
+ MockedStatic<DefaultSchemaNameResolver> defaultSchemaNameResolver = mockStatic(DefaultSchemaNameResolver.class);
+ MockedConstruction<SchemaMetaDataLoader> schemaMetaDataLoader = mockConstruction(SchemaMetaDataLoader.class,
+ (mock, context) -> when(mock.loadSchemaTableNames(anyString(), any(DataSource.class), anyCollection(), anyCollection())).thenReturn(schemaTableNames))) {
+ databaseTypeEngine.when(() -> DatabaseTypeEngine.getStorageType(dataSource)).thenReturn(storageDatabaseType);
+ defaultSchemaNameResolver.when(() -> DefaultSchemaNameResolver.resolveStorage(storageDatabaseType, dataSource, "foo_db")).thenReturn("foo_db");
+ Map<String, Collection<DataNode>> actual = SingleTableDataNodeLoader.load(
+ "foo_db", schemaAvailableProtocolDatabaseType, localDataSourceMap, Collections.emptyList(), Collections.singleton("foo_ds.foo_tbl.part.item"));
+ assertThat(actual.get("foo_tbl.part.item"), is(Collections.singletonList(new DataNode("foo_ds", "foo_db", "foo_tbl.part.item"))));
+ verify(schemaMetaDataLoader.constructed().get(0)).loadSchemaTableNames(
+ "foo_db", dataSource, Collections.singleton("foo_tbl.part.item"), Collections.emptySet());
+ }
+ }
+
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("invalidConfiguredTableArguments")
+ void assertLoadWithInvalidConfiguredTable(final String name, final boolean schemaAvailable, final String configuredTable) {
+ DataSource dataSource = mock(DataSource.class);
+ Map<String, DataSource> localDataSourceMap = Collections.singletonMap("foo_ds", dataSource);
+ DialectDatabaseMetaData dialectDatabaseMetaData = mock(DialectDatabaseMetaData.class, RETURNS_DEEP_STUBS);
+ when(dialectDatabaseMetaData.getSchemaOption().isSchemaAvailable()).thenReturn(schemaAvailable);
+ try (
+ MockedStatic<DatabaseTypeEngine> databaseTypeEngine = mockStatic(DatabaseTypeEngine.class);
+ MockedConstruction<DatabaseTypeRegistry> ignored = mockConstruction(
+ DatabaseTypeRegistry.class, (mock, context) -> when(mock.getDialectDatabaseMetaData()).thenReturn(dialectDatabaseMetaData))) {
+ databaseTypeEngine.when(() -> DatabaseTypeEngine.getStorageType(dataSource)).thenReturn(storageDatabaseType);
+ assertThrows(InvalidDataNodeFormatException.class, () -> SingleTableDataNodeLoader.load(
+ "foo_db", storageDatabaseType, localDataSourceMap, Collections.emptyList(), Collections.singleton(configuredTable)));
+ }
+ }
+
@Test
void assertLoadSchemaTableNames() {
Map<String, Collection<String>> actual = SingleTableDataNodeLoader.loadSchemaTableNames("foo_db", databaseType, dataSourceMap.get("foo_ds"), "foo_ds",
@@ -345,6 +386,13 @@ class SingleTableDataNodeLoaderTest {
Arguments.arguments("all schema tables", Collections.emptyList(), Collections.singleton("*.*.*"), createExpectedTableDataSources(allSchemaTablesExpectedDataSources)));
}
+ private static Stream<Arguments> invalidConfiguredTableArguments() {
+ return Stream.of(
+ Arguments.arguments("schema-aware dotted table", true, "foo_ds.foo_schema.foo.part"),
+ Arguments.arguments("blank dotted segment", false, "foo_ds.\t.foo"),
+ Arguments.arguments("unknown storage unit with dotted table", false, "bar_ds.foo.part.item"));
+ }
+
private static ShardingSphereRule createRule(final Collection<String> distributedTableNames, final Collection<String> enhancedTableNames) {
ShardingSphereRule result = mock(ShardingSphereRule.class);
TableMapperRuleAttribute ruleAttribute = mock(TableMapperRuleAttribute.class);
diff --git a/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/UnloadSingleTableExecutor.java b/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/UnloadSingleTableExecutor.java
index 2134cc036d4..8567daf801a 100644
--- a/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/UnloadSingleTableExecutor.java
+++ b/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/UnloadSingleTableExecutor.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.single.distsql.handler.update;
-import com.google.common.base.Splitter;
import lombok.Setter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.database.exception.core.exception.syntax.table.NoSuchTableException;
@@ -27,8 +26,10 @@ import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.infra.exception.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.exception.kernel.metadata.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnit;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
import org.apache.shardingsphere.infra.rule.attribute.datanode.DataNodeRuleAttribute;
+import org.apache.shardingsphere.infra.rule.attribute.datasource.aggregate.AggregatedDataSourceRuleAttribute;
import org.apache.shardingsphere.infra.rule.attribute.table.TableMapperRuleAttribute;
import org.apache.shardingsphere.single.config.SingleRuleConfiguration;
import org.apache.shardingsphere.single.distsql.statement.rdl.UnloadSingleTableStatement;
@@ -36,9 +37,10 @@ import org.apache.shardingsphere.single.exception.SingleTableNotFoundException;
import org.apache.shardingsphere.single.rule.SingleRule;
import org.apache.shardingsphere.single.util.SingleTableLoadUtils;
+import javax.sql.DataSource;
import java.util.Collection;
import java.util.Collections;
-import java.util.List;
+import java.util.Map;
import java.util.stream.Collectors;
/**
@@ -67,7 +69,7 @@ public final class UnloadSingleTableExecutor implements DatabaseRuleAlterExecuto
for (String each : sqlStatement.getTables()) {
checkTableExist(allTables, each);
checkIsSingleTable(singleTables, each);
- checkTableRuleExist(database.getName(), database.getProtocolType(), singleRule.getAttributes().getAttribute(DataNodeRuleAttribute.class).getDataNodesByTableName(each), each);
+ checkTableRuleExist(database.getName(), singleRule.getAttributes().getAttribute(DataNodeRuleAttribute.class).getDataNodesByTableName(each), each);
}
}
@@ -84,19 +86,38 @@ public final class UnloadSingleTableExecutor implements DatabaseRuleAlterExecuto
ShardingSpherePreconditions.checkContains(singleTables, tableName, () -> new SingleTableNotFoundException(tableName));
}
- private void checkTableRuleExist(final String databaseName, final DatabaseType databaseType, final Collection<DataNode> dataNodes, final String tableName) {
+ private void checkTableRuleExist(final String databaseName, final Collection<DataNode> dataNodes, final String tableName) {
ShardingSpherePreconditions.checkNotEmpty(dataNodes, () -> new MissingRequiredRuleException("Single", databaseName, tableName));
DataNode dataNode = dataNodes.iterator().next();
- String dataNodeString = SingleTableLoadUtils.getDataNodeString(databaseType, dataNode.getDataSourceName(), dataNode.getSchemaName(), dataNode.getTableName());
+ String dataNodeString = getDataNodeString(dataNode);
ShardingSpherePreconditions.checkContains(rule.getConfiguration().getTables(), dataNodeString, () -> new MissingRequiredRuleException("Single", databaseName, tableName));
}
+ private String getDataNodeString(final DataNode dataNode) {
+ DatabaseType storageType = getStorageType(dataNode.getDataSourceName());
+ return SingleTableLoadUtils.getDataNodeString(storageType, dataNode.getDataSourceName(), dataNode.getSchemaName(), dataNode.getTableName());
+ }
+
+ private DatabaseType getStorageType(final String dataSourceName) {
+ Map<String, StorageUnit> storageUnits = database.getResourceMetaData().getStorageUnits();
+ StorageUnit storageUnit = storageUnits.get(dataSourceName);
+ if (null != storageUnit) {
+ return storageUnit.getStorageType();
+ }
+ DataSource dataSource = rule.getAttributes().getAttribute(AggregatedDataSourceRuleAttribute.class).getAggregatedDataSources().get(dataSourceName);
+ return storageUnits.values().stream().filter(each -> dataSource == each.getDataSource()).map(StorageUnit::getStorageType).findFirst()
+ .orElseThrow(() -> new IllegalStateException(String.format("Can not find storage type for data source: %s", dataSourceName)));
+ }
+
@Override
public SingleRuleConfiguration buildToBeAlteredRuleConfiguration(final UnloadSingleTableStatement sqlStatement) {
SingleRuleConfiguration result = new SingleRuleConfiguration();
if (!sqlStatement.isUnloadAllTables()) {
result.getTables().addAll(rule.getConfiguration().getTables());
- result.getTables().removeIf(each -> sqlStatement.getTables().contains(extractTableName(each)));
+ DataNodeRuleAttribute dataNodeRuleAttribute = rule.getAttributes().getAttribute(DataNodeRuleAttribute.class);
+ Collection<String> toBeRemovedDataNodes = sqlStatement.getTables().stream().flatMap(each -> dataNodeRuleAttribute.getDataNodesByTableName(each).stream())
+ .map(this::getDataNodeString).collect(Collectors.toSet());
+ result.getTables().removeAll(toBeRemovedDataNodes);
}
return result;
}
@@ -111,11 +132,6 @@ public final class UnloadSingleTableExecutor implements DatabaseRuleAlterExecuto
return null;
}
- private String extractTableName(final String tableNode) {
- List<String> segments = Splitter.on(".").trimResults().splitToList(tableNode);
- return segments.get(segments.size() - 1);
- }
-
@Override
public Class<SingleRule> getRuleClass() {
return SingleRule.class;
diff --git a/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/update/UnloadSingleTableExecutorTest.java b/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/update/UnloadSingleTableExecutorTest.java
index 66b594faf8c..22511582af4 100644
--- a/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/update/UnloadSingleTableExecutorTest.java
+++ b/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/update/UnloadSingleTableExecutorTest.java
@@ -25,17 +25,21 @@ import org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.data
import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.infra.exception.kernel.metadata.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
+import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnit;
import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
import org.apache.shardingsphere.infra.rule.attribute.RuleAttributes;
import org.apache.shardingsphere.infra.rule.attribute.datanode.DataNodeRuleAttribute;
+import org.apache.shardingsphere.infra.rule.attribute.datasource.aggregate.AggregatedDataSourceRuleAttribute;
import org.apache.shardingsphere.infra.rule.attribute.table.TableMapperRuleAttribute;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.single.config.SingleRuleConfiguration;
import org.apache.shardingsphere.single.distsql.statement.rdl.UnloadSingleTableStatement;
import org.apache.shardingsphere.single.exception.SingleTableNotFoundException;
import org.apache.shardingsphere.single.rule.SingleRule;
+import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -48,6 +52,8 @@ import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
+import javax.sql.DataSource;
+import java.sql.SQLException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -69,13 +75,17 @@ import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockConstruction;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
class UnloadSingleTableExecutorTest {
- private final DatabaseType databaseType = TypedSPILoader.getService(DatabaseType.class, "FIXTURE");
+ private final DatabaseType protocolDatabaseType = TypedSPILoader.getService(DatabaseType.class, "PostgreSQL");
+
+ private final DatabaseType storageDatabaseType = TypedSPILoader.getService(DatabaseType.class, "MySQL");
private final UnloadSingleTableExecutor executor = (UnloadSingleTableExecutor) TypedSPILoader.getService(DatabaseRuleDefinitionExecutor.class, UnloadSingleTableStatement.class);
@@ -91,14 +101,33 @@ class UnloadSingleTableExecutorTest {
@Mock
private DataNodeRuleAttribute dataNodeRuleAttribute;
+ @Mock
+ private DataSource dataSource;
+
@BeforeEach
void setUp() {
executor.setDatabase(database);
executor.setRule(rule);
when(database.getName()).thenReturn("foo_db");
- when(database.getProtocolType()).thenReturn(databaseType);
+ when(database.getProtocolType()).thenReturn(protocolDatabaseType);
+ StorageUnit storageUnit = mock(StorageUnit.class);
+ when(storageUnit.getStorageType()).thenReturn(storageDatabaseType);
+ when(storageUnit.getDataSource()).thenReturn(dataSource);
+ ResourceMetaData resourceMetaData = mock(ResourceMetaData.class);
+ when(resourceMetaData.getStorageUnits()).thenReturn(Collections.singletonMap("foo_ds", storageUnit));
+ when(database.getResourceMetaData()).thenReturn(resourceMetaData);
when(database.getRuleMetaData()).thenReturn(new RuleMetaData(Collections.singleton(rule)));
- when(rule.getAttributes()).thenReturn(new RuleAttributes(tableMapperRuleAttribute, dataNodeRuleAttribute));
+ Map<String, DataSource> aggregatedDataSources = new HashMap<>(3, 1F);
+ aggregatedDataSources.put("foo_ds", dataSource);
+ aggregatedDataSources.put("bar_ds", dataSource);
+ aggregatedDataSources.put("readwrite_ds", dataSource);
+ when(rule.getAttributes()).thenReturn(new RuleAttributes(
+ tableMapperRuleAttribute, dataNodeRuleAttribute, new AggregatedDataSourceRuleAttribute(aggregatedDataSources)));
+ }
+
+ @AfterEach
+ void assertStorageIsNotProbed() throws SQLException {
+ verify(dataSource, never()).getConnection();
}
@ParameterizedTest(name = "{0}")
@@ -116,12 +145,7 @@ class UnloadSingleTableExecutorTest {
void assertCheckBeforeUpdate(final String name, final boolean schemaAvailable, final UnloadSingleTableStatement sqlStatement, final Collection<String> allTables,
final Collection<String> singleTables, final Map<String, Collection<DataNode>> tableDataNodes, final Collection<String> configuredTables) {
prepareCheckBeforeUpdateContext(allTables, singleTables, tableDataNodes, configuredTables);
- DialectDatabaseMetaData dialectDatabaseMetaData = mock(DialectDatabaseMetaData.class, RETURNS_DEEP_STUBS);
- when(dialectDatabaseMetaData.getSchemaOption().getDefaultSchema()).thenReturn(Optional.of("foo_schema"));
- when(dialectDatabaseMetaData.getSchemaOption().isSchemaAvailable()).thenReturn(schemaAvailable);
- try (
- MockedConstruction<DatabaseTypeRegistry> ignored = mockConstruction(
- DatabaseTypeRegistry.class, (mock, context) -> when(mock.getDialectDatabaseMetaData()).thenReturn(dialectDatabaseMetaData))) {
+ try (MockedConstruction<DatabaseTypeRegistry> ignored = mockDatabaseTypeRegistry(schemaAvailable)) {
assertDoesNotThrow(() -> executor.checkBeforeUpdate(sqlStatement));
}
}
@@ -134,11 +158,15 @@ class UnloadSingleTableExecutorTest {
@ParameterizedTest(name = "{0}")
@MethodSource("assertBuildToBeAlteredRuleConfigurationArguments")
- void assertBuildToBeAlteredRuleConfiguration(final String name, final Collection<String> currentTables,
- final UnloadSingleTableStatement sqlStatement, final Collection<String> expectedTables) {
+ void assertBuildToBeAlteredRuleConfiguration(final String name, final boolean schemaAvailable, final Collection<String> currentTables,
+ final Map<String, Collection<DataNode>> tableDataNodes, final UnloadSingleTableStatement sqlStatement,
+ final Collection<String> expectedTables) {
when(rule.getConfiguration()).thenReturn(new SingleRuleConfiguration(new LinkedList<>(currentTables), null));
- SingleRuleConfiguration actual = executor.buildToBeAlteredRuleConfiguration(sqlStatement);
- assertThat(new HashSet<>(actual.getTables()), is(new HashSet<>(expectedTables)));
+ when(dataNodeRuleAttribute.getDataNodesByTableName(anyString())).thenAnswer(invocation -> tableDataNodes.getOrDefault(invocation.getArgument(0), Collections.emptyList()));
+ try (MockedConstruction<DatabaseTypeRegistry> ignored = mockDatabaseTypeRegistry(schemaAvailable)) {
+ SingleRuleConfiguration actual = executor.buildToBeAlteredRuleConfiguration(sqlStatement);
+ assertThat(new HashSet<>(actual.getTables()), is(new HashSet<>(expectedTables)));
+ }
}
@ParameterizedTest(name = "{0}")
@@ -161,6 +189,15 @@ class UnloadSingleTableExecutorTest {
assertThat(executor.getRuleClass(), is(SingleRule.class));
}
+ private MockedConstruction<DatabaseTypeRegistry> mockDatabaseTypeRegistry(final boolean storageSchemaAvailable) {
+ DialectDatabaseMetaData protocolMetaData = mock(DialectDatabaseMetaData.class, RETURNS_DEEP_STUBS);
+ when(protocolMetaData.getSchemaOption().isSchemaAvailable()).thenReturn(true);
+ DialectDatabaseMetaData storageMetaData = mock(DialectDatabaseMetaData.class, RETURNS_DEEP_STUBS);
+ when(storageMetaData.getSchemaOption().isSchemaAvailable()).thenReturn(storageSchemaAvailable);
+ return mockConstruction(DatabaseTypeRegistry.class, (mock, context) -> when(mock.getDialectDatabaseMetaData())
+ .thenReturn(storageDatabaseType == context.arguments().get(0) ? storageMetaData : protocolMetaData));
+ }
+
private void prepareCheckBeforeUpdateContext(final Collection<String> allTables, final Collection<String> singleTables,
final Map<String, Collection<DataNode>> tableDataNodes, final Collection<String> configuredTables) {
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
@@ -205,13 +242,22 @@ class UnloadSingleTableExecutorTest {
}
private static Stream<Arguments> assertBuildToBeAlteredRuleConfigurationArguments() {
+ Map<String, Collection<DataNode>> twoSegmentTableNodes = Collections.singletonMap("foo_tbl", Collections.singleton(new DataNode("foo_ds.foo_tbl")));
+ Map<String, Collection<DataNode>> schemaTableNodes = Collections.singletonMap("bar_tbl", Collections.singleton(new DataNode("foo_ds.foo_schema.bar_tbl")));
+ Map<String, Collection<DataNode>> dottedTableNodes = Collections.singletonMap(
+ "foo.bar", Arrays.asList(new DataNode("readwrite_ds", "foo_schema", "foo.bar"), new DataNode("bar_ds", "foo_schema", "foo.bar")));
+ Map<String, Collection<DataNode>> suffixTableNodes = Collections.singletonMap("bar", Collections.singleton(new DataNode("foo_ds", "foo_schema", "bar")));
return Stream.of(
- Arguments.of("unload all tables keeps altered config empty", Arrays.asList("foo_ds.foo_tbl", "foo_ds.bar_tbl"), new UnloadSingleTableStatement(true, Collections.emptyList()),
- Collections.emptyList()),
- Arguments.of("unload one table removes matching two-segment node", Arrays.asList("foo_ds.foo_tbl", "foo_ds.bar_tbl"),
+ Arguments.of("unload all tables keeps altered config empty", false, Arrays.asList("foo_ds.foo_tbl", "foo_ds.bar_tbl"), Collections.emptyMap(),
+ new UnloadSingleTableStatement(true, Collections.emptyList()), Collections.emptyList()),
+ Arguments.of("unload one table removes matching two-segment node", false, Arrays.asList("foo_ds.foo_tbl", "foo_ds.bar_tbl"), twoSegmentTableNodes,
new UnloadSingleTableStatement(false, Collections.singletonList("foo_tbl")), Collections.singleton("foo_ds.bar_tbl")),
- Arguments.of("unload one table removes matching three-segment node", Arrays.asList("foo_ds.foo_schema.bar_tbl", "foo_ds.foo_tbl"),
- new UnloadSingleTableStatement(false, Collections.singletonList("bar_tbl")), Collections.singleton("foo_ds.foo_tbl")));
+ Arguments.of("unload one table removes matching three-segment node", true, Arrays.asList("foo_ds.foo_schema.bar_tbl", "foo_ds.foo_tbl"), schemaTableNodes,
+ new UnloadSingleTableStatement(false, Collections.singletonList("bar_tbl")), Collections.singleton("foo_ds.foo_tbl")),
+ Arguments.of("unload dotted table removes all exact nodes", false, Arrays.asList("readwrite_ds.foo.bar", "bar_ds.foo.bar", "foo_ds.bar"), dottedTableNodes,
+ new UnloadSingleTableStatement(false, Collections.singletonList("foo.bar")), Collections.singleton("foo_ds.bar")),
+ Arguments.of("unload suffix table preserves dotted table", false, Arrays.asList("foo_ds.bar", "foo_ds.foo.bar"), suffixTableNodes,
+ new UnloadSingleTableStatement(false, Collections.singletonList("bar")), Collections.singleton("foo_ds.foo.bar")));
}
private static Stream<Arguments> assertBuildToBeDroppedRuleConfigurationArguments() {
diff --git a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/persist/service/StandaloneMetaDataManagerPersistService.java b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/persist/service/StandaloneMetaDataManagerPersistService.java
index 4080811390d..825e6624351 100644
--- a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/persist/service/StandaloneMetaDataManagerPersistService.java
+++ b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/persist/service/StandaloneMetaDataManagerPersistService.java
@@ -29,6 +29,7 @@ import org.apache.shardingsphere.infra.metadata.database.schema.builder.GenericS
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereView;
+import org.apache.shardingsphere.infra.rule.attribute.table.TableMapperRuleAttribute;
import org.apache.shardingsphere.infra.rule.scope.GlobalRule;
import org.apache.shardingsphere.infra.rule.scope.GlobalRule.GlobalRuleChangedType;
import org.apache.shardingsphere.infra.spi.type.ordered.cache.OrderedServicesCache;
@@ -229,10 +230,13 @@ public final class StandaloneMetaDataManagerPersistService implements MetaDataMa
}
private void alterSingleRuleConfigurationItem(final ShardingSphereDatabase database, final SingleRuleConfiguration toBeAlteredRuleConfig) {
- Collection<String> originalSingleTables = database.getRuleMetaData().getSingleRule(SingleRule.class).getConfiguration().getLogicTableNames();
- Collection<String> needReloadTables = toBeAlteredRuleConfig.getLogicTableNames().stream().filter(each -> !originalSingleTables.contains(each)).collect(Collectors.toList());
+ Collection<String> originalSingleTables = database.getRuleMetaData().getSingleRule(SingleRule.class).getAttributes()
+ .getAttribute(TableMapperRuleAttribute.class).getLogicTableNames();
Collection<MetaDataVersion> metaDataVersions = metaDataPersistFacade.getDatabaseRuleService().persist(database.getName(), Collections.singleton(toBeAlteredRuleConfig));
alterRuleItem(database.getName(), metaDataVersions);
+ ShardingSphereDatabase refreshedDatabase = metaDataContextManager.getMetaDataContexts().getMetaData().getDatabase(database.getName());
+ Collection<String> needReloadTables = refreshedDatabase.getRuleMetaData().getSingleRule(SingleRule.class).getAttributes()
+ .getAttribute(TableMapperRuleAttribute.class).getLogicTableNames().stream().filter(each -> !originalSingleTables.contains(each)).collect(Collectors.toList());
persistAndAlterSchemaTables(database, needReloadTables);
clearServicesCache();
}
diff --git a/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/persist/service/StandaloneMetaDataManagerPersistServiceTest.java b/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/persist/service/StandaloneMetaDataManagerPersistServiceTest.java
index 049b50e26fb..707708c5a5c 100644
--- a/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/persist/service/StandaloneMetaDataManagerPersistServiceTest.java
+++ b/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/persist/service/StandaloneMetaDataManagerPersistServiceTest.java
@@ -29,6 +29,7 @@ import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSp
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.rule.attribute.RuleAttributes;
+import org.apache.shardingsphere.infra.rule.attribute.table.TableMapperRuleAttribute;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.mode.metadata.manager.MetaDataContextManager;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistFacade;
@@ -183,18 +184,26 @@ class StandaloneMetaDataManagerPersistServiceTest {
void assertAlterRuleConfigurationWithSingleRule() {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn("foo_db");
- when(database.getProtocolType()).thenReturn(TypedSPILoader.getService(DatabaseType.class, "MySQL"));
- when(database.getDefaultSchemaName()).thenReturn("foo_default_schema");
- SingleRule singleRule = mock(SingleRule.class);
- when(singleRule.getConfiguration()).thenReturn(new SingleRuleConfiguration(Collections.singleton("foo_ds.foo_tbl"), null));
- when(singleRule.getAttributes()).thenReturn(new RuleAttributes());
- when(database.getRuleMetaData()).thenReturn(new RuleMetaData(Collections.singleton(singleRule)));
- ShardingSphereMetaData metaData = new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), new ConfigurationProperties(new Properties()));
+ TableMapperRuleAttribute originalTableMapperRuleAttribute = mock(TableMapperRuleAttribute.class);
+ when(originalTableMapperRuleAttribute.getLogicTableNames()).thenReturn(Collections.singleton("foo_tbl"));
+ SingleRule originalSingleRule = mock(SingleRule.class);
+ when(originalSingleRule.getAttributes()).thenReturn(new RuleAttributes(originalTableMapperRuleAttribute));
+ when(database.getRuleMetaData()).thenReturn(new RuleMetaData(Collections.singleton(originalSingleRule)));
+ ShardingSphereDatabase refreshedDatabase = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
+ when(refreshedDatabase.getName()).thenReturn("foo_db");
+ when(refreshedDatabase.getProtocolType()).thenReturn(TypedSPILoader.getService(DatabaseType.class, "MySQL"));
+ when(refreshedDatabase.getDefaultSchemaName()).thenReturn("foo_default_schema");
+ TableMapperRuleAttribute refreshedTableMapperRuleAttribute = mock(TableMapperRuleAttribute.class);
+ when(refreshedTableMapperRuleAttribute.getLogicTableNames()).thenReturn(Arrays.asList("foo_tbl", "foo_order.foo_item"));
+ SingleRule refreshedSingleRule = mock(SingleRule.class);
+ when(refreshedSingleRule.getAttributes()).thenReturn(new RuleAttributes(refreshedTableMapperRuleAttribute));
+ when(refreshedDatabase.getRuleMetaData()).thenReturn(new RuleMetaData(Collections.singleton(refreshedSingleRule)));
+ ShardingSphereMetaData metaData = new ShardingSphereMetaData(Collections.singleton(refreshedDatabase), mock(), mock(), new ConfigurationProperties(new Properties()));
when(metaDataContextManager.getMetaDataContexts().getMetaData()).thenReturn(metaData);
- SingleRuleConfiguration ruleConfig = new SingleRuleConfiguration(Arrays.asList("foo_ds.foo_tbl", "foo_ds.bar_tbl"), null);
+ SingleRuleConfiguration ruleConfig = new SingleRuleConfiguration(Arrays.asList("foo_ds.foo_tbl", "foo_ds.foo_order.foo_item"), null);
metaDataManagerPersistService.alterRuleConfiguration(database, ruleConfig);
verify(metaDataPersistFacade.getDatabaseRuleService()).persist("foo_db", Collections.singleton(ruleConfig));
- verify(metaDataPersistFacade.getDatabaseMetaDataFacade()).persistAlteredTables(eq("foo_db"), any(), eq(Collections.singletonList("bar_tbl")));
+ verify(metaDataPersistFacade.getDatabaseMetaDataFacade()).persistAlteredTables(eq("foo_db"), any(), eq(Collections.singletonList("foo_order.foo_item")));
}
@Test