This is an automated email from the ASF dual-hosted git repository. menghaoran pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push: new b27cedf78a1 Improve "show migration check status jobId": update table formatting (#35340) b27cedf78a1 is described below commit b27cedf78a1016f4d9bd5097a4cf5234f871e71f Author: Hongsheng Zhong <zhonghongsh...@apache.org> AuthorDate: Tue May 6 14:59:19 2025 +0800 Improve "show migration check status jobId": update table formatting (#35340) --- .../infra/metadata/database/schema/QualifiedTable.java | 11 ++++++++++- .../infra/metadata/database/schema/QualifiedTableTest.java | 7 +++++++ .../check/consistency/MigrationDataConsistencyChecker.java | 14 ++++++++------ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/QualifiedTable.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/QualifiedTable.java index c6a77a95010..ec9f2845bbe 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/QualifiedTable.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/QualifiedTable.java @@ -53,6 +53,15 @@ public final class QualifiedTable { return tableName.getValue(); } + /** + * Get qualified table name. + * + * @return qualified table name + */ + public String format() { + return null == getSchemaName() ? getTableName() : String.join(".", getSchemaName(), getTableName()); + } + @Override public boolean equals(final Object o) { if (null == o || getClass() != o.getClass()) { @@ -70,6 +79,6 @@ public final class QualifiedTable { @Override public String toString() { - return null == getSchemaName() ? getTableName() : String.join(".", getSchemaName(), getTableName()); + return format(); } } diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/QualifiedTableTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/QualifiedTableTest.java index cdb62891575..5db3c6eaef1 100644 --- a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/QualifiedTableTest.java +++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/QualifiedTableTest.java @@ -25,6 +25,13 @@ import static org.junit.jupiter.api.Assertions.assertNotEquals; class QualifiedTableTest { + @Test + void assertFormat() { + assertThat(new QualifiedTable("schema", "t_order").format(), is("schema.t_order")); + assertThat(new QualifiedTable("SCHEMA", "T_ORDER").format(), is("SCHEMA.T_ORDER")); + assertThat(new QualifiedTable(null, "t_order").format(), is("t_order")); + } + @Test void assertEqualsTrueWithoutSchema() { QualifiedTable actual = new QualifiedTable(null, "t_order"); diff --git a/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/check/consistency/MigrationDataConsistencyChecker.java b/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/check/consistency/MigrationDataConsistencyChecker.java index 1d2ac52b3d8..ef8df850ecf 100644 --- a/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/check/consistency/MigrationDataConsistencyChecker.java +++ b/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/check/consistency/MigrationDataConsistencyChecker.java @@ -84,7 +84,8 @@ public final class MigrationDataConsistencyChecker implements PipelineDataConsis @Override public Map<String, TableDataConsistencyCheckResult> check(final String algorithmType, final Properties algorithmProps) { List<String> sourceTableNames = new LinkedList<>(); - jobConfig.getJobShardingDataNodes().forEach(each -> each.getEntries().forEach(entry -> entry.getDataNodes().forEach(dataNode -> sourceTableNames.add(dataNode.format())))); + jobConfig.getJobShardingDataNodes().forEach(each -> each.getEntries().forEach(entry -> entry.getDataNodes() + .forEach(dataNode -> sourceTableNames.add(new QualifiedTable(dataNode.getSchemaName(), dataNode.getTableName()).format())))); progressContext.setRecordsCount(getRecordsCount()); progressContext.getTableNames().addAll(sourceTableNames); progressContext.onProgressUpdated(new PipelineJobUpdateProgress(0)); @@ -94,11 +95,11 @@ public final class MigrationDataConsistencyChecker implements PipelineDataConsis TableDataConsistencyChecker tableChecker = TableDataConsistencyCheckerFactory.newInstance(algorithmType, algorithmProps)) { for (JobDataNodeLine each : jobConfig.getJobShardingDataNodes()) { if (checkTableInventoryDataUnmatchedAndBreak(each, tableChecker, result, dataSourceManager)) { - return result.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey().toString(), Entry::getValue)); + return result.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey().format(), Entry::getValue)); } } } - return result.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey().toString(), Entry::getValue)); + return result.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey().format(), Entry::getValue)); } private long getRecordsCount() { @@ -112,10 +113,11 @@ public final class MigrationDataConsistencyChecker implements PipelineDataConsis for (JobDataNodeEntry entry : jobDataNodeLine.getEntries()) { for (DataNode each : entry.getDataNodes()) { TableDataConsistencyCheckResult checkResult = checkSingleTableInventoryData(entry.getLogicTableName(), each, tableChecker, dataSourceManager); - checkResultMap.put(new QualifiedTable(each.getSchemaName(), each.getTableName()), checkResult); + QualifiedTable sourceTable = new QualifiedTable(each.getSchemaName(), each.getTableName()); + checkResultMap.put(sourceTable, checkResult); if (checkResult.isIgnored()) { - progressContext.getIgnoredTableNames().add(each.format()); - log.info("Table '{}' is ignored, ignore type: {}", checkResult.getIgnoredType(), each.format()); + progressContext.getIgnoredTableNames().add(sourceTable.format()); + log.info("Table '{}' is ignored, ignore type: {}", each.format(), checkResult.getIgnoredType()); continue; } if (!checkResult.isMatched() && tableChecker.isBreakOnInventoryCheckNotMatched()) {