This is an automated email from the ASF dual-hosted git repository.
zhonghongsheng 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 292414a3501 Refactor StringPkSmallOrderDAO and IntPkOrderItemDAO to
use schema name (#37873)
292414a3501 is described below
commit 292414a350106e3997b1c5499e440a19095cc500
Author: Hongsheng Zhong <[email protected]>
AuthorDate: Wed Jan 28 18:44:41 2026 +0800
Refactor StringPkSmallOrderDAO and IntPkOrderItemDAO to use schema name
(#37873)
* Refactor StringPkSmallOrderDAO to use QualifiedTable
* Refactor IntPkOrderItemDAO constructor: add schemaName param
* Refactor IntPkOrderItemSQLBuilder: add schemaPrefix param
---
.../operation/pipeline/cases/PipelineContainerComposer.java | 1 +
.../cases/migration/general/MySQLMigrationGeneralE2EIT.java | 2 +-
.../migration/general/PostgreSQLMigrationGeneralE2EIT.java | 7 +++----
.../cases/migration/general/RulesMigrationE2EIT.java | 3 ++-
.../cases/migration/primarykey/MariaDBMigrationE2EIT.java | 3 ++-
.../migration/primarykey/TextPrimaryKeyMigrationE2EIT.java | 4 +++-
.../pipeline/dao/order/small/StringPkSmallOrderDAO.java | 13 +++++++------
.../small/sqlbuilder/MySQLStringPkSmallOrderSQLBuilder.java | 4 ++--
.../sqlbuilder/OpenGaussStringPkSmallOrderSQLBuilder.java | 4 ++--
.../sqlbuilder/PostgreSQLStringPkSmallOrderSQLBuilder.java | 4 ++--
.../small/sqlbuilder/StringPkSmallOrderSQLBuilder.java | 10 +++++-----
.../operation/pipeline/dao/orderitem/IntPkOrderItemDAO.java | 11 +++++++----
.../dao/orderitem/sqlbuilder/IntPkOrderItemSQLBuilder.java | 6 ++++--
.../orderitem/sqlbuilder/MySQLIntPkOrderItemSQLBuilder.java | 4 ++--
.../sqlbuilder/OpenGaussIntPkOrderItemSQLBuilder.java | 12 ++++++------
.../sqlbuilder/PostgreSQLIntPkOrderItemSQLBuilder.java | 12 ++++++------
16 files changed, 55 insertions(+), 45 deletions(-)
diff --git
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/PipelineContainerComposer.java
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/PipelineContainerComposer.java
index 90c3b8f5b02..baf0e8e91a9 100644
---
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/PipelineContainerComposer.java
+++
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/PipelineContainerComposer.java
@@ -333,6 +333,7 @@ public final class PipelineContainerComposer implements
AutoCloseable {
* @param tableName table name
* @return qualified table
*/
+ // TODO Rename, add schema
public QualifiedTable createQualifiedTable(final String tableName) {
String schemaName = new
DatabaseTypeRegistry(databaseType).getDialectDatabaseMetaData().getSchemaOption().isSchemaAvailable()
? SCHEMA_NAME : null;
return new QualifiedTable(schemaName, tableName);
diff --git
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/general/MySQLMigrationGeneralE2EIT.java
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/general/MySQLMigrationGeneralE2EIT.java
index 87406f55170..3fab6209c1c 100644
---
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/general/MySQLMigrationGeneralE2EIT.java
+++
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/general/MySQLMigrationGeneralE2EIT.java
@@ -67,7 +67,7 @@ class MySQLMigrationGeneralE2EIT extends
AbstractMigrationE2EIT {
distSQLFacade.alterPipelineRule();
IntPkLargeOrderDAO orderDAO = new
IntPkLargeOrderDAO(containerComposer.getSourceDataSource(),
containerComposer.getDatabaseType(), new QualifiedTable(null,
SOURCE_TABLE_NAME));
orderDAO.createTable();
- IntPkOrderItemDAO orderItemDAO = new
IntPkOrderItemDAO(containerComposer.getSourceDataSource(),
containerComposer.getDatabaseType());
+ IntPkOrderItemDAO orderItemDAO = new
IntPkOrderItemDAO(containerComposer.getSourceDataSource(),
containerComposer.getDatabaseType(), null);
orderItemDAO.createTable();
addMigrationSourceResource(containerComposer);
addMigrationTargetResource(containerComposer);
diff --git
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/general/PostgreSQLMigrationGeneralE2EIT.java
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/general/PostgreSQLMigrationGeneralE2EIT.java
index 27836a574d5..94d0c4c53b8 100644
---
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/general/PostgreSQLMigrationGeneralE2EIT.java
+++
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/general/PostgreSQLMigrationGeneralE2EIT.java
@@ -20,7 +20,6 @@ package
org.apache.shardingsphere.test.e2e.operation.pipeline.cases.migration.ge
import lombok.extern.slf4j.Slf4j;
import
org.apache.shardingsphere.data.pipeline.scenario.migration.MigrationJobType;
import
org.apache.shardingsphere.infra.algorithm.keygen.snowflake.SnowflakeKeyGenerateAlgorithm;
-import org.apache.shardingsphere.infra.metadata.database.schema.QualifiedTable;
import
org.apache.shardingsphere.test.e2e.operation.pipeline.cases.PipelineContainerComposer;
import
org.apache.shardingsphere.test.e2e.operation.pipeline.cases.migration.AbstractMigrationE2EIT;
import
org.apache.shardingsphere.test.e2e.operation.pipeline.cases.task.E2EIncrementalTask;
@@ -66,10 +65,10 @@ class PostgreSQLMigrationGeneralE2EIT extends
AbstractMigrationE2EIT {
PipelineE2EDistSQLFacade distSQLFacade = new
PipelineE2EDistSQLFacade(containerComposer, new MigrationJobType());
distSQLFacade.alterPipelineRule();
createSourceSchema(containerComposer,
PipelineContainerComposer.SCHEMA_NAME);
- IntPkLargeOrderDAO orderDAO = new
IntPkLargeOrderDAO(containerComposer.getSourceDataSource(),
containerComposer.getDatabaseType(),
- new QualifiedTable(PipelineContainerComposer.SCHEMA_NAME,
SOURCE_TABLE_NAME));
+ IntPkLargeOrderDAO orderDAO = new
IntPkLargeOrderDAO(containerComposer.getSourceDataSource(),
+ containerComposer.getDatabaseType(),
containerComposer.createQualifiedTable(SOURCE_TABLE_NAME));
orderDAO.createTable();
- IntPkOrderItemDAO orderItemDAO = new
IntPkOrderItemDAO(containerComposer.getSourceDataSource(),
containerComposer.getDatabaseType());
+ IntPkOrderItemDAO orderItemDAO = new
IntPkOrderItemDAO(containerComposer.getSourceDataSource(),
containerComposer.getDatabaseType(), PipelineContainerComposer.SCHEMA_NAME);
orderItemDAO.createTable();
containerComposer.createSourceTableIndexList(PipelineContainerComposer.SCHEMA_NAME,
SOURCE_TABLE_NAME);
containerComposer.createSourceCommentOnList(PipelineContainerComposer.SCHEMA_NAME,
SOURCE_TABLE_NAME);
diff --git
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/general/RulesMigrationE2EIT.java
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/general/RulesMigrationE2EIT.java
index aa12f6bae6e..cddd944f967 100644
---
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/general/RulesMigrationE2EIT.java
+++
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/general/RulesMigrationE2EIT.java
@@ -18,6 +18,7 @@
package
org.apache.shardingsphere.test.e2e.operation.pipeline.cases.migration.general;
import
org.apache.shardingsphere.data.pipeline.scenario.migration.MigrationJobType;
+import org.apache.shardingsphere.infra.metadata.database.schema.QualifiedTable;
import
org.apache.shardingsphere.test.e2e.operation.pipeline.cases.PipelineContainerComposer;
import
org.apache.shardingsphere.test.e2e.operation.pipeline.cases.migration.AbstractMigrationE2EIT;
import
org.apache.shardingsphere.test.e2e.operation.pipeline.dao.order.small.StringPkSmallOrderDAO;
@@ -74,7 +75,7 @@ class RulesMigrationE2EIT extends AbstractMigrationE2EIT {
}
private void assertMigrationSuccess(final PipelineContainerComposer
containerComposer, final Callable<Void> addRuleFn) throws Exception {
- StringPkSmallOrderDAO orderDAO = new
StringPkSmallOrderDAO(containerComposer.getSourceDataSource(),
containerComposer.getDatabaseType(), SOURCE_TABLE_NAME);
+ StringPkSmallOrderDAO orderDAO = new
StringPkSmallOrderDAO(containerComposer.getSourceDataSource(),
containerComposer.getDatabaseType(), new QualifiedTable(null,
SOURCE_TABLE_NAME));
orderDAO.createTable();
orderDAO.batchInsert(PipelineContainerComposer.TABLE_INIT_ROW_COUNT);
addMigrationSourceResource(containerComposer);
diff --git
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/primarykey/MariaDBMigrationE2EIT.java
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/primarykey/MariaDBMigrationE2EIT.java
index 17ec9e9ee4b..44fd41b4d85 100644
---
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/primarykey/MariaDBMigrationE2EIT.java
+++
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/primarykey/MariaDBMigrationE2EIT.java
@@ -18,6 +18,7 @@
package
org.apache.shardingsphere.test.e2e.operation.pipeline.cases.migration.primarykey;
import
org.apache.shardingsphere.data.pipeline.scenario.migration.MigrationJobType;
+import org.apache.shardingsphere.infra.metadata.database.schema.QualifiedTable;
import
org.apache.shardingsphere.test.e2e.operation.pipeline.cases.PipelineContainerComposer;
import
org.apache.shardingsphere.test.e2e.operation.pipeline.cases.migration.AbstractMigrationE2EIT;
import
org.apache.shardingsphere.test.e2e.operation.pipeline.dao.order.small.StringPkSmallOrderDAO;
@@ -54,7 +55,7 @@ class MariaDBMigrationE2EIT extends AbstractMigrationE2EIT {
@ArgumentsSource(PipelineE2ETestCaseArgumentsProvider.class)
void assertMigrationSuccess(final PipelineTestParameter testParam) throws
SQLException {
try (PipelineContainerComposer containerComposer = new
PipelineContainerComposer(testParam)) {
- StringPkSmallOrderDAO orderDAO = new
StringPkSmallOrderDAO(containerComposer.getSourceDataSource(),
containerComposer.getDatabaseType(), SOURCE_TABLE_NAME);
+ StringPkSmallOrderDAO orderDAO = new
StringPkSmallOrderDAO(containerComposer.getSourceDataSource(),
containerComposer.getDatabaseType(), new QualifiedTable(null,
SOURCE_TABLE_NAME));
orderDAO.createTable();
orderDAO.batchInsert(PipelineContainerComposer.TABLE_INIT_ROW_COUNT);
PipelineE2EDistSQLFacade distSQLFacade = new
PipelineE2EDistSQLFacade(containerComposer, new MigrationJobType());
diff --git
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/primarykey/TextPrimaryKeyMigrationE2EIT.java
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/primarykey/TextPrimaryKeyMigrationE2EIT.java
index 45be39c49c4..4ffe71f6027 100644
---
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/primarykey/TextPrimaryKeyMigrationE2EIT.java
+++
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/primarykey/TextPrimaryKeyMigrationE2EIT.java
@@ -20,6 +20,7 @@ package
org.apache.shardingsphere.test.e2e.operation.pipeline.cases.migration.pr
import com.google.common.collect.ImmutableMap;
import
org.apache.shardingsphere.data.pipeline.scenario.migration.MigrationJobType;
import
org.apache.shardingsphere.database.connector.mysql.type.MySQLDatabaseType;
+import org.apache.shardingsphere.infra.metadata.database.schema.QualifiedTable;
import
org.apache.shardingsphere.test.e2e.operation.pipeline.cases.PipelineContainerComposer;
import
org.apache.shardingsphere.test.e2e.operation.pipeline.cases.migration.AbstractMigrationE2EIT;
import
org.apache.shardingsphere.test.e2e.operation.pipeline.dao.order.small.StringPkSmallOrderDAO;
@@ -52,7 +53,8 @@ class TextPrimaryKeyMigrationE2EIT extends
AbstractMigrationE2EIT {
@ArgumentsSource(PipelineE2ETestCaseArgumentsProvider.class)
void assertTextPrimaryMigrationSuccess(final PipelineTestParameter
testParam) throws SQLException {
try (PipelineContainerComposer containerComposer = new
PipelineContainerComposer(testParam)) {
- StringPkSmallOrderDAO orderDAO = new
StringPkSmallOrderDAO(containerComposer.getSourceDataSource(),
containerComposer.getDatabaseType(), getSourceTableName(containerComposer));
+ StringPkSmallOrderDAO orderDAO = new
StringPkSmallOrderDAO(containerComposer.getSourceDataSource(),
+ containerComposer.getDatabaseType(), new
QualifiedTable(null, getSourceTableName(containerComposer)));
orderDAO.createTable();
orderDAO.batchInsert(PipelineContainerComposer.TABLE_INIT_ROW_COUNT);
PipelineE2EDistSQLFacade distSQLFacade = new
PipelineE2EDistSQLFacade(containerComposer, new MigrationJobType());
diff --git
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/order/small/StringPkSmallOrderDAO.java
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/order/small/StringPkSmallOrderDAO.java
index 281c0780b2c..6fc64162bf6 100644
---
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/order/small/StringPkSmallOrderDAO.java
+++
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/order/small/StringPkSmallOrderDAO.java
@@ -21,6 +21,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPILoader;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import
org.apache.shardingsphere.infra.algorithm.keygen.uuid.UUIDKeyGenerateAlgorithm;
+import org.apache.shardingsphere.infra.metadata.database.schema.QualifiedTable;
import
org.apache.shardingsphere.test.e2e.operation.pipeline.dao.order.small.sqlbuilder.StringPkSmallOrderSQLBuilder;
import
org.apache.shardingsphere.test.e2e.operation.pipeline.framework.helper.PipelineCaseHelper;
import
org.apache.shardingsphere.test.e2e.operation.pipeline.util.DataSourceExecuteUtils;
@@ -39,12 +40,12 @@ public final class StringPkSmallOrderDAO {
private final StringPkSmallOrderSQLBuilder sqlBuilder;
- private final String tableName;
+ private final String qualifiedTableName;
- public StringPkSmallOrderDAO(final DataSource dataSource, final
DatabaseType databaseType, final String tableName) {
+ public StringPkSmallOrderDAO(final DataSource dataSource, final
DatabaseType databaseType, final QualifiedTable qualifiedTable) {
this.dataSource = dataSource;
this.sqlBuilder =
DatabaseTypedSPILoader.getService(StringPkSmallOrderSQLBuilder.class,
databaseType);
- this.tableName = tableName;
+ this.qualifiedTableName = qualifiedTable.format();
}
/**
@@ -53,7 +54,7 @@ public final class StringPkSmallOrderDAO {
* @throws SQLException SQL exception
*/
public void createTable() throws SQLException {
- String sql = sqlBuilder.buildCreateTableSQL(tableName);
+ String sql = sqlBuilder.buildCreateTableSQL(qualifiedTableName);
log.info("Create string pk small order table SQL: {}", sql);
DataSourceExecuteUtils.execute(dataSource, sql);
}
@@ -66,7 +67,7 @@ public final class StringPkSmallOrderDAO {
*/
public void batchInsert(final int recordCount) throws SQLException {
List<Object[]> paramsList =
PipelineCaseHelper.generateSmallOrderInsertData(new UUIDKeyGenerateAlgorithm(),
recordCount);
- String sql = sqlBuilder.buildPreparedInsertSQL(tableName);
+ String sql = sqlBuilder.buildPreparedInsertSQL(qualifiedTableName);
log.info("Batch insert string pk small order SQL: {}, params list
size: {}", sql, paramsList.size());
DataSourceExecuteUtils.execute(dataSource, sql, paramsList);
}
@@ -80,7 +81,7 @@ public final class StringPkSmallOrderDAO {
* @throws SQLException SQL exception
*/
public void insert(final String orderId, final int userId, final String
status) throws SQLException {
- String sql = sqlBuilder.buildPreparedInsertSQL(tableName);
+ String sql = sqlBuilder.buildPreparedInsertSQL(qualifiedTableName);
Object[] params = new Object[]{orderId, userId, status};
log.info("Insert string pk small order SQL: {}, params: {}", sql,
params);
DataSourceExecuteUtils.execute(dataSource, sql, params);
diff --git
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/order/small/sqlbuilder/MySQLStringPkSmallOrderSQLBuilder.java
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/order/small/sqlbuilder/MySQLStringPkSmallOrderSQLBuilder.java
index ca68a42234f..46a5c13122d 100644
---
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/order/small/sqlbuilder/MySQLStringPkSmallOrderSQLBuilder.java
+++
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/order/small/sqlbuilder/MySQLStringPkSmallOrderSQLBuilder.java
@@ -20,7 +20,7 @@ package
org.apache.shardingsphere.test.e2e.operation.pipeline.dao.order.small.sq
public final class MySQLStringPkSmallOrderSQLBuilder implements
StringPkSmallOrderSQLBuilder {
@Override
- public String buildCreateTableSQL(final String tableName) {
+ public String buildCreateTableSQL(final String qualifiedTableName) {
return String.format("""
CREATE TABLE `%s` (
`order_id` varchar(255) NOT NULL COMMENT 'pk id',
@@ -30,7 +30,7 @@ public final class MySQLStringPkSmallOrderSQLBuilder
implements StringPkSmallOrd
PRIMARY KEY ( `order_id` ),
INDEX ( `user_id` )
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_general_ci
- """, tableName);
+ """, qualifiedTableName);
}
@Override
diff --git
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/order/small/sqlbuilder/OpenGaussStringPkSmallOrderSQLBuilder.java
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/order/small/sqlbuilder/OpenGaussStringPkSmallOrderSQLBuilder.java
index c9db3c83390..8a99d01c7e4 100644
---
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/order/small/sqlbuilder/OpenGaussStringPkSmallOrderSQLBuilder.java
+++
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/order/small/sqlbuilder/OpenGaussStringPkSmallOrderSQLBuilder.java
@@ -20,7 +20,7 @@ package
org.apache.shardingsphere.test.e2e.operation.pipeline.dao.order.small.sq
public final class OpenGaussStringPkSmallOrderSQLBuilder implements
StringPkSmallOrderSQLBuilder {
@Override
- public String buildCreateTableSQL(final String tableName) {
+ public String buildCreateTableSQL(final String qualifiedTableName) {
return String.format("""
CREATE TABLE %s (
order_id varchar(255) NOT NULL,
@@ -29,7 +29,7 @@ public final class OpenGaussStringPkSmallOrderSQLBuilder
implements StringPkSmal
t_unsigned_int int NULL,
PRIMARY KEY (order_id)
)
- """, tableName);
+ """, qualifiedTableName);
}
@Override
diff --git
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/order/small/sqlbuilder/PostgreSQLStringPkSmallOrderSQLBuilder.java
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/order/small/sqlbuilder/PostgreSQLStringPkSmallOrderSQLBuilder.java
index d730ee12ddc..b94b35fad4c 100644
---
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/order/small/sqlbuilder/PostgreSQLStringPkSmallOrderSQLBuilder.java
+++
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/order/small/sqlbuilder/PostgreSQLStringPkSmallOrderSQLBuilder.java
@@ -20,7 +20,7 @@ package
org.apache.shardingsphere.test.e2e.operation.pipeline.dao.order.small.sq
public final class PostgreSQLStringPkSmallOrderSQLBuilder implements
StringPkSmallOrderSQLBuilder {
@Override
- public String buildCreateTableSQL(final String tableName) {
+ public String buildCreateTableSQL(final String qualifiedTableName) {
return String.format("""
CREATE TABLE %s (
order_id varchar(255) NOT NULL,
@@ -29,7 +29,7 @@ public final class PostgreSQLStringPkSmallOrderSQLBuilder
implements StringPkSma
t_unsigned_int int NULL,
PRIMARY KEY (order_id)
)
- """, tableName);
+ """, qualifiedTableName);
}
@Override
diff --git
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/order/small/sqlbuilder/StringPkSmallOrderSQLBuilder.java
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/order/small/sqlbuilder/StringPkSmallOrderSQLBuilder.java
index 0331ab37fbf..8da11042322 100644
---
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/order/small/sqlbuilder/StringPkSmallOrderSQLBuilder.java
+++
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/order/small/sqlbuilder/StringPkSmallOrderSQLBuilder.java
@@ -24,18 +24,18 @@ public interface StringPkSmallOrderSQLBuilder extends
DatabaseTypedSPI {
/**
* Build create table SQL.
*
- * @param tableName table name
+ * @param qualifiedTableName qualified table name
* @return create table SQL
*/
- String buildCreateTableSQL(String tableName);
+ String buildCreateTableSQL(String qualifiedTableName);
/**
* Build prepared insert SQL.
*
- * @param tableName table name
+ * @param qualifiedTableName qualified table name
* @return prepared insert SQL
*/
- default String buildPreparedInsertSQL(final String tableName) {
- return String.format("INSERT INTO %s (order_id, user_id, status)
VALUES (?, ?, ?)", tableName);
+ default String buildPreparedInsertSQL(final String qualifiedTableName) {
+ return String.format("INSERT INTO %s (order_id, user_id, status)
VALUES (?, ?, ?)", qualifiedTableName);
}
}
diff --git
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/orderitem/IntPkOrderItemDAO.java
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/orderitem/IntPkOrderItemDAO.java
index 7db401973fc..5f1cd586a66 100644
---
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/orderitem/IntPkOrderItemDAO.java
+++
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/orderitem/IntPkOrderItemDAO.java
@@ -36,9 +36,12 @@ public final class IntPkOrderItemDAO {
private final IntPkOrderItemSQLBuilder sqlBuilder;
- public IntPkOrderItemDAO(final DataSource dataSource, final DatabaseType
databaseType) {
+ private final String schemaPrefix;
+
+ public IntPkOrderItemDAO(final DataSource dataSource, final DatabaseType
databaseType, final String schemaName) {
this.dataSource = dataSource;
sqlBuilder =
DatabaseTypedSPILoader.getService(IntPkOrderItemSQLBuilder.class, databaseType);
+ schemaPrefix = null == schemaName || schemaName.isEmpty() ? "" :
(schemaName + ".");
}
/**
@@ -47,7 +50,7 @@ public final class IntPkOrderItemDAO {
* @throws SQLException SQL exception
*/
public void createTable() throws SQLException {
- String sql = sqlBuilder.buildCreateTableSQL();
+ String sql = sqlBuilder.buildCreateTableSQL(schemaPrefix);
log.info("Create order_item table SQL: {}", sql);
DataSourceExecuteUtils.execute(dataSource, sql);
}
@@ -60,7 +63,7 @@ public final class IntPkOrderItemDAO {
*/
public void batchInsert(final int recordCount) throws SQLException {
List<Object[]> paramsList =
PipelineCaseHelper.generateOrderItemInsertData(new
AutoIncrementKeyGenerateAlgorithm(), recordCount);
- String sql = sqlBuilder.buildPreparedInsertSQL();
+ String sql = sqlBuilder.buildPreparedInsertSQL(schemaPrefix);
log.info("Batch insert order_item SQL: {}, params list size: {}", sql,
paramsList.size());
DataSourceExecuteUtils.execute(dataSource, sql, paramsList);
}
@@ -75,7 +78,7 @@ public final class IntPkOrderItemDAO {
* @throws SQLException SQL exception
*/
public void insert(final long itemId, final long orderId, final int
userId, final String status) throws SQLException {
- String sql = sqlBuilder.buildPreparedInsertSQL();
+ String sql = sqlBuilder.buildPreparedInsertSQL(schemaPrefix);
Object[] params = new Object[]{itemId, orderId, userId, status};
log.info("Insert order_item SQL: {}, params: {}", sql, params);
DataSourceExecuteUtils.execute(dataSource, sql, params);
diff --git
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/orderitem/sqlbuilder/IntPkOrderItemSQLBuilder.java
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/orderitem/sqlbuilder/IntPkOrderItemSQLBuilder.java
index 99b68fe99d3..fa8fe21db67 100644
---
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/orderitem/sqlbuilder/IntPkOrderItemSQLBuilder.java
+++
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/orderitem/sqlbuilder/IntPkOrderItemSQLBuilder.java
@@ -24,14 +24,16 @@ public interface IntPkOrderItemSQLBuilder extends
DatabaseTypedSPI {
/**
* Build create table SQL.
*
+ * @param schemaPrefix schema prefix
* @return create table SQL
*/
- String buildCreateTableSQL();
+ String buildCreateTableSQL(String schemaPrefix);
/**
* Build prepared insert SQL.
*
+ * @param schemaPrefix schema prefix
* @return prepared insert SQL
*/
- String buildPreparedInsertSQL();
+ String buildPreparedInsertSQL(String schemaPrefix);
}
diff --git
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/orderitem/sqlbuilder/MySQLIntPkOrderItemSQLBuilder.java
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/orderitem/sqlbuilder/MySQLIntPkOrderItemSQLBuilder.java
index 7c2b50e021d..ccaae35ef96 100644
---
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/orderitem/sqlbuilder/MySQLIntPkOrderItemSQLBuilder.java
+++
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/orderitem/sqlbuilder/MySQLIntPkOrderItemSQLBuilder.java
@@ -20,7 +20,7 @@ package
org.apache.shardingsphere.test.e2e.operation.pipeline.dao.orderitem.sqlb
public final class MySQLIntPkOrderItemSQLBuilder implements
IntPkOrderItemSQLBuilder {
@Override
- public String buildCreateTableSQL() {
+ public String buildCreateTableSQL(final String schemaPrefix) {
return """
CREATE TABLE t_order_item (
item_id bigint NOT NULL,
@@ -33,7 +33,7 @@ public final class MySQLIntPkOrderItemSQLBuilder implements
IntPkOrderItemSQLBui
}
@Override
- public String buildPreparedInsertSQL() {
+ public String buildPreparedInsertSQL(final String schemaPrefix) {
return "INSERT INTO t_order_item (item_id, order_id, user_id, status)
VALUES (?, ?, ?, ?)";
}
diff --git
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/orderitem/sqlbuilder/OpenGaussIntPkOrderItemSQLBuilder.java
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/orderitem/sqlbuilder/OpenGaussIntPkOrderItemSQLBuilder.java
index a9412129f93..256ea9350c6 100644
---
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/orderitem/sqlbuilder/OpenGaussIntPkOrderItemSQLBuilder.java
+++
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/orderitem/sqlbuilder/OpenGaussIntPkOrderItemSQLBuilder.java
@@ -20,21 +20,21 @@ package
org.apache.shardingsphere.test.e2e.operation.pipeline.dao.orderitem.sqlb
public final class OpenGaussIntPkOrderItemSQLBuilder implements
IntPkOrderItemSQLBuilder {
@Override
- public String buildCreateTableSQL() {
- return """
- CREATE TABLE test.t_order_item (
+ public String buildCreateTableSQL(final String schemaPrefix) {
+ return String.format("""
+ CREATE TABLE %st_order_item (
item_id int8 NOT NULL,
order_id int8 NOT NULL,
user_id int4 NOT NULL,
status varchar(50),
PRIMARY KEY (item_id)
)
- """;
+ """, schemaPrefix);
}
@Override
- public String buildPreparedInsertSQL() {
- return "INSERT INTO test.t_order_item (item_id, order_id, user_id,
status) VALUES (?, ?, ?, ?)";
+ public String buildPreparedInsertSQL(final String schemaPrefix) {
+ return String.format("INSERT INTO %st_order_item (item_id, order_id,
user_id, status) VALUES (?, ?, ?, ?)", schemaPrefix);
}
@Override
diff --git
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/orderitem/sqlbuilder/PostgreSQLIntPkOrderItemSQLBuilder.java
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/orderitem/sqlbuilder/PostgreSQLIntPkOrderItemSQLBuilder.java
index 951295785d3..e08dd9410ee 100644
---
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/orderitem/sqlbuilder/PostgreSQLIntPkOrderItemSQLBuilder.java
+++
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/dao/orderitem/sqlbuilder/PostgreSQLIntPkOrderItemSQLBuilder.java
@@ -20,21 +20,21 @@ package
org.apache.shardingsphere.test.e2e.operation.pipeline.dao.orderitem.sqlb
public final class PostgreSQLIntPkOrderItemSQLBuilder implements
IntPkOrderItemSQLBuilder {
@Override
- public String buildCreateTableSQL() {
- return """
- CREATE TABLE test.t_order_item (
+ public String buildCreateTableSQL(final String schemaPrefix) {
+ return String.format("""
+ CREATE TABLE %st_order_item (
item_id int8 NOT NULL,
order_id int8 NOT NULL,
user_id int4 NOT NULL,
status varchar(50),
PRIMARY KEY (item_id)
)
- """;
+ """, schemaPrefix);
}
@Override
- public String buildPreparedInsertSQL() {
- return "INSERT INTO test.t_order_item (item_id, order_id, user_id,
status) VALUES (?, ?, ?, ?)";
+ public String buildPreparedInsertSQL(final String schemaPrefix) {
+ return String.format("INSERT INTO %st_order_item (item_id, order_id,
user_id, status) VALUES (?, ?, ?, ?)", schemaPrefix);
}
@Override