diff --git a/kernel/data-pipeline/dialect/opengauss/src/main/java/org/apache/shardingsphere/data/pipeline/opengauss/prepare/datasource/OpenGaussDataSourcePreparer.java b/kernel/data-pipeline/dialect/opengauss/src/main/java/org/apache/shardingsphere/data/pipeline/opengauss/prepare/datasource/OpenGaussDataSourcePreparer.java index ba9679fbb2b6a..ba76a9b72137d 100644 --- a/kernel/data-pipeline/dialect/opengauss/src/main/java/org/apache/shardingsphere/data/pipeline/opengauss/prepare/datasource/OpenGaussDataSourcePreparer.java +++ b/kernel/data-pipeline/dialect/opengauss/src/main/java/org/apache/shardingsphere/data/pipeline/opengauss/prepare/datasource/OpenGaussDataSourcePreparer.java @@ -19,7 +19,6 @@ import com.google.common.base.Splitter; import lombok.extern.slf4j.Slf4j; -import org.apache.curator.shaded.com.google.common.base.Strings; import org.apache.shardingsphere.data.pipeline.common.config.CreateTableConfiguration.CreateTableEntry; import org.apache.shardingsphere.data.pipeline.common.datasource.PipelineDataSourceManager; import org.apache.shardingsphere.data.pipeline.core.preparer.datasource.AbstractDataSourcePreparer; @@ -28,7 +27,6 @@ import java.sql.Connection; import java.sql.SQLException; -import java.util.stream.Collectors; /** * Data source preparer for openGauss. @@ -55,7 +53,7 @@ public void prepareTargetTables(final PrepareTargetTablesParameter param) throws for (CreateTableEntry each : param.getCreateTableConfig().getCreateTableEntries()) { String createTargetTableSQL = getCreateTargetTableSQL(each, dataSourceManager, param.getSqlParserEngine()); try (Connection targetConnection = getCachedDataSource(dataSourceManager, each.getTargetDataSourceConfig()).getConnection()) { - for (String sql : Splitter.on(";").trimResults().splitToList(createTargetTableSQL).stream().filter(cs -> !Strings.isNullOrEmpty(cs)).collect(Collectors.toList())) { + for (String sql : Splitter.on(";").trimResults().omitEmptyStrings().splitToList(createTargetTableSQL)) { executeTargetTableSQL(targetConnection, addIfNotExistsForCreateTableSQL(sql)); } } diff --git a/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/prepare/datasource/PostgreSQLDataSourcePreparer.java b/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/prepare/datasource/PostgreSQLDataSourcePreparer.java index abd17f3a8cd20..a99fe07dd0eb7 100644 --- a/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/prepare/datasource/PostgreSQLDataSourcePreparer.java +++ b/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/prepare/datasource/PostgreSQLDataSourcePreparer.java @@ -39,7 +39,7 @@ public void prepareTargetTables(final PrepareTargetTablesParameter param) throws for (CreateTableEntry each : param.getCreateTableConfig().getCreateTableEntries()) { String createTargetTableSQL = getCreateTargetTableSQL(each, dataSourceManager, param.getSqlParserEngine()); try (Connection targetConnection = getCachedDataSource(dataSourceManager, each.getTargetDataSourceConfig()).getConnection()) { - for (String sql : Splitter.on(";").trimResults().splitToList(createTargetTableSQL).stream().filter(cs -> !Strings.isNullOrEmpty(cs)).collect(Collectors.toList())) { + for (String sql : Splitter.on(";").trimResults().omitEmptyStrings().splitToList(createTargetTableSQL)) { executeTargetTableSQL(targetConnection, sql); } } diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationExecutorTest.java index 0d0e9124fcaa6..4c50e1c8aab06 100644 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationExecutorTest.java +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationExecutorTest.java @@ -18,7 +18,6 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable; import com.google.common.base.Splitter; -import com.google.common.base.Strings; import lombok.SneakyThrows; import org.apache.shardingsphere.distsql.statement.ral.queryable.ConvertYamlConfigurationStatement; import org.apache.shardingsphere.infra.database.core.type.DatabaseType; @@ -26,6 +25,7 @@ import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; import org.apache.shardingsphere.parser.rule.SQLParserRule; import org.apache.shardingsphere.parser.rule.builder.DefaultSQLParserRuleConfigurationBuilder; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.io.BufferedReader; @@ -37,7 +37,6 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertNotNull; class ConvertYamlConfigurationExecutorTest { @@ -97,11 +96,11 @@ private void assertRowData(final Collection data, final } private void assertParseSQL(final String actual) { - Splitter.on(";").trimResults().splitToList(actual).forEach(each -> { - if (!Strings.isNullOrEmpty(each)) { - assertNotNull(sqlParserRule.getSQLParserEngine(TypedSPILoader.getService(DatabaseType.class, "MySQL")).parse(each, false)); - } - }); + Splitter.on(";").trimResults().omitEmptyStrings().splitToList(actual).forEach(this::assertNotNull); + } + + private void assertNotNull(String each) { + Assertions.assertNotNull(sqlParserRule.getSQLParserEngine(TypedSPILoader.getService(DatabaseType.class, "MySQL")).parse(each, false)); } @SneakyThrows(IOException.class)