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 92487ed7240 Improve heterogeneous databases migration (#35424)
92487ed7240 is described below
commit 92487ed7240bb08230762cdc2131c0dc30cb539c
Author: Hongsheng Zhong <[email protected]>
AuthorDate: Thu May 15 18:07:41 2025 +0800
Improve heterogeneous databases migration (#35424)
* Improve findSchema for heterogeneous databases migration
* Improve SQL builder with different IdentifierPatternType for
heterogeneous databases migration
* Update unmatched method name
---
.../data/pipeline/core/importer/ImporterConfiguration.java | 2 +-
.../core/sqlbuilder/segment/PipelineSQLSegmentBuilder.java | 7 +++++--
.../cases/migration/general/PostgreSQLToMySQLMigrationE2EIT.java | 2 +-
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/importer/ImporterConfiguration.java
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/importer/ImporterConfiguration.java
index f1cfb2abe5e..0903b7d833f 100644
---
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/importer/ImporterConfiguration.java
+++
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/importer/ImporterConfiguration.java
@@ -77,7 +77,7 @@ public final class ImporterConfiguration {
*/
public Optional<String> findSchemaName(final String logicTableName) {
DialectDatabaseMetaData dialectDatabaseMetaData = new
DatabaseTypeRegistry(dataSourceConfig.getDatabaseType()).getDialectDatabaseMetaData();
- return dialectDatabaseMetaData.getSchemaOption().isSchemaAvailable() ?
Optional.of(tableAndSchemaNameMapper.getSchemaName(logicTableName)) :
Optional.empty();
+ return dialectDatabaseMetaData.getSchemaOption().isSchemaAvailable() ?
Optional.ofNullable(tableAndSchemaNameMapper.getSchemaName(logicTableName)) :
Optional.empty();
}
/**
diff --git
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/segment/PipelineSQLSegmentBuilder.java
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/segment/PipelineSQLSegmentBuilder.java
index bb58daa0cc5..ab6567452b3 100644
---
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/segment/PipelineSQLSegmentBuilder.java
+++
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/segment/PipelineSQLSegmentBuilder.java
@@ -28,10 +28,13 @@ import
org.apache.shardingsphere.infra.metadata.database.schema.QualifiedTable;
*/
public final class PipelineSQLSegmentBuilder {
+ private final DatabaseTypeRegistry databaseTypeRegistry;
+
private final DialectDatabaseMetaData dialectDatabaseMetaData;
public PipelineSQLSegmentBuilder(final DatabaseType databaseType) {
- dialectDatabaseMetaData = new
DatabaseTypeRegistry(databaseType).getDialectDatabaseMetaData();
+ databaseTypeRegistry = new DatabaseTypeRegistry(databaseType);
+ dialectDatabaseMetaData =
databaseTypeRegistry.getDialectDatabaseMetaData();
}
/**
@@ -41,7 +44,7 @@ public final class PipelineSQLSegmentBuilder {
* @return escaped identifier
*/
public String getEscapedIdentifier(final String identifier) {
- return "*".equals(identifier) ? identifier :
dialectDatabaseMetaData.getQuoteCharacter().wrap(identifier);
+ return "*".equals(identifier) ? identifier :
dialectDatabaseMetaData.getQuoteCharacter().wrap(databaseTypeRegistry.formatIdentifierPattern(identifier));
}
/**
diff --git
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/migration/general/PostgreSQLToMySQLMigrationE2EIT.java
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/migration/general/PostgreSQLToMySQLMigrationE2EIT.java
index 16b7685a373..d57f6fa5001 100644
---
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/migration/general/PostgreSQLToMySQLMigrationE2EIT.java
+++
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/migration/general/PostgreSQLToMySQLMigrationE2EIT.java
@@ -61,7 +61,7 @@ class PostgreSQLToMySQLMigrationE2EIT extends
AbstractMigrationE2EIT {
@ParameterizedTest(name = "{0}")
@EnabledIf("isEnabled")
@ArgumentsSource(PipelineE2ETestCaseArgumentsProvider.class)
- void assertMySQLToPostgreSQLMigrationSuccess(final PipelineTestParameter
testParam) throws SQLException {
+ void assertMigrationSuccess(final PipelineTestParameter testParam) throws
SQLException {
PostgreSQLContainer<?> postgresqlContainer = null;
try (PipelineContainerComposer containerComposer = new
PipelineContainerComposer(testParam, new MigrationJobType())) {
if (PipelineEnvTypeEnum.DOCKER ==
PipelineE2EEnvironment.getInstance().getItEnvType()) {