diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingTableNodesExecutor.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingTableNodesExecutor.java index 9272c1ccf957e..b0739c3fe1b32 100644 --- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingTableNodesExecutor.java +++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingTableNodesExecutor.java @@ -34,7 +34,7 @@ import java.util.stream.Collectors; /** - * Result set for show sharding table nodes. + * Show sharding table nodes executor. */ public final class ShowShardingTableNodesExecutor implements RQLExecutor { diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/query/RQLExecutor.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/query/RQLExecutor.java index e6ecbc2bbc919..34f254861be81 100644 --- a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/query/RQLExecutor.java +++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/query/RQLExecutor.java @@ -43,11 +43,11 @@ public interface RQLExecutor extends TypedSPI { /** * Get query result rows. * - * @param shardingSphereDatabase ShardingSphere database + * @param database database * @param sqlStatement SQL statement * @return query result rows */ - Collection getRows(ShardingSphereDatabase shardingSphereDatabase, T sqlStatement); + Collection getRows(ShardingSphereDatabase database, T sqlStatement); @Override Class getType(); 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..10c0c05dda6af 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 @@ -18,7 +18,6 @@ package org.apache.shardingsphere.data.pipeline.postgresql.prepare.datasource; import com.google.common.base.Splitter; -import 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; @@ -26,7 +25,6 @@ import java.sql.Connection; import java.sql.SQLException; -import java.util.stream.Collectors; /** * Data source preparer for PostgreSQL. @@ -39,7 +37,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..0831b2259dde2 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(final String sql) { + Assertions.assertNotNull(sqlParserRule.getSQLParserEngine(TypedSPILoader.getService(DatabaseType.class, "MySQL")).parse(sql, false)); } @SneakyThrows(IOException.class) diff --git a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/DDLE2EIT.java b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/DDLE2EIT.java index 1beba8c29f92c..4adfeaa176688 100644 --- a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/DDLE2EIT.java +++ b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/DDLE2EIT.java @@ -139,7 +139,7 @@ private void executeInitSQLs(final SingleE2EContainerComposer containerComposer, if (null == containerComposer.getAssertion().getInitialSQL().getSql()) { return; } - for (String each : Splitter.on(";").trimResults().splitToList(containerComposer.getAssertion().getInitialSQL().getSql())) { + for (String each : Splitter.on(";").trimResults().omitEmptyStrings().splitToList(containerComposer.getAssertion().getInitialSQL().getSql())) { try (PreparedStatement preparedStatement = connection.prepareStatement(each)) { preparedStatement.executeUpdate(); } @@ -159,7 +159,7 @@ private void executeDestroySQLs(final SingleE2EContainerComposer containerCompos if (null == containerComposer.getAssertion().getDestroySQL().getSql()) { return; } - for (String each : Splitter.on(";").trimResults().splitToList(containerComposer.getAssertion().getDestroySQL().getSql())) { + for (String each : Splitter.on(";").trimResults().omitEmptyStrings().splitToList(containerComposer.getAssertion().getDestroySQL().getSql())) { try (PreparedStatement preparedStatement = connection.prepareStatement(each)) { preparedStatement.executeUpdate(); } diff --git a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RALE2EIT.java b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RALE2EIT.java index cf2c3951ccb15..3bb870379f911 100644 --- a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RALE2EIT.java +++ b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RALE2EIT.java @@ -85,7 +85,7 @@ private void executeInitSQLs(final SingleE2EContainerComposer containerComposer, if (null == containerComposer.getAssertion().getInitialSQL().getSql()) { return; } - for (String each : Splitter.on(";").trimResults().splitToList(containerComposer.getAssertion().getInitialSQL().getSql())) { + for (String each : Splitter.on(";").trimResults().omitEmptyStrings().splitToList(containerComposer.getAssertion().getInitialSQL().getSql())) { try (PreparedStatement preparedStatement = connection.prepareStatement(each)) { preparedStatement.executeUpdate(); } @@ -105,7 +105,7 @@ private void executeDestroySQLs(final SingleE2EContainerComposer containerCompos if (null == containerComposer.getAssertion().getDestroySQL().getSql()) { return; } - for (String each : Splitter.on(";").trimResults().splitToList(containerComposer.getAssertion().getDestroySQL().getSql())) { + for (String each : Splitter.on(";").trimResults().omitEmptyStrings().splitToList(containerComposer.getAssertion().getDestroySQL().getSql())) { try (PreparedStatement preparedStatement = connection.prepareStatement(each)) { preparedStatement.executeUpdate(); } diff --git a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RDLE2EIT.java b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RDLE2EIT.java index f09565d594294..3e4d607ec3dcd 100644 --- a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RDLE2EIT.java +++ b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RDLE2EIT.java @@ -99,7 +99,7 @@ private void executeInitSQLs(final SingleE2EContainerComposer containerComposer, if (null == containerComposer.getAssertion().getInitialSQL() || null == containerComposer.getAssertion().getInitialSQL().getSql()) { return; } - for (String each : Splitter.on(";").trimResults().splitToList(containerComposer.getAssertion().getInitialSQL().getSql())) { + for (String each : Splitter.on(";").trimResults().omitEmptyStrings().splitToList(containerComposer.getAssertion().getInitialSQL().getSql())) { try (PreparedStatement preparedStatement = connection.prepareStatement(each)) { preparedStatement.executeUpdate(); Awaitility.await().pollDelay(2L, TimeUnit.SECONDS).until(() -> true); @@ -111,7 +111,7 @@ private void executeDestroySQLs(final SingleE2EContainerComposer containerCompos if (null == containerComposer.getAssertion().getDestroySQL().getSql()) { return; } - for (String each : Splitter.on(";").trimResults().splitToList(containerComposer.getAssertion().getDestroySQL().getSql())) { + for (String each : Splitter.on(";").trimResults().omitEmptyStrings().splitToList(containerComposer.getAssertion().getDestroySQL().getSql())) { try (PreparedStatement preparedStatement = connection.prepareStatement(each)) { preparedStatement.executeUpdate(); Awaitility.await().pollDelay(2L, TimeUnit.SECONDS).until(() -> true);