This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 c99f16907b8 Remove SQLStatement.buildAttributes() (#38364)
c99f16907b8 is described below
commit c99f16907b80e0c9e127582f09c3fdeca38307d7
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Mar 7 11:10:29 2026 +0800
Remove SQLStatement.buildAttributes() (#38364)
* Remove SQLStatement.buildAttributes()
* Remove SQLStatement.buildAttributes()
* Remove SQLStatement.buildAttributes()
* Remove SQLStatement.buildAttributes()
---
.../core/advice/SQLRouteCountAdviceTest.java | 1 -
.../engine/BroadcastRouteEngineFactoryTest.java | 1 -
.../CreateBroadcastTableRuleExecutorTest.java | 5 --
.../update/DropBroadcastTableRuleExecutorTest.java | 2 -
.../EncryptShowCreateTableMergedResultTest.java | 1 -
.../token/EncryptTokenGenerateBuilderTest.java | 1 -
.../ddl/EncryptAlterTableTokenGeneratorTest.java | 12 ++---
.../update/AlterEncryptRuleExecutorTest.java | 12 ++---
.../update/CreateEncryptRuleExecutorTest.java | 16 ++-----
.../update/DropEncryptRuleExecutorTest.java | 8 +---
.../handler/update/AlterMaskRuleExecutorTest.java | 17 +++----
.../handler/update/CreateMaskRuleExecutorTest.java | 8 +---
.../handler/update/DropMaskRuleExecutorTest.java | 4 +-
.../AlterReadwriteSplittingRuleExecutorTest.java | 4 +-
.../CreateReadwriteSplittingRuleExecutorTest.java | 28 +++++------
.../DropReadwriteSplittingRuleExecutorTest.java | 19 ++------
.../update/AlterShadowRuleExecutorTest.java | 36 +++++++-------
.../update/CreateShadowRuleExecutorTest.java | 55 ++++++++++------------
.../handler/update/DropShadowRuleExecutorTest.java | 4 +-
.../ShardingAlterTableSupportedCheckerTest.java | 1 -
.../ddl/ShardingDropIndexSupportedCheckerTest.java | 11 ++---
.../merge/ShardingResultMergerEngineTest.java | 1 -
.../ShardingAlterTableRouteContextCheckerTest.java | 10 ++--
.../ShardingDropIndexRouteContextCheckerTest.java | 20 ++++----
.../type/ShardingRouteEngineFactoryTest.java | 2 -
.../ShardingTableBroadcastRouteEngineTest.java | 2 -
.../unicast/ShardingUnicastRouteEngineTest.java | 1 -
.../query/ShowShardingTableNodesExecutorTest.java | 3 --
.../engine/statement/SQLStatementCopyUtils.java | 1 -
.../context/SQLStatementContextFactoryTest.java | 11 +----
.../type/dal/ExplainStatementContextTest.java | 1 -
.../connection/kernel/KernelProcessorTest.java | 1 -
.../parser/sql/SQLStatementParserExecutor.java | 4 +-
.../tableless/TablelessRouteEngineFactoryTest.java | 37 +++++----------
...tDefaultSingleTableStorageUnitExecutorTest.java | 3 --
.../parser/core/featured/DistSQLParserEngine.java | 4 +-
.../kernel/KernelDistSQLStatementParserEngine.java | 4 +-
.../statement/type/HiveDMLStatementVisitor.java | 2 -
.../statement/type/OracleDMLStatementVisitor.java | 1 -
.../statement/core/statement/SQLStatement.java | 6 ---
.../StandardDatabaseProxyConnectorTest.java | 10 ----
.../handler/ProxyBackendHandlerFactoryTest.java | 15 ++----
.../DistSQLProxyBackendHandlerFactoryTest.java | 1 -
.../DistSQLQueryProxyBackendHandlerTest.java | 4 +-
.../DistSQLUpdateProxyBackendHandlerTest.java | 21 +++------
.../distsql/rul/ParseDistSQLExecutorTest.java | 3 --
.../admin/FirebirdAdminExecutorCreatorTest.java | 23 ++-------
.../admin/MySQLAdminExecutorCreatorTest.java | 9 ----
.../admin/PostgreSQLAdminExecutorCreatorTest.java | 3 --
.../command/MySQLCommandPacketFactoryTest.java | 1 -
.../command/query/extended/PortalTest.java | 2 -
.../test/it/sql/binder/SQLBinderIT.java | 1 -
52 files changed, 132 insertions(+), 321 deletions(-)
diff --git
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLRouteCountAdviceTest.java
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLRouteCountAdviceTest.java
index 4adb90218aa..8c0468e1b77 100644
---
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLRouteCountAdviceTest.java
+++
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLRouteCountAdviceTest.java
@@ -78,7 +78,6 @@ class SQLRouteCountAdviceTest {
}
private static QueryContext createQueryContext(final SQLStatement
sqlStatement) {
- sqlStatement.buildAttributes();
return new QueryContext(new CommonSQLStatementContext(sqlStatement),
"", Collections.emptyList(), new HintValueContext(), mockConnectionContext(),
mock(ShardingSphereMetaData.class));
}
diff --git
a/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/route/engine/BroadcastRouteEngineFactoryTest.java
b/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/route/engine/BroadcastRouteEngineFactoryTest.java
index c9e2d619f3b..7ef15b339a4 100644
---
a/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/route/engine/BroadcastRouteEngineFactoryTest.java
+++
b/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/route/engine/BroadcastRouteEngineFactoryTest.java
@@ -88,7 +88,6 @@ class BroadcastRouteEngineFactoryTest {
void assertNewInstanceWithCursorContextAvailableAndIsAllBroadcastTables() {
CursorHeldSQLStatementContext sqlStatementContext =
mock(CursorHeldSQLStatementContext.class, RETURNS_DEEP_STUBS);
CloseStatement closeStatement = new CloseStatement(databaseType,
mock(), false);
- closeStatement.buildAttributes();
when(sqlStatementContext.getSqlStatement()).thenReturn(closeStatement);
when(sqlStatementContext.getTablesContext()).thenReturn(createTablesContext());
when(queryContext.getSqlStatementContext()).thenReturn(sqlStatementContext);
diff --git
a/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/CreateBroadcastTableRuleExecutorTest.java
b/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/CreateBroadcastTableRuleExecutorTest.java
index a77db9eb409..b025b5f29ae 100644
---
a/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/CreateBroadcastTableRuleExecutorTest.java
+++
b/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/CreateBroadcastTableRuleExecutorTest.java
@@ -48,7 +48,6 @@ class CreateBroadcastTableRuleExecutorTest {
@Test
void assertExecuteUpdateWithEmptyStorageUnits() {
CreateBroadcastTableRuleStatement sqlStatement = new
CreateBroadcastTableRuleStatement(false, Collections.singleton("t_address"));
- sqlStatement.buildAttributes();
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
when(database.getResourceMetaData().getStorageUnits()).thenReturn(Collections.emptyMap());
assertThrows(EmptyStorageUnitException.class, () -> new
DistSQLUpdateExecuteEngine(sqlStatement, "foo_db", mockContextManager(database,
mock(BroadcastRule.class)), null).executeUpdate());
@@ -57,7 +56,6 @@ class CreateBroadcastTableRuleExecutorTest {
@Test
void assertExecuteUpdateWithDuplicateBroadcastTables() {
CreateBroadcastTableRuleStatement sqlStatement = new
CreateBroadcastTableRuleStatement(false, Collections.singleton("foo_tbl"));
- sqlStatement.buildAttributes();
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
BroadcastRule rule = mock(BroadcastRule.class);
when(rule.getTables()).thenReturn(Collections.singleton("foo_tbl"));
@@ -67,7 +65,6 @@ class CreateBroadcastTableRuleExecutorTest {
@Test
void assertExecuteUpdateWithIfNotExists() throws SQLException {
CreateBroadcastTableRuleStatement sqlStatement = new
CreateBroadcastTableRuleStatement(true, new
ArrayList<>(Arrays.asList("foo_tbl", "bar_tbl")));
- sqlStatement.buildAttributes();
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
BroadcastRule rule = mock(BroadcastRule.class);
when(rule.getTables()).thenReturn(Collections.singleton("foo_tbl"));
@@ -81,7 +78,6 @@ class CreateBroadcastTableRuleExecutorTest {
@Test
void assertExecuteUpdateWithoutIfNotExists() throws SQLException {
CreateBroadcastTableRuleStatement sqlStatement = new
CreateBroadcastTableRuleStatement(false, Collections.singleton("bar_tbl"));
- sqlStatement.buildAttributes();
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
BroadcastRule rule = mock(BroadcastRule.class);
when(rule.getTables()).thenReturn(Collections.singleton("foo_tbl"));
@@ -95,7 +91,6 @@ class CreateBroadcastTableRuleExecutorTest {
@Test
void assertExecuteUpdateWithoutExistedRule() throws SQLException {
CreateBroadcastTableRuleStatement sqlStatement = new
CreateBroadcastTableRuleStatement(false, new
ArrayList<>(Arrays.asList("foo_tbl", "bar_tbl")));
- sqlStatement.buildAttributes();
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
ContextManager contextManager = mockContextManager(database, null);
new DistSQLUpdateExecuteEngine(sqlStatement, "foo_db", contextManager,
null).executeUpdate();
diff --git
a/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleExecutorTest.java
b/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleExecutorTest.java
index 8caf0a2ba2d..b1b4471bb7a 100644
---
a/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleExecutorTest.java
+++
b/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleExecutorTest.java
@@ -46,7 +46,6 @@ class DropBroadcastTableRuleExecutorTest {
@Test
void assertExecuteUpdateWithoutToBeDroppedTables() {
DropBroadcastTableRuleStatement sqlStatement = new
DropBroadcastTableRuleStatement(false, Collections.singleton("foo_tbl"));
- sqlStatement.buildAttributes();
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
BroadcastRule rule = mock(BroadcastRule.class, RETURNS_DEEP_STUBS);
assertThrows(MissingRequiredRuleException.class, () -> new
DistSQLUpdateExecuteEngine(sqlStatement, "foo_db", mockContextManager(database,
rule), null).executeUpdate());
@@ -55,7 +54,6 @@ class DropBroadcastTableRuleExecutorTest {
@Test
void assertExecuteUpdate() throws SQLException {
DropBroadcastTableRuleStatement sqlStatement = new
DropBroadcastTableRuleStatement(true, new ArrayList<>(Arrays.asList("foo_tbl",
"bar_tbl")));
- sqlStatement.buildAttributes();
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn("foo_db");
BroadcastRule rule = mock(BroadcastRule.class, RETURNS_DEEP_STUBS);
diff --git
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/EncryptShowCreateTableMergedResultTest.java
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/EncryptShowCreateTableMergedResultTest.java
index cc41970b832..6d54e13e82e 100644
---
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/EncryptShowCreateTableMergedResultTest.java
+++
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/EncryptShowCreateTableMergedResultTest.java
@@ -187,7 +187,6 @@ class EncryptShowCreateTableMergedResultTest {
private EncryptShowCreateTableMergedResult createMergedResult(final
MergedResult mergedResult, final String tableName, final EncryptRule rule) {
MySQLShowCreateTableStatement sqlStatement = new
MySQLShowCreateTableStatement(databaseType, new SimpleTableSegment(new
TableNameSegment(1, 4, new IdentifierValue(tableName))));
- sqlStatement.buildAttributes();
CommonSQLStatementContext sqlStatementContext = new
CommonSQLStatementContext(sqlStatement);
RuleMetaData globalRuleMetaData = mock(RuleMetaData.class);
when(globalRuleMetaData.getSingleRule(SQLParserRule.class)).thenReturn(new
SQLParserRule(new SQLParserRuleConfiguration(new CacheOption(128, 1024L), new
CacheOption(2000, 65535L))));
diff --git
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/EncryptTokenGenerateBuilderTest.java
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/EncryptTokenGenerateBuilderTest.java
index 09f76e79b67..ff0c35d7773 100644
---
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/EncryptTokenGenerateBuilderTest.java
+++
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/EncryptTokenGenerateBuilderTest.java
@@ -63,7 +63,6 @@ class EncryptTokenGenerateBuilderTest {
when(selectStatementContext.getGroupByContext().getItems()).thenReturn(Collections.emptyList());
when(selectStatementContext.getWhereSegments()).thenReturn(Collections.emptyList());
SelectStatement selectStatement =
SelectStatement.builder().databaseType(databaseType).build();
- selectStatement.buildAttributes();
when(selectStatementContext.getSqlStatement()).thenReturn(selectStatement);
SQLRewriteContext sqlRewriteContext = mock(SQLRewriteContext.class,
RETURNS_DEEP_STUBS);
EncryptCondition encryptCondition = mock(EncryptCondition.class);
diff --git
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/ddl/EncryptAlterTableTokenGeneratorTest.java
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/ddl/EncryptAlterTableTokenGeneratorTest.java
index 92b990ba045..dde574f11aa 100644
---
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/ddl/EncryptAlterTableTokenGeneratorTest.java
+++
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/ddl/EncryptAlterTableTokenGeneratorTest.java
@@ -121,11 +121,9 @@ class EncryptAlterTableTokenGeneratorTest {
private SQLStatement createAddColumnStatement() {
ColumnDefinitionSegment columnDefinitionSegment = new
ColumnDefinitionSegment(
33, 67, new ColumnSegment(33, 50, new
IdentifierValue("certificate_number")), new DataTypeSegment(), false, false,
"");
- AlterTableStatement result =
AlterTableStatement.builder().databaseType(databaseType)
+ return AlterTableStatement.builder().databaseType(databaseType)
.table(new SimpleTableSegment(new TableNameSegment(0, 0, new
IdentifierValue("t_encrypt"))))
.addColumnDefinition(new AddColumnDefinitionSegment(22, 67,
Collections.singleton(columnDefinitionSegment))).build();
- result.buildAttributes();
- return result;
}
@Test
@@ -136,11 +134,9 @@ class EncryptAlterTableTokenGeneratorTest {
private SQLStatement createModifyColumnStatement() {
ColumnDefinitionSegment columnDefinitionSegment = new
ColumnDefinitionSegment(
36, 70, new ColumnSegment(36, 53, new
IdentifierValue("certificate_number")), new DataTypeSegment(), false, false,
"");
- AlterTableStatement result =
AlterTableStatement.builder().databaseType(databaseType)
+ return AlterTableStatement.builder().databaseType(databaseType)
.table(new SimpleTableSegment(new TableNameSegment(0, 0, new
IdentifierValue("t_encrypt"))))
.modifyColumnDefinition(new ModifyColumnDefinitionSegment(22,
70, columnDefinitionSegment)).build();
- result.buildAttributes();
- return result;
}
@Test
@@ -153,9 +149,7 @@ class EncryptAlterTableTokenGeneratorTest {
55, 93, new ColumnSegment(55, 76, new
IdentifierValue("certificate_number_new")), new DataTypeSegment(), false,
false, "");
ChangeColumnDefinitionSegment changeColumnDefinitionSegment = new
ChangeColumnDefinitionSegment(22, 93, columnDefinitionSegment);
changeColumnDefinitionSegment.setPreviousColumn(new ColumnSegment(36,
53, new IdentifierValue("certificate_number")));
- AlterTableStatement result =
AlterTableStatement.builder().databaseType(databaseType)
+ return AlterTableStatement.builder().databaseType(databaseType)
.table(new SimpleTableSegment(new TableNameSegment(0, 0, new
IdentifierValue("t_encrypt")))).changeColumnDefinition(changeColumnDefinitionSegment).build();
- result.buildAttributes();
- return result;
}
}
diff --git
a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleExecutorTest.java
b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleExecutorTest.java
index ac18061c733..24dface882e 100644
---
a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleExecutorTest.java
+++
b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleExecutorTest.java
@@ -80,9 +80,7 @@ class AlterEncryptRuleExecutorTest {
new EncryptColumnItemSegment("user_cipher", new
AlgorithmSegment("MD5", new Properties())),
new EncryptColumnItemSegment(assistQueryColumnName, new
AlgorithmSegment("MD5", new Properties())),
new EncryptColumnItemSegment(likeColumnName, new
AlgorithmSegment("MD5", new Properties())));
- AlterEncryptRuleStatement result = new
AlterEncryptRuleStatement(Collections.singleton(new
EncryptRuleSegment("t_encrypt", Collections.singleton(columnSegment))));
- result.buildAttributes();
- return result;
+ return new AlterEncryptRuleStatement(Collections.singleton(new
EncryptRuleSegment("t_encrypt", Collections.singleton(columnSegment))));
}
@Test
@@ -121,17 +119,13 @@ class AlterEncryptRuleExecutorTest {
new EncryptColumnItemSegment("assisted_column", new
AlgorithmSegment("MD5", new Properties())),
new EncryptColumnItemSegment("like_column", new
AlgorithmSegment("MD5", new Properties())));
EncryptRuleSegment ruleSegment = new EncryptRuleSegment("t_encrypt",
Collections.singleton(columnSegment));
- AlterEncryptRuleStatement result = new
AlterEncryptRuleStatement(Collections.singleton(ruleSegment));
- result.buildAttributes();
- return result;
+ return new
AlterEncryptRuleStatement(Collections.singleton(ruleSegment));
}
private AlterEncryptRuleStatement
createSQLStatementWithoutAssistQueryAndLikeColumns() {
EncryptColumnSegment columnSegment = new
EncryptColumnSegment("user_id", new EncryptColumnItemSegment("user_cipher", new
AlgorithmSegment("MD5", new Properties())), null, null);
EncryptRuleSegment ruleSegment = new EncryptRuleSegment("t_encrypt",
Collections.singleton(columnSegment));
- AlterEncryptRuleStatement result = new
AlterEncryptRuleStatement(Collections.singleton(ruleSegment));
- result.buildAttributes();
- return result;
+ return new
AlterEncryptRuleStatement(Collections.singleton(ruleSegment));
}
private EncryptRuleConfiguration createCurrentRuleConfiguration() {
diff --git
a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutorTest.java
b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutorTest.java
index 3bc76d2454a..2d65dd09135 100644
---
a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutorTest.java
+++
b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutorTest.java
@@ -97,9 +97,7 @@ class CreateEncryptRuleExecutorTest {
new EncryptColumnItemSegment("like_column", new
AlgorithmSegment("CHAR_DIGEST_LIKE", new Properties())));
EncryptRuleSegment userRuleSegment = new EncryptRuleSegment("t_user",
Collections.singleton(tUserColumnSegment));
EncryptRuleSegment orderRuleSegment = new
EncryptRuleSegment("t_order", Collections.singleton(tOrderColumnSegment));
- CreateEncryptRuleStatement result = new
CreateEncryptRuleStatement(true, Arrays.asList(userRuleSegment,
orderRuleSegment));
- result.buildAttributes();
- return result;
+ return new CreateEncryptRuleStatement(true,
Arrays.asList(userRuleSegment, orderRuleSegment));
}
@Test
@@ -119,9 +117,7 @@ class CreateEncryptRuleExecutorTest {
new EncryptColumnItemSegment("like_column", null));
Collection<EncryptRuleSegment> rules = new LinkedList<>();
rules.add(new EncryptRuleSegment("t_user",
Collections.singleton(encryptColumnSegment)));
- CreateEncryptRuleStatement result = new
CreateEncryptRuleStatement(ifNotExists, rules);
- result.buildAttributes();
- return result;
+ return new CreateEncryptRuleStatement(ifNotExists, rules);
}
private CreateEncryptRuleStatement createSQLStatement(final boolean
ifNotExists, final String encryptorName) {
@@ -138,9 +134,7 @@ class CreateEncryptRuleExecutorTest {
Collection<EncryptRuleSegment> rules = new LinkedList<>();
rules.add(tUserRuleSegment);
rules.add(tOrderRuleSegment);
- CreateEncryptRuleStatement result = new
CreateEncryptRuleStatement(ifNotExists, rules);
- result.buildAttributes();
- return result;
+ return new CreateEncryptRuleStatement(ifNotExists, rules);
}
private CreateEncryptRuleStatement createConflictColumnNameSQLStatement() {
@@ -149,9 +143,7 @@ class CreateEncryptRuleExecutorTest {
new EncryptColumnItemSegment("user_id", new
AlgorithmSegment("test", new Properties())),
new EncryptColumnItemSegment("like_column", new
AlgorithmSegment("test", new Properties())));
EncryptRuleSegment ruleSegment = new EncryptRuleSegment("t_encrypt",
Collections.singleton(columnSegment));
- CreateEncryptRuleStatement result = new
CreateEncryptRuleStatement(false, Collections.singleton(ruleSegment));
- result.buildAttributes();
- return result;
+ return new CreateEncryptRuleStatement(false,
Collections.singleton(ruleSegment));
}
private EncryptRuleConfiguration getCurrentRuleConfiguration() {
diff --git
a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleExecutorTest.java
b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleExecutorTest.java
index c0648da9147..dc674f91945 100644
---
a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleExecutorTest.java
+++
b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleExecutorTest.java
@@ -109,15 +109,11 @@ class DropEncryptRuleExecutorTest {
}
private DropEncryptRuleStatement createSQLStatement(final String
tableName) {
- DropEncryptRuleStatement result = new DropEncryptRuleStatement(false,
Collections.singleton(tableName));
- result.buildAttributes();
- return result;
+ return new DropEncryptRuleStatement(false,
Collections.singleton(tableName));
}
private DropEncryptRuleStatement createSQLStatement(final boolean
ifExists, final String tableName) {
- DropEncryptRuleStatement result = new
DropEncryptRuleStatement(ifExists, Collections.singleton(tableName));
- result.buildAttributes();
- return result;
+ return new DropEncryptRuleStatement(ifExists,
Collections.singleton(tableName));
}
private EncryptRuleConfiguration createCurrentRuleConfiguration() {
diff --git
a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/AlterMaskRuleExecutorTest.java
b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/AlterMaskRuleExecutorTest.java
index e100f0853b2..597b2a589a8 100644
---
a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/AlterMaskRuleExecutorTest.java
+++
b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/AlterMaskRuleExecutorTest.java
@@ -83,7 +83,7 @@ class AlterMaskRuleExecutorTest {
@Test
void assertBuildToBeAlteredRuleConfiguration() {
- AlterMaskRuleStatement sqlStatement =
createAlterStatement(Collections.singleton(createRuleSegment("t_order",
"order_id", "MD5")));
+ AlterMaskRuleStatement sqlStatement = new
AlterMaskRuleStatement(Collections.singleton(createRuleSegment("t_order",
"order_id", "MD5")));
MaskRuleConfiguration actual =
executor.buildToBeAlteredRuleConfiguration(sqlStatement);
assertThat(actual.getTables().size(), is(1));
MaskTableRuleConfiguration actualTable =
actual.getTables().iterator().next();
@@ -116,18 +116,13 @@ class AlterMaskRuleExecutorTest {
private static Stream<Arguments> checkBeforeUpdateArguments() {
return Stream.of(
- Arguments.of("all tables exist",
createAlterStatement(Collections.singleton(createRuleSegment("t_order",
"order_id", "MD5"))),
+ Arguments.of("all tables exist", new
AlterMaskRuleStatement(Collections.singleton(createRuleSegment("t_order",
"order_id", "MD5"))),
createCurrentRuleConfiguration(Collections.singleton("t_order")), null),
- Arguments.of("single missing table",
createAlterStatement(Collections.singleton(createRuleSegment("t_missing",
"order_id", "MD5"))),
+ Arguments.of("single missing table", new
AlterMaskRuleStatement(Collections.singleton(createRuleSegment("t_missing",
"order_id", "MD5"))),
createCurrentRuleConfiguration(Collections.singleton("t_order")),
MissingRequiredRuleException.class),
- Arguments.of("one table exists and one missing",
createAlterStatement(Arrays.asList(createRuleSegment("t_order", "order_id",
"MD5"),
- createRuleSegment("t_missing", "user_id", "AES"))),
createCurrentRuleConfiguration(Collections.singleton("t_order")),
MissingRequiredRuleException.class));
- }
-
- private static AlterMaskRuleStatement createAlterStatement(final
Collection<MaskRuleSegment> rules) {
- AlterMaskRuleStatement result = new AlterMaskRuleStatement(rules);
- result.buildAttributes();
- return result;
+ Arguments.of("one table exists and one missing",
+ new
AlterMaskRuleStatement(Arrays.asList(createRuleSegment("t_order", "order_id",
"MD5"), createRuleSegment("t_missing", "user_id", "AES"))),
+
createCurrentRuleConfiguration(Collections.singleton("t_order")),
MissingRequiredRuleException.class));
}
private static MaskRuleSegment createRuleSegment(final String tableName,
final String columnName, final String algorithmType) {
diff --git
a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/CreateMaskRuleExecutorTest.java
b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/CreateMaskRuleExecutorTest.java
index 77f9fb771f3..855777cdb4a 100644
---
a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/CreateMaskRuleExecutorTest.java
+++
b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/CreateMaskRuleExecutorTest.java
@@ -89,9 +89,7 @@ class CreateMaskRuleExecutorTest {
Collection<MaskRuleSegment> rules = new LinkedList<>();
rules.add(tMaskRuleSegment);
rules.add(tOrderRuleSegment);
- CreateMaskRuleStatement result = new
CreateMaskRuleStatement(ifNotExists, rules);
- result.buildAttributes();
- return result;
+ return new CreateMaskRuleStatement(ifNotExists, rules);
}
private CreateMaskRuleStatement createDuplicatedSQLStatement(final boolean
ifNotExists, final String algorithmType) {
@@ -102,9 +100,7 @@ class CreateMaskRuleExecutorTest {
Collection<MaskRuleSegment> rules = new LinkedList<>();
rules.add(tMaskRuleSegment);
rules.add(tOrderRuleSegment);
- CreateMaskRuleStatement result = new
CreateMaskRuleStatement(ifNotExists, rules);
- result.buildAttributes();
- return result;
+ return new CreateMaskRuleStatement(ifNotExists, rules);
}
private MaskRuleConfiguration getCurrentRuleConfiguration() {
diff --git
a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/DropMaskRuleExecutorTest.java
b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/DropMaskRuleExecutorTest.java
index fa5287a5936..f304686620e 100644
---
a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/DropMaskRuleExecutorTest.java
+++
b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/DropMaskRuleExecutorTest.java
@@ -84,9 +84,7 @@ class DropMaskRuleExecutorTest {
}
private DropMaskRuleStatement createSQLStatement(final boolean ifExists,
final String tableName) {
- DropMaskRuleStatement result = new DropMaskRuleStatement(ifExists,
Collections.singleton(tableName));
- result.buildAttributes();
- return result;
+ return new DropMaskRuleStatement(ifExists,
Collections.singleton(tableName));
}
private MaskRuleConfiguration createCurrentRuleConfiguration() {
diff --git
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleExecutorTest.java
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleExecutorTest.java
index 9b9b5cfa92f..1a4f5e830db 100644
---
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleExecutorTest.java
+++
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleExecutorTest.java
@@ -102,9 +102,7 @@ class AlterReadwriteSplittingRuleExecutorTest {
private AlterReadwriteSplittingRuleStatement createSQLStatement(final
Collection<String> readDataSources, final Properties props) {
ReadwriteSplittingRuleSegment ruleSegment = new
ReadwriteSplittingRuleSegment("readwrite_ds", "write_ds", readDataSources, new
AlgorithmSegment("RANDOM", props));
- AlterReadwriteSplittingRuleStatement result = new
AlterReadwriteSplittingRuleStatement(Collections.singleton(ruleSegment));
- result.buildAttributes();
- return result;
+ return new
AlterReadwriteSplittingRuleStatement(Collections.singleton(ruleSegment));
}
private ReadwriteSplittingRuleConfiguration
createCurrentRuleConfiguration() {
diff --git
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleExecutorTest.java
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleExecutorTest.java
index 9b5be3b8a03..3f82b0422cc 100644
---
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleExecutorTest.java
+++
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleExecutorTest.java
@@ -76,13 +76,14 @@ class CreateReadwriteSplittingRuleExecutorTest {
void assertCheckBeforeUpdate() {
mockCheckBeforeUpdateDependencies(Collections.emptySet());
setRule(null);
- assertDoesNotThrow(() ->
executor.checkBeforeUpdate(createSQLStatement(false,
Collections.singleton(createRuleSegment("readwrite_ds_1")))));
+ assertDoesNotThrow(() -> executor.checkBeforeUpdate(new
CreateReadwriteSplittingRuleStatement(false,
Collections.singleton(createRuleSegment("readwrite_ds_1")))));
}
@Test
void assertBuildToBeCreatedRuleConfigurationWithoutIfNotExists() {
setRule(createCurrentRuleConfiguration());
- ReadwriteSplittingRuleConfiguration actual =
executor.buildToBeCreatedRuleConfiguration(createSQLStatement(false,
Collections.singleton(createRuleSegment("readwrite_ds_1"))));
+ ReadwriteSplittingRuleConfiguration actual =
executor.buildToBeCreatedRuleConfiguration(
+ new CreateReadwriteSplittingRuleStatement(false,
Collections.singleton(createRuleSegment("readwrite_ds_1"))));
assertThat(actual.getDataSourceGroups().size(), is(1));
assertThat(actual.getLoadBalancers().size(), is(1));
}
@@ -92,7 +93,7 @@ class CreateReadwriteSplittingRuleExecutorTest {
void assertBuildToBeCreatedRuleConfigurationWithIfNotExists(final String
name, final ReadwriteSplittingRuleConfiguration currentRuleConfig,
final
Collection<ReadwriteSplittingRuleSegment> ruleSegments, final int
expectedGroupCount) {
setRule(currentRuleConfig);
-
assertThat(executor.buildToBeCreatedRuleConfiguration(createSQLStatement(true,
ruleSegments)).getDataSourceGroups().size(), is(expectedGroupCount));
+ assertThat(executor.buildToBeCreatedRuleConfiguration(new
CreateReadwriteSplittingRuleStatement(true, new
LinkedList<>(ruleSegments))).getDataSourceGroups().size(),
is(expectedGroupCount));
}
@Test
@@ -104,7 +105,8 @@ class CreateReadwriteSplittingRuleExecutorTest {
void assertCheckBeforeUpdateWithMissingStorageUnit() {
mockCheckBeforeUpdateDependencies(Collections.singleton("missing_ds"));
setRule(null);
- assertThrows(MissingRequiredStorageUnitsException.class, () ->
executor.checkBeforeUpdate(createSQLStatement(false,
Collections.singleton(createRuleSegment("readwrite_ds_1")))));
+ assertThrows(MissingRequiredStorageUnitsException.class,
+ () -> executor.checkBeforeUpdate(new
CreateReadwriteSplittingRuleStatement(false,
Collections.singleton(createRuleSegment("readwrite_ds_1")))));
}
private void mockCheckBeforeUpdateDependencies(final Collection<String>
notExistedDataSources) {
@@ -123,17 +125,11 @@ class CreateReadwriteSplittingRuleExecutorTest {
executor.setRule(rule);
}
- private CreateReadwriteSplittingRuleStatement createSQLStatement(final
boolean ifNotExists, final Collection<ReadwriteSplittingRuleSegment>
ruleSegments) {
- CreateReadwriteSplittingRuleStatement result = new
CreateReadwriteSplittingRuleStatement(ifNotExists, new
LinkedList<>(ruleSegments));
- result.buildAttributes();
- return result;
- }
-
private static Stream<Arguments>
buildToBeCreatedRuleConfigurationArguments() {
return Stream.of(
- Arguments.of("if not exists with null rule", null, new
LinkedList<>(Collections.singleton(createRuleSegment("readwrite_ds_1"))), 1),
- Arguments.of("if not exists removes duplicated rule",
createCurrentRuleConfiguration(), new
LinkedList<>(Collections.singleton(createRuleSegment("readwrite_ds_0"))), 0),
- Arguments.of("if not exists keeps non duplicated rule",
createCurrentRuleConfiguration(), new
LinkedList<>(Collections.singleton(createRuleSegment("readwrite_ds_1"))), 1));
+ Arguments.of("if not exists with null rule", null,
Collections.singleton(createRuleSegment("readwrite_ds_1")), 1),
+ Arguments.of("if not exists removes duplicated rule",
createCurrentRuleConfiguration(),
Collections.singleton(createRuleSegment("readwrite_ds_0")), 0),
+ Arguments.of("if not exists keeps non duplicated rule",
createCurrentRuleConfiguration(),
Collections.singleton(createRuleSegment("readwrite_ds_1")), 1));
}
private static ReadwriteSplittingRuleSegment createRuleSegment(final
String ruleName) {
@@ -141,8 +137,8 @@ class CreateReadwriteSplittingRuleExecutorTest {
}
private static ReadwriteSplittingRuleConfiguration
createCurrentRuleConfiguration() {
- ReadwriteSplittingDataSourceGroupRuleConfiguration
dataSourceGroupConfig = new
ReadwriteSplittingDataSourceGroupRuleConfiguration("readwrite_ds_0", "ds_write",
- Arrays.asList("read_ds_0", "read_ds_1"), "RANDOM");
- return new ReadwriteSplittingRuleConfiguration(new
LinkedList<>(Collections.singleton(dataSourceGroupConfig)),
Collections.emptyMap());
+ ReadwriteSplittingDataSourceGroupRuleConfiguration
dataSourceGroupConfig = new ReadwriteSplittingDataSourceGroupRuleConfiguration(
+ "readwrite_ds_0", "ds_write", Arrays.asList("read_ds_0",
"read_ds_1"), "RANDOM");
+ return new
ReadwriteSplittingRuleConfiguration(Collections.singleton(dataSourceGroupConfig),
Collections.emptyMap());
}
}
diff --git
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleExecutorTest.java
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleExecutorTest.java
index f0c1ce64c4b..5c8cd103e04 100644
---
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleExecutorTest.java
+++
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleExecutorTest.java
@@ -76,13 +76,12 @@ class DropReadwriteSplittingRuleExecutorTest {
void assertCheckBeforeUpdateWithoutToBeDroppedRule() {
when(database.getName()).thenReturn("test_db");
setRule(new
ReadwriteSplittingRuleConfiguration(Collections.emptyList(),
Collections.emptyMap()));
- assertThrows(MissingRequiredRuleException.class, () ->
executor.checkBeforeUpdate(createSQLStatement()));
+ assertThrows(MissingRequiredRuleException.class, () ->
executor.checkBeforeUpdate(new DropReadwriteSplittingRuleStatement(false,
Collections.singleton("readwrite_ds"))));
}
@Test
void assertCheckBeforeUpdateWithIfExists() {
DropReadwriteSplittingRuleStatement sqlStatement = new
DropReadwriteSplittingRuleStatement(true,
Collections.singleton("readwrite_ds"));
- sqlStatement.buildAttributes();
assertDoesNotThrow(() -> executor.checkBeforeUpdate(sqlStatement));
}
@@ -95,7 +94,7 @@ class DropReadwriteSplittingRuleExecutorTest {
when(mapperRule.getAttributes()).thenReturn(new
RuleAttributes(dataSourceMapperRuleAttribute));
when(database.getRuleMetaData().getRules()).thenReturn(Collections.singleton(mapperRule));
setRule(createCurrentRuleConfiguration());
- assertThrows(InUsedRuleException.class, () ->
executor.checkBeforeUpdate(createSQLStatement()));
+ assertThrows(InUsedRuleException.class, () ->
executor.checkBeforeUpdate(new DropReadwriteSplittingRuleStatement(false,
Collections.singleton("readwrite_ds"))));
}
@Test
@@ -116,13 +115,7 @@ class DropReadwriteSplittingRuleExecutorTest {
when(singleRule.getAttributes()).thenReturn(new RuleAttributes());
when(database.getRuleMetaData().getRules()).thenReturn(Arrays.asList(readwriteRule,
mapperRule, plainRule, dataNodeRule, singleRule));
setRule(createCurrentRuleConfiguration());
- assertDoesNotThrow(() ->
executor.checkBeforeUpdate(createSQLStatement()));
- }
-
- private DropReadwriteSplittingRuleStatement createSQLStatement() {
- DropReadwriteSplittingRuleStatement result = new
DropReadwriteSplittingRuleStatement(false,
Collections.singleton("readwrite_ds"));
- result.buildAttributes();
- return result;
+ assertDoesNotThrow(() -> executor.checkBeforeUpdate(new
DropReadwriteSplittingRuleStatement(false,
Collections.singleton("readwrite_ds"))));
}
@ParameterizedTest(name = "{0}")
@@ -130,7 +123,7 @@ class DropReadwriteSplittingRuleExecutorTest {
void assertBuildToBeDroppedRuleConfiguration(final String name,
final
ReadwriteSplittingRuleConfiguration currentRuleConfig, final int
expectedDataSourceGroupCount, final int expectedLoadBalancerCount) {
setRule(currentRuleConfig);
- ReadwriteSplittingRuleConfiguration actual =
executor.buildToBeDroppedRuleConfiguration(createSQLStatement());
+ ReadwriteSplittingRuleConfiguration actual =
executor.buildToBeDroppedRuleConfiguration(new
DropReadwriteSplittingRuleStatement(false,
Collections.singleton("readwrite_ds")));
assertThat(actual.getDataSourceGroups().size(),
is(expectedDataSourceGroupCount));
assertThat(actual.getLoadBalancers().size(),
is(expectedLoadBalancerCount));
}
@@ -140,9 +133,7 @@ class DropReadwriteSplittingRuleExecutorTest {
void assertHasAnyOneToBeDropped(final String name, final
Collection<String> toBeDroppedNames, final boolean expected) {
setRule(createCurrentRuleConfiguration());
DropReadwriteSplittingRuleStatement sqlStatement = new
DropReadwriteSplittingRuleStatement(false, toBeDroppedNames);
- sqlStatement.buildAttributes();
- boolean actual = executor.hasAnyOneToBeDropped(sqlStatement);
- assertThat(actual, is(expected));
+ assertThat(executor.hasAnyOneToBeDropped(sqlStatement), is(expected));
}
private void setRule(final ReadwriteSplittingRuleConfiguration ruleConfig)
{
diff --git
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowRuleExecutorTest.java
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowRuleExecutorTest.java
index ca06f074d80..e646a112f54 100644
---
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowRuleExecutorTest.java
+++
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/handler/update/AlterShadowRuleExecutorTest.java
@@ -114,7 +114,7 @@ class AlterShadowRuleExecutorTest {
Properties props = PropertiesBuilder.build(new Property("type",
"value"));
ShadowAlgorithmSegment segment1 = new
ShadowAlgorithmSegment("algorithmName1", new AlgorithmSegment("SQL_HINT",
props));
ShadowAlgorithmSegment segment2 = new
ShadowAlgorithmSegment("algorithmName2", new AlgorithmSegment("SQL_HINT",
props));
- AlterShadowRuleStatement sqlStatement =
createAlterStatement(Arrays.asList(
+ AlterShadowRuleStatement sqlStatement = new
AlterShadowRuleStatement(Arrays.asList(
new ShadowRuleSegment("initRuleName1", "ds_0", null,
Collections.singletonMap("t_order", Collections.singleton(segment1))),
new ShadowRuleSegment("initRuleName2", "ds_1", null,
Collections.singletonMap("t_order_1", Collections.singleton(segment2)))));
assertDoesNotThrow(() -> executor.checkBeforeUpdate(sqlStatement));
@@ -123,7 +123,7 @@ class AlterShadowRuleExecutorTest {
@Test
void assertBuildToBeAlteredRuleConfiguration() {
ShadowAlgorithmSegment algorithmSegment = new
ShadowAlgorithmSegment("algorithm_name", new AlgorithmSegment("SQL_HINT",
PropertiesBuilder.build(new Property("type", "value"))));
- AlterShadowRuleStatement sqlStatement = createAlterStatement(
+ AlterShadowRuleStatement sqlStatement = new AlterShadowRuleStatement(
Collections.singleton(new ShadowRuleSegment("initRuleName1",
"ds_0", "ds_0_shadow", Collections.singletonMap("t_order",
Collections.singleton(algorithmSegment)))));
ShadowRuleConfiguration actual =
executor.buildToBeAlteredRuleConfiguration(sqlStatement);
assertThat(actual.getDataSources().size(), is(1));
@@ -155,26 +155,24 @@ class AlterShadowRuleExecutorTest {
ShadowAlgorithmSegment invalidTypeSegment = new
ShadowAlgorithmSegment("invalid_type_algorithm",
new AlgorithmSegment("INVALID_TYPE",
PropertiesBuilder.build(new Property("type", "value"))));
return Stream.of(
- Arguments.of("duplicate rule name",
createAlterStatement(Arrays.asList(
- new ShadowRuleSegment("rule_name", null, null, null),
- new ShadowRuleSegment("rule_name", null, null,
null))), Collections.emptyList(), DuplicateRuleException.class),
- Arguments.of("rule not found",
createAlterStatement(Collections.singleton(
- new ShadowRuleSegment("missing_rule", null, null,
null))), Collections.emptyList(), MissingRequiredRuleException.class),
- Arguments.of("storage unit not found",
createAlterStatement(Collections.singleton(
- new ShadowRuleSegment("initRuleName1",
"missing_storage_unit", null, null))),
Collections.singletonList("missing_storage_unit"),
+ Arguments.of("duplicate rule name", new
AlterShadowRuleStatement(
+ Arrays.asList(new ShadowRuleSegment("rule_name", null,
null, null),
+ new ShadowRuleSegment("rule_name", null, null,
null))),
+ Collections.emptyList(), DuplicateRuleException.class),
+ Arguments.of("rule not found", new AlterShadowRuleStatement(
+ Collections.singleton(new
ShadowRuleSegment("missing_rule", null, null, null))), Collections.emptyList(),
MissingRequiredRuleException.class),
+ Arguments.of("storage unit not found", new
AlterShadowRuleStatement(
+ Collections.singleton(new
ShadowRuleSegment("initRuleName1", "missing_storage_unit", null, null))),
Collections.singletonList("missing_storage_unit"),
MissingRequiredStorageUnitsException.class),
- Arguments.of("duplicate algorithm name",
createAlterStatement(Arrays.asList(
- new ShadowRuleSegment("initRuleName1", "ds_0", null,
Collections.singletonMap("t_order",
Collections.singleton(duplicatedAlgorithmSegment))),
- new ShadowRuleSegment("initRuleName2", "ds_1", null,
Collections.singletonMap("t_order_1",
Collections.singleton(duplicatedAlgorithmSegment))))),
+ Arguments.of("duplicate algorithm name", new
AlterShadowRuleStatement(
+ Arrays.asList(new ShadowRuleSegment("initRuleName1",
"ds_0", null,
+ Collections.singletonMap("t_order",
Collections.singleton(duplicatedAlgorithmSegment))),
+ new ShadowRuleSegment("initRuleName2", "ds_1",
null,
+ Collections.singletonMap("t_order_1",
Collections.singleton(duplicatedAlgorithmSegment))))),
Collections.emptyList(),
InUsedAlgorithmException.class),
- Arguments.of("invalid algorithm type",
createAlterStatement(Collections.singleton(
- new ShadowRuleSegment("initRuleName1", "ds_0", null,
Collections.singletonMap("t_order",
Collections.singleton(invalidTypeSegment))))),
+ Arguments.of("invalid algorithm type", new
AlterShadowRuleStatement(
+ Collections.singleton(new
ShadowRuleSegment("initRuleName1", "ds_0", null,
Collections.singletonMap("t_order",
Collections.singleton(invalidTypeSegment))))),
Collections.emptyList(),
ServiceProviderNotFoundException.class));
}
- private static AlterShadowRuleStatement createAlterStatement(final
Collection<ShadowRuleSegment> rules) {
- AlterShadowRuleStatement result = new AlterShadowRuleStatement(rules);
- result.buildAttributes();
- return result;
- }
}
diff --git
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/handler/update/CreateShadowRuleExecutorTest.java
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/handler/update/CreateShadowRuleExecutorTest.java
index e6c28c347b3..6adcdc68e80 100644
---
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/handler/update/CreateShadowRuleExecutorTest.java
+++
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/handler/update/CreateShadowRuleExecutorTest.java
@@ -97,13 +97,14 @@ class CreateShadowRuleExecutorTest {
@Test
void assertCheckBeforeUpdate() {
- assertDoesNotThrow(() ->
executor.checkBeforeUpdate(createStatement(false,
Collections.singleton(createShadowRuleSegment("rule_name", "ds_0",
"algorithm_name", "SQL_HINT", "t_order")))));
+ assertDoesNotThrow(() -> executor.checkBeforeUpdate(new
CreateShadowRuleStatement(
+ false,
Collections.singleton(createShadowRuleSegment("rule_name", "ds_0",
"algorithm_name", "SQL_HINT", "t_order")))));
}
@Test
void assertBuildToBeCreatedRuleConfiguration() {
- ShadowRuleConfiguration actual =
executor.buildToBeCreatedRuleConfiguration(
- createStatement(false,
Collections.singleton(createShadowRuleSegment("rule_name", "ds_0",
"algorithm_name", "SQL_HINT", "t_order"))));
+ ShadowRuleConfiguration actual =
executor.buildToBeCreatedRuleConfiguration(new CreateShadowRuleStatement(
+ false,
Collections.singleton(createShadowRuleSegment("rule_name", "ds_0",
"algorithm_name", "SQL_HINT", "t_order"))));
assertThat(actual.getDataSources().size(), is(1));
assertThat(actual.getTables().size(), is(1));
assertThat(actual.getShadowAlgorithms().size(), is(1));
@@ -111,9 +112,9 @@ class CreateShadowRuleExecutorTest {
@Test
void assertBuildToBeCreatedRuleConfigurationWithIfNotExists() {
- CreateShadowRuleStatement sqlStatement = createStatement(true,
Arrays.asList(
+ CreateShadowRuleStatement sqlStatement = new
CreateShadowRuleStatement(true, new LinkedList<>(Arrays.asList(
createShadowRuleSegment("initRuleName", "ds_0",
"algorithm_name_0", "SQL_HINT", "t_order"),
- createShadowRuleSegment("new_rule_name", "ds_1",
"algorithm_name_1", "SQL_HINT", "t_order_1")));
+ createShadowRuleSegment("new_rule_name", "ds_1",
"algorithm_name_1", "SQL_HINT", "t_order_1"))));
executor.setRule(createRule(createCurrentRuleConfiguration()));
ShadowRuleConfiguration actual =
executor.buildToBeCreatedRuleConfiguration(sqlStatement);
assertThat(actual.getDataSources().size(), is(1));
@@ -132,32 +133,26 @@ class CreateShadowRuleExecutorTest {
when(duplicatedLogicDataSourceAttribute.getDataSourceMapper()).thenReturn(Collections.singletonMap("duplicate_ds",
Collections.singleton("ds_0")));
ShadowAlgorithmSegment duplicatedAlgorithmSegment =
createShadowAlgorithmSegment("duplicated_algorithm", "SQL_HINT");
return Stream.of(
- Arguments.of("duplicate rule name", createStatement(false,
Arrays.asList(
- new ShadowRuleSegment("rule_name", null, null, null),
- new ShadowRuleSegment("rule_name", null, null,
null))), createRule(createCurrentRuleConfiguration()),
- Collections.emptyList(), Collections.emptyList(),
DuplicateRuleException.class),
- Arguments.of("duplicate current rule", createStatement(false,
Collections.singleton(
- createShadowRuleSegment("initRuleName", "ds_0",
"algorithm_name", "SQL_HINT", "t_order"))),
createRule(createCurrentRuleConfiguration()),
- Collections.emptyList(), Collections.emptyList(),
DuplicateRuleException.class),
- Arguments.of("duplicate logic datasource",
createStatement(false, Collections.singleton(
- createShadowRuleSegment("duplicate_ds", "ds_0",
"algorithm_name", "SQL_HINT", "t_order"))),
createRule(createCurrentRuleConfiguration()),
- Collections.emptyList(),
Collections.singleton(duplicatedLogicDataSourceAttribute),
InvalidRuleConfigurationException.class),
- Arguments.of("missing storage unit", createStatement(false,
Collections.singleton(
- createShadowRuleSegment("rule_name", "missing_ds",
"algorithm_name", "SQL_HINT", "t_order"))),
createRule(createCurrentRuleConfiguration()),
- Collections.singleton("missing_ds"),
Collections.emptyList(), MissingRequiredStorageUnitsException.class),
- Arguments.of("duplicate algorithm", createStatement(false,
Arrays.asList(
- new ShadowRuleSegment("rule_name_0", "ds_0", null,
Collections.singletonMap("t_order",
Collections.singleton(duplicatedAlgorithmSegment))),
- new ShadowRuleSegment("rule_name_1", "ds_1", null,
Collections.singletonMap("t_order_1",
Collections.singleton(duplicatedAlgorithmSegment))))),
+ Arguments.of("duplicate rule name", new
CreateShadowRuleStatement(false,
+ Arrays.asList(new ShadowRuleSegment("rule_name", null,
null, null), new ShadowRuleSegment("rule_name", null, null, null))),
createRule(createCurrentRuleConfiguration()),
Collections.emptyList(), Collections.emptyList(), DuplicateRuleException.class),
- Arguments.of("invalid algorithm type", createStatement(false,
Collections.singleton(
- createShadowRuleSegment("rule_name", "ds_0",
"algorithm_name", "INVALID_TYPE", "t_order"))),
createRule(createCurrentRuleConfiguration()),
- Collections.emptyList(), Collections.emptyList(),
ServiceProviderNotFoundException.class));
- }
-
- private static CreateShadowRuleStatement createStatement(final boolean
ifNotExists, final Collection<ShadowRuleSegment> rules) {
- CreateShadowRuleStatement result = new
CreateShadowRuleStatement(ifNotExists, new LinkedList<>(rules));
- result.buildAttributes();
- return result;
+ Arguments.of("duplicate current rule", new
CreateShadowRuleStatement(false,
+
Collections.singleton(createShadowRuleSegment("initRuleName", "ds_0",
"algorithm_name", "SQL_HINT", "t_order"))),
+ createRule(createCurrentRuleConfiguration()),
Collections.emptyList(), Collections.emptyList(), DuplicateRuleException.class),
+ Arguments.of("duplicate logic datasource", new
CreateShadowRuleStatement(false,
+
Collections.singleton(createShadowRuleSegment("duplicate_ds", "ds_0",
"algorithm_name", "SQL_HINT", "t_order"))),
+ createRule(createCurrentRuleConfiguration()),
Collections.emptyList(),
Collections.singleton(duplicatedLogicDataSourceAttribute),
InvalidRuleConfigurationException.class),
+ Arguments.of("missing storage unit", new
CreateShadowRuleStatement(false,
+
Collections.singleton(createShadowRuleSegment("rule_name", "missing_ds",
"algorithm_name", "SQL_HINT", "t_order"))),
+ createRule(createCurrentRuleConfiguration()),
Collections.singleton("missing_ds"), Collections.emptyList(),
MissingRequiredStorageUnitsException.class),
+ Arguments.of("duplicate algorithm", new
CreateShadowRuleStatement(false,
+ Arrays.asList(
+ new ShadowRuleSegment("rule_name_0", "ds_0",
null, Collections.singletonMap("t_order",
Collections.singleton(duplicatedAlgorithmSegment))),
+ new ShadowRuleSegment("rule_name_1", "ds_1",
null, Collections.singletonMap("t_order_1",
Collections.singleton(duplicatedAlgorithmSegment))))),
+ createRule(createCurrentRuleConfiguration()),
Collections.emptyList(), Collections.emptyList(), DuplicateRuleException.class),
+ Arguments.of("invalid algorithm type", new
CreateShadowRuleStatement(false,
+
Collections.singleton(createShadowRuleSegment("rule_name", "ds_0",
"algorithm_name", "INVALID_TYPE", "t_order"))),
+ createRule(createCurrentRuleConfiguration()),
Collections.emptyList(), Collections.emptyList(),
ServiceProviderNotFoundException.class));
}
private static ShadowRuleSegment createShadowRuleSegment(final String
ruleName, final String source, final String algorithmName, final String
algorithmType, final String tableName) {
diff --git
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowRuleExecutorTest.java
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowRuleExecutorTest.java
index ab449e2aca4..bdbea6cef17 100644
---
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowRuleExecutorTest.java
+++
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowRuleExecutorTest.java
@@ -159,9 +159,7 @@ class DropShadowRuleExecutorTest {
}
private static DropShadowRuleStatement createStatement(final boolean
ifExists, final String... ruleNames) {
- DropShadowRuleStatement result = new DropShadowRuleStatement(ifExists,
Arrays.asList(ruleNames));
- result.buildAttributes();
- return result;
+ return new DropShadowRuleStatement(ifExists, Arrays.asList(ruleNames));
}
private static ShadowRule createRule(final ShadowRuleConfiguration
ruleConfig) {
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterTableSupportedCheckerTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterTableSupportedCheckerTest.java
index d15421190d8..7df0c645d88 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterTableSupportedCheckerTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterTableSupportedCheckerTest.java
@@ -58,7 +58,6 @@ class ShardingAlterTableSupportedCheckerTest {
AlterTableStatement sqlStatement =
AlterTableStatement.builder().databaseType(databaseType)
.table(new SimpleTableSegment(new TableNameSegment(0, 0, new
IdentifierValue("t_order"))))
.renameTable(new SimpleTableSegment(new TableNameSegment(0, 0,
new IdentifierValue("t_order_new")))).build();
- sqlStatement.buildAttributes();
CommonSQLStatementContext sqlStatementContext = new
CommonSQLStatementContext(sqlStatement);
when(rule.containsShardingTable(Arrays.asList("t_order",
"t_order_new"))).thenReturn(true);
assertThrows(UnsupportedShardingOperationException.class, () -> new
ShardingAlterTableSupportedChecker().check(rule, database, mock(),
sqlStatementContext));
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropIndexSupportedCheckerTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropIndexSupportedCheckerTest.java
index 29af51c1495..b45fad6c0a4 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropIndexSupportedCheckerTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropIndexSupportedCheckerTest.java
@@ -56,17 +56,15 @@ class ShardingDropIndexSupportedCheckerTest {
@Test
void assertCheckWhenIndexExistForPostgreSQL() {
- DropIndexStatement sqlStatement = DropIndexStatement.builder()
- .databaseType(databaseType)
- .indexes(Arrays.asList(new IndexSegment(0, 0, new
IndexNameSegment(0, 0, new IdentifierValue("t_order_index"))),
- new IndexSegment(0, 0, new IndexNameSegment(0, 0, new
IdentifierValue("t_order_index_new")))))
- .build();
- sqlStatement.buildAttributes();
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
ShardingSphereTable table = mock(ShardingSphereTable.class);
when(schema.getAllTables()).thenReturn(Collections.singleton(table));
when(table.containsIndex("t_order_index")).thenReturn(true);
when(table.containsIndex("t_order_index_new")).thenReturn(true);
+ DropIndexStatement sqlStatement =
DropIndexStatement.builder().databaseType(databaseType)
+ .indexes(Arrays.asList(new IndexSegment(0, 0, new
IndexNameSegment(0, 0, new IdentifierValue("t_order_index"))),
+ new IndexSegment(0, 0, new IndexNameSegment(0, 0, new
IdentifierValue("t_order_index_new")))))
+ .build();
assertDoesNotThrow(() -> new
ShardingDropIndexSupportedChecker().check(rule, database, schema, new
CommonSQLStatementContext(sqlStatement)));
}
@@ -77,7 +75,6 @@ class ShardingDropIndexSupportedCheckerTest {
.indexes(Arrays.asList(new IndexSegment(0, 0, new
IndexNameSegment(0, 0, new IdentifierValue("t_order_index"))),
new IndexSegment(0, 0, new IndexNameSegment(0, 0, new
IdentifierValue("t_order_index_new")))))
.build();
- sqlStatement.buildAttributes();
ShardingSphereTable table = mock(ShardingSphereTable.class);
when(database.getSchema("public").getAllTables()).thenReturn(Collections.singleton(table));
when(database.getSchema("public").getTable("t_order")).thenReturn(table);
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ShardingResultMergerEngineTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ShardingResultMergerEngineTest.java
index 94d1eeadc34..1c7b290af92 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ShardingResultMergerEngineTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ShardingResultMergerEngineTest.java
@@ -96,7 +96,6 @@ class ShardingResultMergerEngineTest {
@Test
void assertNewInstanceWithDDLStatement() {
FetchStatement fetchStatement = new FetchStatement(databaseType, null,
null);
- fetchStatement.buildAttributes();
ConfigurationProperties props = new ConfigurationProperties(new
Properties());
SQLStatementContext sqlStatementContext = new
CommonSQLStatementContext(fetchStatement);
assertThat(new ShardingResultMergerEngine().newInstance("foo_db",
databaseType, null, props, sqlStatementContext),
isA(ShardingDDLResultMerger.class));
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingAlterTableRouteContextCheckerTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingAlterTableRouteContextCheckerTest.java
index 591cb6fb361..e996f0abfbb 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingAlterTableRouteContextCheckerTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingAlterTableRouteContextCheckerTest.java
@@ -68,29 +68,27 @@ class ShardingAlterTableRouteContextCheckerTest {
@Test
void assertCheckWithSameRouteResultShardingTableForPostgreSQL() {
- AlterTableStatement sqlStatement =
AlterTableStatement.builder().databaseType(databaseType)
- .table(new SimpleTableSegment(new TableNameSegment(0, 0, new
IdentifierValue("t_order")))).build();
- sqlStatement.buildAttributes();
when(shardingRule.isShardingTable("t_order")).thenReturn(true);
when(shardingRule.getShardingTable("t_order")).thenReturn(new
ShardingTable(Arrays.asList("ds_0", "ds_1"), "t_order"));
Collection<RouteUnit> routeUnits = new LinkedList<>();
routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"),
Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
routeUnits.add(new RouteUnit(new RouteMapper("ds_1", "ds_1"),
Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
+ AlterTableStatement sqlStatement =
AlterTableStatement.builder().databaseType(databaseType)
+ .table(new SimpleTableSegment(new TableNameSegment(0, 0, new
IdentifierValue("t_order")))).build();
when(queryContext.getSqlStatementContext()).thenReturn(new
CommonSQLStatementContext(sqlStatement));
assertDoesNotThrow(() -> new
ShardingAlterTableRouteContextChecker().check(shardingRule, queryContext,
database, mock(ConfigurationProperties.class), routeContext));
}
@Test
void assertCheckWithDifferentRouteResultShardingTableForPostgreSQL() {
- AlterTableStatement sqlStatement =
AlterTableStatement.builder().databaseType(databaseType)
- .table(new SimpleTableSegment(new TableNameSegment(0, 0, new
IdentifierValue("t_order")))).build();
- sqlStatement.buildAttributes();
when(shardingRule.isShardingTable("t_order")).thenReturn(true);
when(shardingRule.getShardingTable("t_order")).thenReturn(new
ShardingTable(Arrays.asList("ds_0", "ds_1"), "t_order"));
Collection<RouteUnit> routeUnits = new LinkedList<>();
routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"),
Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
+ AlterTableStatement sqlStatement =
AlterTableStatement.builder().databaseType(databaseType)
+ .table(new SimpleTableSegment(new TableNameSegment(0, 0, new
IdentifierValue("t_order")))).build();
when(queryContext.getSqlStatementContext()).thenReturn(new
CommonSQLStatementContext(sqlStatement));
assertThrows(ShardingDDLRouteException.class, () -> new
ShardingAlterTableRouteContextChecker().check(shardingRule, queryContext,
database, mock(ConfigurationProperties.class), routeContext));
}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropIndexRouteContextCheckerTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropIndexRouteContextCheckerTest.java
index 0b6bb9a0790..c97ae4c7a16 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropIndexRouteContextCheckerTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropIndexRouteContextCheckerTest.java
@@ -69,12 +69,6 @@ class ShardingDropIndexRouteContextCheckerTest {
@Test
void assertCheckWithSameRouteResultShardingTableIndexForPostgreSQL() {
- DropIndexStatement sqlStatement = DropIndexStatement.builder()
- .databaseType(databaseType)
- .indexes(Arrays.asList(new IndexSegment(0, 0, new
IndexNameSegment(0, 0, new IdentifierValue("t_order_index"))),
- new IndexSegment(0, 0, new IndexNameSegment(0, 0, new
IdentifierValue("t_order_index_new")))))
- .build();
- sqlStatement.buildAttributes();
ShardingSphereTable table = mock(ShardingSphereTable.class);
when(table.getName()).thenReturn("t_order");
when(database.getSchema("public").getAllTables()).thenReturn(Collections.singleton(table));
@@ -86,18 +80,16 @@ class ShardingDropIndexRouteContextCheckerTest {
routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"),
Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
routeUnits.add(new RouteUnit(new RouteMapper("ds_1", "ds_1"),
Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
+ DropIndexStatement sqlStatement =
DropIndexStatement.builder().databaseType(databaseType)
+ .indexes(Arrays.asList(new IndexSegment(0, 0, new
IndexNameSegment(0, 0, new IdentifierValue("t_order_index"))),
+ new IndexSegment(0, 0, new IndexNameSegment(0, 0, new
IdentifierValue("t_order_index_new")))))
+ .build();
when(queryContext.getSqlStatementContext()).thenReturn(new
CommonSQLStatementContext(sqlStatement));
assertDoesNotThrow(() -> new
ShardingDropIndexRouteContextChecker().check(shardingRule, queryContext,
database, mock(ConfigurationProperties.class), routeContext));
}
@Test
void assertCheckWithDifferentRouteResultShardingTableIndexForPostgreSQL() {
- DropIndexStatement sqlStatement = DropIndexStatement.builder()
- .databaseType(databaseType)
- .indexes(Arrays.asList(new IndexSegment(0, 0, new
IndexNameSegment(0, 0, new IdentifierValue("t_order_index"))),
- new IndexSegment(0, 0, new IndexNameSegment(0, 0, new
IdentifierValue("t_order_index_new")))))
- .build();
- sqlStatement.buildAttributes();
ShardingSphereTable table = mock(ShardingSphereTable.class);
when(table.getName()).thenReturn("t_order");
when(database.getSchema("public").getAllTables()).thenReturn(Collections.singleton(table));
@@ -108,6 +100,10 @@ class ShardingDropIndexRouteContextCheckerTest {
Collection<RouteUnit> routeUnits = new LinkedList<>();
routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"),
Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
+ DropIndexStatement sqlStatement =
DropIndexStatement.builder().databaseType(databaseType)
+ .indexes(Arrays.asList(new IndexSegment(0, 0, new
IndexNameSegment(0, 0, new IdentifierValue("t_order_index"))),
+ new IndexSegment(0, 0, new IndexNameSegment(0, 0, new
IdentifierValue("t_order_index_new")))))
+ .build();
when(queryContext.getSqlStatementContext()).thenReturn(new
CommonSQLStatementContext(sqlStatement));
assertThrows(ShardingDDLRouteException.class, () -> new
ShardingDropIndexRouteContextChecker().check(shardingRule, queryContext,
database, mock(ConfigurationProperties.class), routeContext));
}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactoryTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactoryTest.java
index 3ee42748089..a282c2713dc 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactoryTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactoryTest.java
@@ -225,7 +225,6 @@ class ShardingRouteEngineFactoryTest {
void assertNewInstanceForCursorStatementWithShardingTable() {
CursorStatementContext cursorStatementContext =
mock(CursorStatementContext.class, RETURNS_DEEP_STUBS);
CursorStatement cursorStatement = new CursorStatement(databaseType,
null, null);
- cursorStatement.buildAttributes();
when(cursorStatementContext.getSqlStatement()).thenReturn(cursorStatement);
Collection<SimpleTableSegment> tableSegments =
createSimpleTableSegments();
Collection<String> tableNames = tableSegments.stream().map(each ->
each.getTableName().getIdentifier().getValue()).collect(Collectors.toSet());
@@ -243,7 +242,6 @@ class ShardingRouteEngineFactoryTest {
void assertNewInstanceForCursorStatementWithSingleTable() {
CursorStatementContext cursorStatementContext =
mock(CursorStatementContext.class, RETURNS_DEEP_STUBS);
CursorStatement cursorStatement = new CursorStatement(databaseType,
null, null);
- cursorStatement.buildAttributes();
when(cursorStatementContext.getSqlStatement()).thenReturn(cursorStatement);
Collection<SimpleTableSegment> tableSegments =
createSimpleTableSegments();
when(cursorStatementContext.getTablesContext().getSimpleTables()).thenReturn(tableSegments);
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingTableBroadcastRouteEngineTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingTableBroadcastRouteEngineTest.java
index 472eaec3ee8..99fd44e50d2 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingTableBroadcastRouteEngineTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/broadcast/ShardingTableBroadcastRouteEngineTest.java
@@ -90,7 +90,6 @@ class ShardingTableBroadcastRouteEngineTest {
when(segment.getIndexName().getIdentifier().getValue()).thenReturn("t_order");
when(segment.getOwner()).thenReturn(Optional.empty());
DropIndexStatement sqlStatement =
DropIndexStatement.builder().databaseType(databaseType).indexes(Collections.singleton(segment)).build();
- sqlStatement.buildAttributes();
ShardingSphereDatabase database = new ShardingSphereDatabase("foo_db",
databaseType, mock(ResourceMetaData.class), mock(RuleMetaData.class),
Collections.singleton(schema));
ShardingTableBroadcastRouteEngine shardingTableBroadcastRouteEngine =
new ShardingTableBroadcastRouteEngine(database, sqlStatement,
Collections.emptyList());
RouteContext routeContext =
shardingTableBroadcastRouteEngine.route(createShardingRule());
@@ -108,7 +107,6 @@ class ShardingTableBroadcastRouteEngineTest {
when(schema.getName()).thenReturn("foo_db");
when(schema.getTable(anyString()).containsIndex(anyString())).thenReturn(false);
DropIndexStatement sqlStatement =
DropIndexStatement.builder().databaseType(databaseType).build();
- sqlStatement.buildAttributes();
ShardingSphereDatabase database = new ShardingSphereDatabase("foo_db",
databaseType, mock(ResourceMetaData.class), mock(RuleMetaData.class),
Collections.singleton(schema));
ShardingTableBroadcastRouteEngine shardingTableBroadcastRouteEngine =
new ShardingTableBroadcastRouteEngine(database, sqlStatement,
Collections.emptyList());
RouteContext routeContext =
shardingTableBroadcastRouteEngine.route(createShardingRule());
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/unicast/ShardingUnicastRouteEngineTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/unicast/ShardingUnicastRouteEngineTest.java
index cd1840a6e81..76780d0e37c 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/unicast/ShardingUnicastRouteEngineTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/unicast/ShardingUnicastRouteEngineTest.java
@@ -93,7 +93,6 @@ class ShardingUnicastRouteEngineTest {
@Test
void assertRoutingForBroadcastTableWithCursorStatement() {
CursorStatement sqlStatement = new CursorStatement(databaseType, null,
null);
- sqlStatement.buildAttributes();
RouteContext actual = new ShardingUnicastRouteEngine(sqlStatement,
Collections.singleton("t_config"), new
ConnectionContext(Collections::emptySet)).route(rule);
assertThat(actual.getRouteUnits().size(), is(1));
assertThat(actual.getRouteUnits().iterator().next().getDataSourceMapper().getActualName(),
is("ds_0"));
diff --git
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingTableNodesExecutorTest.java
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingTableNodesExecutorTest.java
index bd3174f5363..4540fdb2a19 100644
---
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingTableNodesExecutorTest.java
+++
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingTableNodesExecutorTest.java
@@ -77,7 +77,6 @@ class ShowShardingTableNodesExecutorTest {
private void assertOrder(final ShardingRule rule) throws SQLException {
ShowShardingTableNodesStatement sqlStatement = new
ShowShardingTableNodesStatement("t_order", null);
- sqlStatement.buildAttributes();
DistSQLQueryExecuteEngine engine = new
DistSQLQueryExecuteEngine(sqlStatement, "foo_db", mockContextManager(rule),
mock(DistSQLConnectionContext.class));
engine.executeQuery();
Collection<LocalDataQueryResultRow> actual = engine.getRows();
@@ -97,7 +96,6 @@ class ShowShardingTableNodesExecutorTest {
private void assertOrderItem(final ShardingRule rule) throws SQLException {
ShowShardingTableNodesStatement sqlStatement = new
ShowShardingTableNodesStatement("t_order_item", null);
- sqlStatement.buildAttributes();
DistSQLQueryExecuteEngine engine = new
DistSQLQueryExecuteEngine(sqlStatement, "foo_db", mockContextManager(rule),
mock(DistSQLConnectionContext.class));
engine.executeQuery();
Collection<LocalDataQueryResultRow> actual = engine.getRows();
@@ -109,7 +107,6 @@ class ShowShardingTableNodesExecutorTest {
private void assertAll(final ShardingRule rule) throws SQLException {
ShowShardingTableNodesStatement sqlStatement = new
ShowShardingTableNodesStatement(null, null);
- sqlStatement.buildAttributes();
DistSQLQueryExecuteEngine engine = new
DistSQLQueryExecuteEngine(sqlStatement, "foo_db", mockContextManager(rule),
mock(DistSQLConnectionContext.class));
engine.executeQuery();
List<LocalDataQueryResultRow> actual = new
ArrayList<>(engine.getRows());
diff --git
a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/engine/statement/SQLStatementCopyUtils.java
b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/engine/statement/SQLStatementCopyUtils.java
index ec07d56ac83..63e4d27d22e 100644
---
a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/engine/statement/SQLStatementCopyUtils.java
+++
b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/engine/statement/SQLStatementCopyUtils.java
@@ -37,6 +37,5 @@ public final class SQLStatementCopyUtils {
boundSQLStatement.addParameterMarkers(originalSQLStatement.getParameterMarkers());
boundSQLStatement.getVariableNames().addAll(originalSQLStatement.getVariableNames());
boundSQLStatement.getComments().addAll(originalSQLStatement.getComments());
- boundSQLStatement.buildAttributes();
}
}
diff --git
a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/SQLStatementContextFactoryTest.java
b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/SQLStatementContextFactoryTest.java
index 6280eddac2c..24709fb32ad 100644
---
a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/SQLStatementContextFactoryTest.java
+++
b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/SQLStatementContextFactoryTest.java
@@ -62,7 +62,6 @@ class SQLStatementContextFactoryTest {
void
assertSQLStatementContextCreatedWhenSQLStatementInstanceOfSelectStatement() {
ProjectionsSegment projectionsSegment = new ProjectionsSegment(0, 0);
SelectStatement selectStatement =
SelectStatement.builder().databaseType(databaseType).limit(new LimitSegment(0,
10, null, null)).projections(projectionsSegment).build();
- selectStatement.buildAttributes();
SQLStatementContext sqlStatementContext = new
SQLBindEngine(mockMetaData(), "foo_db", new
HintValueContext()).bind(selectStatement);
assertThat(sqlStatementContext, isA(SelectStatementContext.class));
}
@@ -71,7 +70,6 @@ class SQLStatementContextFactoryTest {
void assertSQLStatementContextCreatedWhenSQLStatementInstance() {
InsertStatement insertStatement =
InsertStatement.builder().databaseType(databaseType)
.table(new SimpleTableSegment(new TableNameSegment(0, 0, new
IdentifierValue("tbl")))).build();
- insertStatement.buildAttributes();
SQLStatementContext sqlStatementContext = new
SQLBindEngine(mockMetaData(), "foo_db", new
HintValueContext()).bind(insertStatement);
assertThat(sqlStatementContext, isA(InsertStatementContext.class));
}
@@ -79,7 +77,6 @@ class SQLStatementContextFactoryTest {
@Test
void
assertSQLStatementContextCreatedWhenSQLStatementNotInstanceOfSelectStatementAndInsertStatement()
{
AlterDatabaseStatement alterDatabaseStatement = new
AlterDatabaseStatement(databaseType);
- alterDatabaseStatement.buildAttributes();
SQLStatementContext sqlStatementContext = new
SQLBindEngine(mockMetaData(), "foo_db", new
HintValueContext()).bind(alterDatabaseStatement);
assertThat(sqlStatementContext, isA(CommonSQLStatementContext.class));
}
@@ -87,9 +84,7 @@ class SQLStatementContextFactoryTest {
@Test
void assertNewInstanceForCursorStatement() {
SelectStatement selectStatement =
SelectStatement.builder().databaseType(databaseType).projections(new
ProjectionsSegment(0, 0)).build();
- selectStatement.buildAttributes();
CursorStatement cursorStatement = new CursorStatement(databaseType,
null, selectStatement);
- cursorStatement.buildAttributes();
SQLStatementContext actual = new SQLBindEngine(mockMetaData(),
"foo_db", new HintValueContext()).bind(cursorStatement);
assertThat(actual, isA(CursorStatementContext.class));
}
@@ -97,7 +92,6 @@ class SQLStatementContextFactoryTest {
@Test
void assertNewInstanceForCloseStatement() {
CloseStatement closeStatement = new CloseStatement(databaseType, null,
false);
- closeStatement.buildAttributes();
SQLStatementContext actual = new SQLBindEngine(mockMetaData(),
"foo_db", new HintValueContext()).bind(closeStatement);
assertThat(actual, isA(CursorHeldSQLStatementContext.class));
}
@@ -105,7 +99,6 @@ class SQLStatementContextFactoryTest {
@Test
void assertNewInstanceForMoveStatement() {
MoveStatement moveStatement = new MoveStatement(databaseType, null,
null);
- moveStatement.buildAttributes();
SQLStatementContext actual = new SQLBindEngine(mockMetaData(),
"foo_db", new HintValueContext()).bind(moveStatement);
assertThat(actual, isA(CursorHeldSQLStatementContext.class));
}
@@ -113,9 +106,7 @@ class SQLStatementContextFactoryTest {
@Test
void assertNewInstanceForFetchStatement() {
FetchStatement fetchStatement = new FetchStatement(databaseType, null,
null);
- fetchStatement.buildAttributes();
- SQLStatementContext actual = new SQLBindEngine(mockMetaData(),
"foo_db", new HintValueContext()).bind(fetchStatement);
- assertThat(actual, isA(CursorHeldSQLStatementContext.class));
+ assertThat(new SQLBindEngine(mockMetaData(), "foo_db", new
HintValueContext()).bind(fetchStatement),
isA(CursorHeldSQLStatementContext.class));
}
private ShardingSphereMetaData mockMetaData() {
diff --git
a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ExplainStatementContextTest.java
b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ExplainStatementContextTest.java
index 0d61d610302..37e11203b44 100644
---
a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ExplainStatementContextTest.java
+++
b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ExplainStatementContextTest.java
@@ -60,7 +60,6 @@ class ExplainStatementContextTest {
@Test
void assertNewInstance() {
ExplainStatement explainStatement = new ExplainStatement(databaseType,
explainableSQLStatement);
- explainStatement.buildAttributes();
ExplainStatementContext actual = new ExplainStatementContext(metaData,
explainStatement, "foo_db");
assertThat(actual.getSqlStatement(), is(explainStatement));
assertThat(actual.getTablesContext().getSimpleTables(),
is(Collections.emptyList()));
diff --git
a/infra/context/src/test/java/org/apache/shardingsphere/infra/connection/kernel/KernelProcessorTest.java
b/infra/context/src/test/java/org/apache/shardingsphere/infra/connection/kernel/KernelProcessorTest.java
index 90fb679bf8a..61749684a78 100644
---
a/infra/context/src/test/java/org/apache/shardingsphere/infra/connection/kernel/KernelProcessorTest.java
+++
b/infra/context/src/test/java/org/apache/shardingsphere/infra/connection/kernel/KernelProcessorTest.java
@@ -63,7 +63,6 @@ class KernelProcessorTest {
@Test
void assertGenerateExecutionContext() {
SelectStatement selectStatement =
SelectStatement.builder().databaseType(databaseType).build();
- selectStatement.buildAttributes();
SQLStatementContext sqlStatementContext = new
CommonSQLStatementContext(selectStatement);
ConnectionContext connectionContext = mock(ConnectionContext.class);
when(connectionContext.getCurrentDatabaseName()).thenReturn(Optional.of("foo_db"));
diff --git
a/infra/parser/src/main/java/org/apache/shardingsphere/infra/parser/sql/SQLStatementParserExecutor.java
b/infra/parser/src/main/java/org/apache/shardingsphere/infra/parser/sql/SQLStatementParserExecutor.java
index dcc22d0fd03..830936fea52 100644
---
a/infra/parser/src/main/java/org/apache/shardingsphere/infra/parser/sql/SQLStatementParserExecutor.java
+++
b/infra/parser/src/main/java/org/apache/shardingsphere/infra/parser/sql/SQLStatementParserExecutor.java
@@ -53,8 +53,6 @@ public final class SQLStatementParserExecutor {
* @return SQL statement
*/
public SQLStatement parse(final String sql) {
- SQLStatement result = visitorEngine.visit(parserEngine.parse(sql,
false));
- result.buildAttributes();
- return result;
+ return visitorEngine.visit(parserEngine.parse(sql, false));
}
}
diff --git
a/infra/route/core/src/test/java/org/apache/shardingsphere/infra/route/engine/tableless/TablelessRouteEngineFactoryTest.java
b/infra/route/core/src/test/java/org/apache/shardingsphere/infra/route/engine/tableless/TablelessRouteEngineFactoryTest.java
index 7be9bfa7a1e..9f7fe82e64f 100644
---
a/infra/route/core/src/test/java/org/apache/shardingsphere/infra/route/engine/tableless/TablelessRouteEngineFactoryTest.java
+++
b/infra/route/core/src/test/java/org/apache/shardingsphere/infra/route/engine/tableless/TablelessRouteEngineFactoryTest.java
@@ -96,8 +96,7 @@ class TablelessRouteEngineFactoryTest {
SetStatement setStatement = mock(SetStatement.class);
when(sqlStatementContext.getSqlStatement()).thenReturn(setStatement);
QueryContext queryContext = new QueryContext(sqlStatementContext, "",
Collections.emptyList(), new HintValueContext(), mockConnectionContext(),
mock(ShardingSphereMetaData.class));
- TablelessRouteEngine actual =
TablelessRouteEngineFactory.newInstance(queryContext, database);
- assertThat(actual, isA(TablelessDataSourceBroadcastRouteEngine.class));
+ assertThat(TablelessRouteEngineFactory.newInstance(queryContext,
database), isA(TablelessDataSourceBroadcastRouteEngine.class));
}
@Test
@@ -106,8 +105,7 @@ class TablelessRouteEngineFactoryTest {
when(dalStatement.getAttributes()).thenReturn(new
SQLStatementAttributes(new
TablelessDataSourceBroadcastRouteSQLStatementAttribute()));
when(sqlStatementContext.getSqlStatement()).thenReturn(dalStatement);
QueryContext queryContext = new QueryContext(sqlStatementContext, "",
Collections.emptyList(), new HintValueContext(), mockConnectionContext(),
mock(ShardingSphereMetaData.class));
- TablelessRouteEngine actual =
TablelessRouteEngineFactory.newInstance(queryContext, database);
- assertThat(actual, isA(TablelessDataSourceBroadcastRouteEngine.class));
+ assertThat(TablelessRouteEngineFactory.newInstance(queryContext,
database), isA(TablelessDataSourceBroadcastRouteEngine.class));
}
@Test
@@ -115,8 +113,7 @@ class TablelessRouteEngineFactoryTest {
TCLStatement tclStatement = mock(TCLStatement.class);
when(sqlStatementContext.getSqlStatement()).thenReturn(tclStatement);
QueryContext queryContext = new QueryContext(sqlStatementContext, "",
Collections.emptyList(), new HintValueContext(), mockConnectionContext(),
mock(ShardingSphereMetaData.class));
- TablelessRouteEngine actual =
TablelessRouteEngineFactory.newInstance(queryContext, database);
- assertThat(actual, isA(TablelessDataSourceBroadcastRouteEngine.class));
+ assertThat(TablelessRouteEngineFactory.newInstance(queryContext,
database), isA(TablelessDataSourceBroadcastRouteEngine.class));
}
@Test
@@ -129,8 +126,7 @@ class TablelessRouteEngineFactoryTest {
when(DatabaseTypedSPILoader.findService(DialectDALStatementBroadcastRouteDecider.class,
databaseType)).thenReturn(Optional.of(dialectDALStatementBroadcastRouteDecider));
when(sqlStatementContext.getSqlStatement()).thenReturn(sqlStatement);
QueryContext queryContext = new QueryContext(sqlStatementContext, "",
Collections.emptyList(), new HintValueContext(), mockConnectionContext(),
mock(ShardingSphereMetaData.class));
- TablelessRouteEngine actual =
TablelessRouteEngineFactory.newInstance(queryContext, database);
- assertThat(actual, isA(TablelessDataSourceBroadcastRouteEngine.class));
+ assertThat(TablelessRouteEngineFactory.newInstance(queryContext,
database), isA(TablelessDataSourceBroadcastRouteEngine.class));
}
@Test
@@ -143,8 +139,7 @@ class TablelessRouteEngineFactoryTest {
when(DatabaseTypedSPILoader.findService(DialectDALStatementBroadcastRouteDecider.class,
databaseType)).thenReturn(Optional.of(dialectDALStatementBroadcastRouteDecider));
when(sqlStatementContext.getSqlStatement()).thenReturn(sqlStatement);
QueryContext queryContext = new QueryContext(sqlStatementContext, "",
Collections.emptyList(), new HintValueContext(), mockConnectionContext(),
mock(ShardingSphereMetaData.class));
- TablelessRouteEngine actual =
TablelessRouteEngineFactory.newInstance(queryContext, database);
- assertThat(actual, isA(TablelessInstanceBroadcastRouteEngine.class));
+ assertThat(TablelessRouteEngineFactory.newInstance(queryContext,
database), isA(TablelessInstanceBroadcastRouteEngine.class));
}
@Test
@@ -157,44 +152,37 @@ class TablelessRouteEngineFactoryTest {
when(DatabaseTypedSPILoader.findService(DialectDALStatementBroadcastRouteDecider.class,
databaseType)).thenReturn(Optional.of(dialectDALStatementBroadcastRouteDecider));
when(sqlStatementContext.getSqlStatement()).thenReturn(sqlStatement);
QueryContext queryContext = new QueryContext(sqlStatementContext, "",
Collections.emptyList(), new HintValueContext(), mockConnectionContext(),
mock(ShardingSphereMetaData.class));
- TablelessRouteEngine actual =
TablelessRouteEngineFactory.newInstance(queryContext, database);
- assertThat(actual, isA(TablelessDataSourceUnicastRouteEngine.class));
+ assertThat(TablelessRouteEngineFactory.newInstance(queryContext,
database), isA(TablelessDataSourceUnicastRouteEngine.class));
}
@Test
void assertNewInstanceForCloseAllStatement() {
CursorHeldSQLStatementContext closeStatementContext =
mock(CursorHeldSQLStatementContext.class, RETURNS_DEEP_STUBS);
when(closeStatementContext.getTablesContext().getDatabaseName()).thenReturn(Optional.empty());
- CloseStatement closeStatement = new CloseStatement(databaseType, null,
true);
- closeStatement.buildAttributes();
-
when(closeStatementContext.getSqlStatement()).thenReturn(closeStatement);
+ when(closeStatementContext.getSqlStatement()).thenReturn(new
CloseStatement(databaseType, null, true));
QueryContext queryContext = new QueryContext(closeStatementContext,
"", Collections.emptyList(), new HintValueContext(), mockConnectionContext(),
mock(ShardingSphereMetaData.class));
- TablelessRouteEngine actual =
TablelessRouteEngineFactory.newInstance(queryContext, database);
- assertThat(actual, isA(TablelessDataSourceBroadcastRouteEngine.class));
+ assertThat(TablelessRouteEngineFactory.newInstance(queryContext,
database), isA(TablelessDataSourceBroadcastRouteEngine.class));
}
@Test
void assertNewInstanceForCreateSchemaStatement() {
QueryContext queryContext = mock(QueryContext.class,
RETURNS_DEEP_STUBS);
when(queryContext.getSqlStatementContext().getSqlStatement()).thenReturn(mock(CreateSchemaStatement.class,
RETURNS_DEEP_STUBS));
- TablelessRouteEngine actual =
TablelessRouteEngineFactory.newInstance(queryContext, database);
- assertThat(actual, isA(TablelessDataSourceBroadcastRouteEngine.class));
+ assertThat(TablelessRouteEngineFactory.newInstance(queryContext,
database), isA(TablelessDataSourceBroadcastRouteEngine.class));
}
@Test
void assertNewInstanceForAlterSchemaStatement() {
QueryContext queryContext = mock(QueryContext.class,
RETURNS_DEEP_STUBS);
when(queryContext.getSqlStatementContext().getSqlStatement()).thenReturn(mock(AlterSchemaStatement.class,
RETURNS_DEEP_STUBS));
- TablelessRouteEngine actual =
TablelessRouteEngineFactory.newInstance(queryContext, database);
- assertThat(actual, isA(TablelessDataSourceBroadcastRouteEngine.class));
+ assertThat(TablelessRouteEngineFactory.newInstance(queryContext,
database), isA(TablelessDataSourceBroadcastRouteEngine.class));
}
@Test
void assertNewInstanceForDropSchemaStatement() {
QueryContext queryContext = mock(QueryContext.class,
RETURNS_DEEP_STUBS);
when(queryContext.getSqlStatementContext().getSqlStatement()).thenReturn(mock(DropSchemaStatement.class,
RETURNS_DEEP_STUBS));
- TablelessRouteEngine actual =
TablelessRouteEngineFactory.newInstance(queryContext, database);
- assertThat(actual, isA(TablelessDataSourceBroadcastRouteEngine.class));
+ assertThat(TablelessRouteEngineFactory.newInstance(queryContext,
database), isA(TablelessDataSourceBroadcastRouteEngine.class));
}
@Test
@@ -202,7 +190,6 @@ class TablelessRouteEngineFactoryTest {
QueryContext queryContext = mock(QueryContext.class,
RETURNS_DEEP_STUBS);
when(queryContext.getSqlStatementContext()).thenReturn(mock(SelectStatementContext.class));
when(queryContext.getSqlStatementContext().getSqlStatement()).thenReturn(mock(SelectStatement.class));
- TablelessRouteEngine actual =
TablelessRouteEngineFactory.newInstance(queryContext, database);
- assertThat(actual, isA(TablelessDataSourceUnicastRouteEngine.class));
+ assertThat(TablelessRouteEngineFactory.newInstance(queryContext,
database), isA(TablelessDataSourceUnicastRouteEngine.class));
}
}
diff --git
a/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/update/SetDefaultSingleTableStorageUnitExecutorTest.java
b/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/update/SetDefaultSingleTableStorageUnitExecutorTest.java
index a6a38fb03a0..5bf8bf51d1b 100644
---
a/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/update/SetDefaultSingleTableStorageUnitExecutorTest.java
+++
b/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/update/SetDefaultSingleTableStorageUnitExecutorTest.java
@@ -53,7 +53,6 @@ class SetDefaultSingleTableStorageUnitExecutorTest {
SingleRule rule = mock(SingleRule.class, RETURNS_DEEP_STUBS);
when(rule.getAttributes().findAttribute(DataSourceMapperRuleAttribute.class)).thenReturn(Optional.empty());
SetDefaultSingleTableStorageUnitStatement sqlStatement = new
SetDefaultSingleTableStorageUnitStatement("foo_ds");
- sqlStatement.buildAttributes();
DistSQLUpdateExecuteEngine engine = new
DistSQLUpdateExecuteEngine(sqlStatement, "foo_db", mockContextManager(database,
rule, "foo_ds"), null);
assertThrows(MissingRequiredStorageUnitsException.class,
engine::executeUpdate);
}
@@ -65,7 +64,6 @@ class SetDefaultSingleTableStorageUnitExecutorTest {
when(rule.getConfiguration()).thenReturn(new
SingleRuleConfiguration(Collections.emptyList(), "foo_ds"));
ContextManager contextManager = mockContextManager(database, rule,
null);
SetDefaultSingleTableStorageUnitStatement sqlStatement = new
SetDefaultSingleTableStorageUnitStatement(null);
- sqlStatement.buildAttributes();
new DistSQLUpdateExecuteEngine(sqlStatement, "foo_db", contextManager,
null).executeUpdate();
MetaDataManagerPersistService metaDataManagerPersistService =
contextManager.getPersistServiceFacade().getModeFacade().getMetaDataManagerService();
verify(metaDataManagerPersistService).removeRuleConfigurationItem(any(),
ArgumentMatchers.<SingleRuleConfiguration>argThat(x ->
x.getDefaultDataSource().equals(Optional.of("foo_ds"))));
@@ -83,7 +81,6 @@ class SetDefaultSingleTableStorageUnitExecutorTest {
when(rule.getAttributes().findAttribute(DataSourceMapperRuleAttribute.class)).thenReturn(Optional.empty());
ContextManager contextManager = mockContextManager(database, rule,
"bar_ds");
SetDefaultSingleTableStorageUnitStatement sqlStatement = new
SetDefaultSingleTableStorageUnitStatement("bar_ds");
- sqlStatement.buildAttributes();
new DistSQLUpdateExecuteEngine(sqlStatement, "foo_db", contextManager,
null).executeUpdate();
MetaDataManagerPersistService metaDataManagerPersistService =
contextManager.getPersistServiceFacade().getModeFacade().getMetaDataManagerService();
verify(metaDataManagerPersistService).alterRuleConfiguration(any(),
ArgumentMatchers.<SingleRuleConfiguration>argThat(x ->
x.getDefaultDataSource().equals(Optional.of("bar_ds"))));
diff --git
a/parser/distsql/engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/featured/DistSQLParserEngine.java
b/parser/distsql/engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/featured/DistSQLParserEngine.java
index 3d90a9e1d6f..41928224193 100644
---
a/parser/distsql/engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/featured/DistSQLParserEngine.java
+++
b/parser/distsql/engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/featured/DistSQLParserEngine.java
@@ -58,8 +58,6 @@ public final class DistSQLParserEngine {
throw new SQLParsingException(sql);
}
SQLVisitor visitor =
facade.getVisitorClass().getDeclaredConstructor().newInstance();
- SQLStatement result = (SQLStatement)
visitor.visit(parseASTNode.getRootNode());
- result.buildAttributes();
- return result;
+ return (SQLStatement) visitor.visit(parseASTNode.getRootNode());
}
}
diff --git
a/parser/distsql/engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/kernel/KernelDistSQLStatementParserEngine.java
b/parser/distsql/engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/kernel/KernelDistSQLStatementParserEngine.java
index 7f12a9d9348..db18278cbfc 100644
---
a/parser/distsql/engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/kernel/KernelDistSQLStatementParserEngine.java
+++
b/parser/distsql/engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/kernel/KernelDistSQLStatementParserEngine.java
@@ -37,9 +37,7 @@ public final class KernelDistSQLStatementParserEngine {
*/
public SQLStatement parse(final String sql) {
ASTNode astNode = SQLParserFactory.newInstance(sql,
KernelDistSQLLexer.class, KernelDistSQLParser.class).parse();
- SQLStatement result = getSQLStatement(sql, (ParseASTNode) astNode);
- result.buildAttributes();
- return result;
+ return getSQLStatement(sql, (ParseASTNode) astNode);
}
private SQLStatement getSQLStatement(final String sql, final ParseASTNode
parseASTNode) {
diff --git
a/parser/sql/engine/dialect/hive/src/main/java/org/apache/shardingsphere/sql/parser/engine/hive/visitor/statement/type/HiveDMLStatementVisitor.java
b/parser/sql/engine/dialect/hive/src/main/java/org/apache/shardingsphere/sql/parser/engine/hive/visitor/statement/type/HiveDMLStatementVisitor.java
index 8fcbb9d7b62..2f0bcfdcd55 100644
---
a/parser/sql/engine/dialect/hive/src/main/java/org/apache/shardingsphere/sql/parser/engine/hive/visitor/statement/type/HiveDMLStatementVisitor.java
+++
b/parser/sql/engine/dialect/hive/src/main/java/org/apache/shardingsphere/sql/parser/engine/hive/visitor/statement/type/HiveDMLStatementVisitor.java
@@ -953,7 +953,6 @@ public final class HiveDMLStatementVisitor extends
HiveStatementVisitor implemen
insertStmt.getInsertSelect().ifPresent(subquery ->
setFromForSelect(subquery, sourceTable));
}
insertStmt.addParameterMarkers(getParameterMarkerSegments());
- insertStmt.buildAttributes();
multiTableInsertInto.getInsertStatements().add(insertStmt);
}
InsertStatement result =
InsertStatement.builder().databaseType(getDatabaseType()).multiTableInsertType(MultiTableInsertType.ALL).multiTableInsertInto(multiTableInsertInto).build();
@@ -1013,7 +1012,6 @@ public final class HiveDMLStatementVisitor extends
HiveStatementVisitor implemen
insertStmt.getInsertSelect().ifPresent(subquery ->
setFromForSelect(subquery, sourceTable));
}
insertStmt.addParameterMarkers(getParameterMarkerSegments());
- insertStmt.buildAttributes();
multiTableInsertInto.getInsertStatements().add(insertStmt);
}
InsertStatement result =
InsertStatement.builder().databaseType(getDatabaseType()).multiTableInsertType(MultiTableInsertType.ALL).multiTableInsertInto(multiTableInsertInto).build();
diff --git
a/parser/sql/engine/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/engine/oracle/visitor/statement/type/OracleDMLStatementVisitor.java
b/parser/sql/engine/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/engine/oracle/visitor/statement/type/OracleDMLStatementVisitor.java
index deb91819968..ee9c310cf70 100644
---
a/parser/sql/engine/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/engine/oracle/visitor/statement/type/OracleDMLStatementVisitor.java
+++
b/parser/sql/engine/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/engine/oracle/visitor/statement/type/OracleDMLStatementVisitor.java
@@ -374,7 +374,6 @@ public final class OracleDMLStatementVisitor extends
OracleStatementVisitor impl
for (MultiTableElementContext each : ctx) {
InsertStatement insertStatement = (InsertStatement) visit(each);
addParameterMarkerSegments(addedSegments, insertStatement);
- insertStatement.buildAttributes();
result.add(insertStatement);
}
return result;
diff --git
a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/SQLStatement.java
b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/SQLStatement.java
index 016a87fcbf1..fae5469e294 100644
---
a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/SQLStatement.java
+++
b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/SQLStatement.java
@@ -69,10 +69,4 @@ public class SQLStatement implements ASTNode {
uniqueParameterIndexes.add(each.getParameterIndex());
}
}
-
- /**
- * Build SQL statement attributes.
- */
- public void buildAttributes() {
- }
}
diff --git
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/StandardDatabaseProxyConnectorTest.java
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/StandardDatabaseProxyConnectorTest.java
index 39ab92e8659..c985fdd6186 100644
---
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/StandardDatabaseProxyConnectorTest.java
+++
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/StandardDatabaseProxyConnectorTest.java
@@ -293,7 +293,6 @@ class StandardDatabaseProxyConnectorTest {
void assertExecuteWithUpdateResultAndAccumulate() throws SQLException {
InsertStatementContext sqlStatementContext =
mock(InsertStatementContext.class, RETURNS_DEEP_STUBS);
InsertStatement insertStatement =
InsertStatement.builder().databaseType(databaseType).build();
- insertStatement.buildAttributes();
when(sqlStatementContext.getSqlStatement()).thenReturn(insertStatement);
when(sqlStatementContext.getTablesContext().getDatabaseNames()).thenReturn(Collections.emptyList());
when(sqlStatementContext.getTablesContext().getSchemaNames()).thenReturn(Collections.emptyList());
@@ -364,7 +363,6 @@ class StandardDatabaseProxyConnectorTest {
@Test
void assertConstructWithCloseAllCursorStatement() {
CloseStatement closeStatement = new CloseStatement(databaseType, null,
true);
- closeStatement.buildAttributes();
SQLStatementContext sqlStatementContext =
createSQLStatementContext(closeStatement);
ConnectionContext connectionContext = mock(ConnectionContext.class,
RETURNS_DEEP_STUBS);
when(databaseConnectionManager.getConnectionSession().getConnectionContext()).thenReturn(connectionContext);
@@ -376,7 +374,6 @@ class StandardDatabaseProxyConnectorTest {
void assertConstructWithNotExistedCursorHeldSQLStatementContext() {
CursorNameSegment cursorNameSegment = new CursorNameSegment(0, 0, new
IdentifierValue("foo_cursor"));
CloseStatement closeStatement = new CloseStatement(databaseType,
cursorNameSegment, false);
- closeStatement.buildAttributes();
CursorHeldSQLStatementContext sqlStatementContext = new
CursorHeldSQLStatementContext(closeStatement);
when(databaseConnectionManager.getConnectionSession().getConnectionContext().getCursorContext()).thenReturn(new
CursorConnectionContext());
assertNotNull(assertThrows(IllegalArgumentException.class, () ->
createDatabaseProxyConnector(JDBCDriverType.STATEMENT,
createQueryContext(sqlStatementContext, mockDatabase()))));
@@ -386,7 +383,6 @@ class StandardDatabaseProxyConnectorTest {
void assertConstructWithCursorHeldSQLStatementContext() {
CursorNameSegment cursorNameSegment = new CursorNameSegment(0, 0, new
IdentifierValue("foo_cursor"));
CloseStatement closeStatement = new CloseStatement(databaseType,
cursorNameSegment, false);
- closeStatement.buildAttributes();
CursorHeldSQLStatementContext sqlStatementContext = new
CursorHeldSQLStatementContext(closeStatement);
CursorConnectionContext cursorConnectionContext = new
CursorConnectionContext();
CursorStatementContext cursorStatementContext =
mock(CursorStatementContext.class, RETURNS_DEEP_STUBS);
@@ -401,7 +397,6 @@ class StandardDatabaseProxyConnectorTest {
void assertConstructWithCursorStatementContext() {
CursorNameSegment cursorNameSegment = new CursorNameSegment(0, 0, new
IdentifierValue("foo_cursor"));
CursorStatement cursorStatement = new CursorStatement(databaseType,
cursorNameSegment, mock(SelectStatement.class));
- cursorStatement.buildAttributes();
CursorStatementContext sqlStatementContext =
mock(CursorStatementContext.class, RETURNS_DEEP_STUBS);
when(sqlStatementContext.getSqlStatement()).thenReturn(cursorStatement);
when(sqlStatementContext.getTablesContext().getDatabaseNames()).thenReturn(Collections.emptyList());
@@ -416,7 +411,6 @@ class StandardDatabaseProxyConnectorTest {
void assertConstructWithSelectStatementContextWithoutDerivedProjections() {
SelectStatementContext sqlStatementContext =
mock(SelectStatementContext.class, RETURNS_DEEP_STUBS);
SelectStatement selectStatement =
SelectStatement.builder().databaseType(databaseType).build();
- selectStatement.buildAttributes();
when(sqlStatementContext.getSqlStatement()).thenReturn(selectStatement);
when(sqlStatementContext.getTablesContext().getDatabaseNames()).thenReturn(Collections.emptyList());
when(sqlStatementContext.getTablesContext().getSchemaNames()).thenReturn(Collections.emptyList());
@@ -540,7 +534,6 @@ class StandardDatabaseProxyConnectorTest {
void assertExecuteWithDerivedQueryResult() throws SQLException {
SelectStatementContext sqlStatementContext =
mock(SelectStatementContext.class, RETURNS_DEEP_STUBS);
SelectStatement selectStatement =
SelectStatement.builder().databaseType(databaseType).build();
- selectStatement.buildAttributes();
when(sqlStatementContext.getSqlStatement()).thenReturn(selectStatement);
when(sqlStatementContext.getTablesContext().getDatabaseNames()).thenReturn(Collections.emptyList());
when(sqlStatementContext.getTablesContext().getSchemaNames()).thenReturn(Collections.emptyList());
@@ -586,7 +579,6 @@ class StandardDatabaseProxyConnectorTest {
@Test
void assertExecuteWithImplicitCommit() throws SQLException {
CloseStatement closeStatement = new CloseStatement(databaseType, null,
false);
- closeStatement.buildAttributes();
SQLStatementContext sqlStatementContext =
createSQLStatementContext(closeStatement);
QueryContext queryContext = createQueryContext(sqlStatementContext,
mockDatabase());
ProxySQLExecutor proxySQLExecutor = mock(ProxySQLExecutor.class,
RETURNS_DEEP_STUBS);
@@ -675,7 +667,6 @@ class StandardDatabaseProxyConnectorTest {
@Test
void assertExecuteWithoutImplicitCommitForDDLWhenOptionDisabled() throws
SQLException {
CloseStatement closeStatement = new CloseStatement(databaseType, null,
false);
- closeStatement.buildAttributes();
SQLStatementContext sqlStatementContext =
createSQLStatementContext(closeStatement);
ProxySQLExecutor proxySQLExecutor = mock(ProxySQLExecutor.class,
RETURNS_DEEP_STUBS);
DatabaseProxyConnector engine =
createDatabaseProxyConnector(JDBCDriverType.STATEMENT,
createQueryContext(sqlStatementContext, mockDatabase()));
@@ -888,7 +879,6 @@ class StandardDatabaseProxyConnectorTest {
}
private SQLStatementContext createSQLStatementContext(final SQLStatement
sqlStatement) {
- sqlStatement.buildAttributes();
SQLStatementContext result = mock(SQLStatementContext.class,
RETURNS_DEEP_STUBS);
when(result.getSqlStatement()).thenReturn(sqlStatement);
when(result.getTablesContext().getDatabaseNames()).thenReturn(Collections.emptyList());
diff --git
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java
index e6abf757502..9c8bb22a107 100644
---
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java
+++
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java
@@ -311,13 +311,9 @@ class ProxyBackendHandlerFactoryTest {
@ParameterizedTest(name = "{0}")
@MethodSource("newInstanceWithDistSQLInTransactionArguments")
- void assertNewInstanceWithDistSQLInTransaction(final String caseName,
final String sql, final boolean buildAttributes,
- final Optional<Class<?
extends ProxyBackendHandler>> expectedHandlerType) throws SQLException {
+ void assertNewInstanceWithDistSQLInTransaction(final String caseName,
final String sql, final Optional<Class<? extends ProxyBackendHandler>>
expectedHandlerType) throws SQLException {
when(connectionSession.getTransactionStatus().isInTransaction()).thenReturn(true);
SQLStatement sqlStatement = ProxySQLComQueryParser.parse(sql,
databaseType, connectionSession);
- if (buildAttributes) {
- sqlStatement.buildAttributes();
- }
if (expectedHandlerType.isPresent()) {
ProxyBackendHandler actual =
ProxyBackendHandlerFactory.newInstance(databaseType, sql, sqlStatement,
connectionSession, new HintValueContext());
assertThat(caseName, actual, isA(expectedHandlerType.get()));
@@ -369,10 +365,9 @@ class ProxyBackendHandlerFactoryTest {
private static Stream<Arguments>
newInstanceWithDistSQLInTransactionArguments() {
return Stream.of(
Arguments.of("non-query DistSQL in transaction", "CREATE
SHARDING TABLE RULE t_order (STORAGE_UNITS(ms_group_0,ms_group_1),"
- + " SHARDING_COLUMN=order_id, TYPE(NAME='hash_mod',
PROPERTIES('sharding-count'='4')));", false,
- Optional.<Class<? extends
ProxyBackendHandler>>empty()),
- Arguments.of("queryable RAL in transaction", "SHOW DIST
VARIABLES", false, Optional.of(DistSQLQueryProxyBackendHandler.class)),
- Arguments.of("RQL in transaction", "SHOW DEFAULT SINGLE TABLE
STORAGE UNIT", false, Optional.of(DistSQLQueryProxyBackendHandler.class)),
- Arguments.of("RUL in transaction", "PREVIEW INSERT INTO
account VALUES(1, 1, 1)", true,
Optional.of(DistSQLQueryProxyBackendHandler.class)));
+ + " SHARDING_COLUMN=order_id, TYPE(NAME='hash_mod',
PROPERTIES('sharding-count'='4')));", Optional.empty()),
+ Arguments.of("queryable RAL in transaction", "SHOW DIST
VARIABLES", Optional.of(DistSQLQueryProxyBackendHandler.class)),
+ Arguments.of("RQL in transaction", "SHOW DEFAULT SINGLE TABLE
STORAGE UNIT", Optional.of(DistSQLQueryProxyBackendHandler.class)),
+ Arguments.of("RUL in transaction", "PREVIEW INSERT INTO
account VALUES(1, 1, 1)", Optional.of(DistSQLQueryProxyBackendHandler.class)));
}
}
diff --git
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLProxyBackendHandlerFactoryTest.java
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLProxyBackendHandlerFactoryTest.java
index efeffbb9aec..dc9817c1d5d 100644
---
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLProxyBackendHandlerFactoryTest.java
+++
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLProxyBackendHandlerFactoryTest.java
@@ -196,7 +196,6 @@ class DistSQLProxyBackendHandlerFactoryTest {
when(contextManager.getDatabase("foo_db")).thenReturn(database);
AlterDefaultShadowAlgorithmStatement statement = new
AlterDefaultShadowAlgorithmStatement(
new ShadowAlgorithmSegment("foo", new
AlgorithmSegment("SQL_HINT", PropertiesBuilder.build(new Property("type",
"value")))));
- statement.buildAttributes();
assertThat(new DistSQLUpdateProxyBackendHandler(statement, mock(),
connectionSession, contextManager).execute(), isA(UpdateResponseHeader.class));
}
diff --git
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLQueryProxyBackendHandlerTest.java
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLQueryProxyBackendHandlerTest.java
index e3d2ea3d663..c26b5d9ac57 100644
---
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLQueryProxyBackendHandlerTest.java
+++
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLQueryProxyBackendHandlerTest.java
@@ -116,9 +116,7 @@ class DistSQLQueryProxyBackendHandlerTest {
}
private ShowTableMetaDataStatement createSqlStatement() {
- ShowTableMetaDataStatement result = new
ShowTableMetaDataStatement(Collections.singleton("t_order"), new
FromDatabaseSegment(0, new DatabaseSegment(0, 0, new
IdentifierValue("foo_db"))));
- result.buildAttributes();
- return result;
+ return new
ShowTableMetaDataStatement(Collections.singleton("t_order"), new
FromDatabaseSegment(0, new DatabaseSegment(0, 0, new
IdentifierValue("foo_db"))));
}
@SuppressWarnings("unchecked")
diff --git
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLUpdateProxyBackendHandlerTest.java
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLUpdateProxyBackendHandlerTest.java
index 94c6866d7fd..426673b3d0b 100644
---
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLUpdateProxyBackendHandlerTest.java
+++
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLUpdateProxyBackendHandlerTest.java
@@ -30,7 +30,6 @@ import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSp
import org.apache.shardingsphere.infra.session.query.QueryContext;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import
org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.junit.jupiter.api.Test;
@@ -62,8 +61,7 @@ class DistSQLUpdateProxyBackendHandlerTest {
void assertEmptyStorageUnit() {
when(contextManager.getDatabase("foo_db")).thenReturn(new
ShardingSphereDatabase("foo_db", databaseType, mock(), mock(),
Collections.emptyList()));
RefreshTableMetaDataStatement sqlStatement = new
RefreshTableMetaDataStatement();
- sqlStatement.buildAttributes();
- DistSQLUpdateProxyBackendHandler backendHandler = new
DistSQLUpdateProxyBackendHandler(sqlStatement, mockQueryContext(),
mockConnectionSession("foo_db"), contextManager);
+ DistSQLUpdateProxyBackendHandler backendHandler = new
DistSQLUpdateProxyBackendHandler(sqlStatement, mockQueryContext(),
mockConnectionSession(), contextManager);
assertThrows(EmptyStorageUnitException.class, backendHandler::execute);
}
@@ -73,8 +71,7 @@ class DistSQLUpdateProxyBackendHandlerTest {
when(resourceMetaData.getStorageUnits()).thenReturn(Collections.singletonMap("ds_0",
mock(StorageUnit.class)));
when(contextManager.getDatabase("foo_db")).thenReturn(new
ShardingSphereDatabase("foo_db", databaseType, resourceMetaData, mock(),
Collections.emptyList()));
RefreshTableMetaDataStatement sqlStatement = new
RefreshTableMetaDataStatement("t_order", "ds_1", null);
- sqlStatement.buildAttributes();
- DistSQLUpdateProxyBackendHandler backendHandler = new
DistSQLUpdateProxyBackendHandler(sqlStatement, mockQueryContext(),
mockConnectionSession("foo_db"), contextManager);
+ DistSQLUpdateProxyBackendHandler backendHandler = new
DistSQLUpdateProxyBackendHandler(sqlStatement, mockQueryContext(),
mockConnectionSession(), contextManager);
assertThrows(MissingRequiredStorageUnitsException.class,
backendHandler::execute);
}
@@ -84,8 +81,7 @@ class DistSQLUpdateProxyBackendHandlerTest {
when(resourceMetaData.getStorageUnits()).thenReturn(Collections.singletonMap("ds_0",
mock(StorageUnit.class)));
when(contextManager.getDatabase("foo_db")).thenReturn(new
ShardingSphereDatabase("foo_db", databaseType, resourceMetaData, mock(),
Collections.emptyList()));
RefreshTableMetaDataStatement sqlStatement = new
RefreshTableMetaDataStatement("t_order", "ds_0", "bar_db");
- sqlStatement.buildAttributes();
- DistSQLUpdateProxyBackendHandler backendHandler = new
DistSQLUpdateProxyBackendHandler(sqlStatement, mockQueryContext(),
mockConnectionSession("foo_db"), contextManager);
+ DistSQLUpdateProxyBackendHandler backendHandler = new
DistSQLUpdateProxyBackendHandler(sqlStatement, mockQueryContext(),
mockConnectionSession(), contextManager);
assertThrows(SchemaNotFoundException.class, backendHandler::execute);
}
@@ -100,8 +96,7 @@ class DistSQLUpdateProxyBackendHandlerTest {
when(database.getResourceMetaData()).thenReturn(resourceMetaData);
when(contextManager.getDatabase("foo_db")).thenReturn(database);
RefreshTableMetaDataStatement sqlStatement = new
RefreshTableMetaDataStatement("t_order", "ds_0", "foo_db");
- sqlStatement.buildAttributes();
- DistSQLUpdateProxyBackendHandler backendHandler = new
DistSQLUpdateProxyBackendHandler(sqlStatement, mockQueryContext(),
mockConnectionSession("foo_db"), contextManager);
+ DistSQLUpdateProxyBackendHandler backendHandler = new
DistSQLUpdateProxyBackendHandler(sqlStatement, mockQueryContext(),
mockConnectionSession(), contextManager);
assertThrows(TableNotFoundException.class, backendHandler::execute);
}
@@ -115,18 +110,16 @@ class DistSQLUpdateProxyBackendHandlerTest {
when(database.getResourceMetaData()).thenReturn(resourceMetaData);
when(contextManager.getDatabase("foo_db")).thenReturn(database);
RefreshTableMetaDataStatement sqlStatement = new
RefreshTableMetaDataStatement();
- sqlStatement.buildAttributes();
- ResponseHeader actual = new
DistSQLUpdateProxyBackendHandler(sqlStatement, mockQueryContext(),
mockConnectionSession("foo_db"), contextManager).execute();
- assertThat(actual, isA(UpdateResponseHeader.class));
+ assertThat(new DistSQLUpdateProxyBackendHandler(sqlStatement,
mockQueryContext(), mockConnectionSession(), contextManager).execute(),
isA(UpdateResponseHeader.class));
}
private QueryContext mockQueryContext() {
return mock(QueryContext.class, RETURNS_DEEP_STUBS);
}
- private ConnectionSession mockConnectionSession(final String databaseName)
{
+ private ConnectionSession mockConnectionSession() {
ConnectionSession result = mock(ConnectionSession.class,
RETURNS_DEEP_STUBS);
- when(result.getUsedDatabaseName()).thenReturn(databaseName);
+ when(result.getUsedDatabaseName()).thenReturn("foo_db");
when(result.getDatabaseConnectionManager().getConnectionSize()).thenReturn(1);
return result;
}
diff --git
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/ParseDistSQLExecutorTest.java
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/ParseDistSQLExecutorTest.java
index eb52f2f1882..f938e5c702f 100644
---
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/ParseDistSQLExecutorTest.java
+++
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/ParseDistSQLExecutorTest.java
@@ -67,7 +67,6 @@ class ParseDistSQLExecutorTest {
String sql = "SELECT * FROM t_order";
when(connectionSession.getProtocolType()).thenReturn(TypedSPILoader.getService(DatabaseType.class,
"MySQL"));
ParseStatement parseStatement = new ParseStatement(sql);
- parseStatement.buildAttributes();
DistSQLQueryProxyBackendHandler handler = new
DistSQLQueryProxyBackendHandler(parseStatement, mock(), connectionSession,
contextManager);
handler.execute();
handler.next();
@@ -81,7 +80,6 @@ class ParseDistSQLExecutorTest {
String sql = "SELECT * FROM t_order";
when(connectionSession.getProtocolType()).thenReturn(TypedSPILoader.getService(DatabaseType.class,
"PostgreSQL"));
ParseStatement parseStatement = new ParseStatement(sql);
- parseStatement.buildAttributes();
DistSQLQueryProxyBackendHandler handler = new
DistSQLQueryProxyBackendHandler(parseStatement, mock(), connectionSession,
contextManager);
handler.execute();
handler.next();
@@ -94,7 +92,6 @@ class ParseDistSQLExecutorTest {
String sql = "wrong sql";
when(connectionSession.getProtocolType()).thenReturn(TypedSPILoader.getService(DatabaseType.class,
"MySQL"));
ParseStatement parseStatement = new ParseStatement(sql);
- parseStatement.buildAttributes();
DistSQLQueryProxyBackendHandler handler = new
DistSQLQueryProxyBackendHandler(parseStatement, mock(), connectionSession,
contextManager);
assertThrows(DialectSQLParsingException.class, handler::execute);
}
diff --git
a/proxy/backend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/backend/firebird/handler/admin/FirebirdAdminExecutorCreatorTest.java
b/proxy/backend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/backend/firebird/handler/admin/FirebirdAdminExecutorCreatorTest.java
index 4ecc2887751..bb9e11e8775 100644
---
a/proxy/backend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/backend/firebird/handler/admin/FirebirdAdminExecutorCreatorTest.java
+++
b/proxy/backend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/backend/firebird/handler/admin/FirebirdAdminExecutorCreatorTest.java
@@ -68,21 +68,11 @@ class FirebirdAdminExecutorCreatorTest {
private static Stream<Arguments> createArguments() {
return Stream.of(
Arguments.of("select statement returns empty",
createSelectStatementContext(), "SELECT 1", null),
- Arguments.of("set statement returns set executor",
createSetStatementContext(), "SET NAMES utf8",
FirebirdSetVariableAdminExecutor.class),
- Arguments.of("show statement returns show executor",
createShowStatementContext(), "SHOW server_version",
FirebirdShowVariableExecutor.class),
- Arguments.of("delete statement returns empty",
createOtherStatementContext(), "DELETE FROM t WHERE id = 1", null));
- }
-
- private static SQLStatementContext createSetStatementContext() {
- SetStatement sqlStatement = new SetStatement(DATABASE_TYPE,
Collections.emptyList());
- sqlStatement.buildAttributes();
- return new CommonSQLStatementContext(sqlStatement);
- }
-
- private static SQLStatementContext createShowStatementContext() {
- ShowStatement sqlStatement = new ShowStatement(DATABASE_TYPE,
"server_version");
- sqlStatement.buildAttributes();
- return new CommonSQLStatementContext(sqlStatement);
+ Arguments.of("set statement returns set executor",
+ new CommonSQLStatementContext(new
SetStatement(DATABASE_TYPE, Collections.emptyList())), "SET NAMES utf8",
FirebirdSetVariableAdminExecutor.class),
+ Arguments.of("show statement returns show executor",
+ new CommonSQLStatementContext(new
ShowStatement(DATABASE_TYPE, "server_version")), "SHOW server_version",
FirebirdShowVariableExecutor.class),
+ Arguments.of("delete statement returns empty", new
DeleteStatementContext(DeleteStatement.builder().databaseType(DATABASE_TYPE).build()),
"DELETE FROM t WHERE id = 1", null));
}
private static SQLStatementContext createSelectStatementContext() {
@@ -91,7 +81,4 @@ class FirebirdAdminExecutorCreatorTest {
return result;
}
- private static SQLStatementContext createOtherStatementContext() {
- return new
DeleteStatementContext(DeleteStatement.builder().databaseType(DATABASE_TYPE).build());
- }
}
diff --git
a/proxy/backend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLAdminExecutorCreatorTest.java
b/proxy/backend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLAdminExecutorCreatorTest.java
index 8c1644f6935..35af90d848a 100644
---
a/proxy/backend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLAdminExecutorCreatorTest.java
+++
b/proxy/backend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLAdminExecutorCreatorTest.java
@@ -97,7 +97,6 @@ class MySQLAdminExecutorCreatorTest {
@Test
void assertCreateWithMySQLShowFunctionStatus() {
MySQLShowFunctionStatusStatement sqlStatement = new
MySQLShowFunctionStatusStatement(databaseType, null);
- sqlStatement.buildAttributes();
SQLStatementContext sqlStatementContext = new
CommonSQLStatementContext(sqlStatement);
Optional<DatabaseAdminExecutor> actual = new
MySQLAdminExecutorCreator().create(sqlStatementContext, "", "",
Collections.emptyList());
assertTrue(actual.isPresent());
@@ -107,7 +106,6 @@ class MySQLAdminExecutorCreatorTest {
@Test
void assertCreateWithShowProcedureStatus() {
MySQLShowProcedureStatusStatement sqlStatement = new
MySQLShowProcedureStatusStatement(databaseType, null);
- sqlStatement.buildAttributes();
SQLStatementContext sqlStatementContext = new
CommonSQLStatementContext(sqlStatement);
Optional<DatabaseAdminExecutor> actual = new
MySQLAdminExecutorCreator().create(sqlStatementContext, "", "",
Collections.emptyList());
assertTrue(actual.isPresent());
@@ -117,7 +115,6 @@ class MySQLAdminExecutorCreatorTest {
@Test
void assertCreateWithShowTables() {
MySQLShowTablesStatement sqlStatement = new
MySQLShowTablesStatement(databaseType, null, null, false);
- sqlStatement.buildAttributes();
SQLStatementContext sqlStatementContext = new
CommonSQLStatementContext(sqlStatement);
Optional<DatabaseAdminExecutor> actual = new
MySQLAdminExecutorCreator().create(sqlStatementContext, "", "",
Collections.emptyList());
assertTrue(actual.isPresent());
@@ -127,7 +124,6 @@ class MySQLAdminExecutorCreatorTest {
@Test
void assertCreateWithUse() {
MySQLUseStatement sqlStatement = new MySQLUseStatement(databaseType,
null);
- sqlStatement.buildAttributes();
SQLStatementContext sqlStatementContext = new
CommonSQLStatementContext(sqlStatement);
Optional<DatabaseAdminExecutor> actual = new
MySQLAdminExecutorCreator().create(sqlStatementContext, "use db", "",
Collections.emptyList());
assertTrue(actual.isPresent());
@@ -137,7 +133,6 @@ class MySQLAdminExecutorCreatorTest {
@Test
void assertCreateWithShowDatabasesStatement() {
MySQLShowDatabasesStatement sqlStatement = new
MySQLShowDatabasesStatement(databaseType, null);
- sqlStatement.buildAttributes();
SQLStatementContext sqlStatementContext = new
CommonSQLStatementContext(sqlStatement);
Optional<DatabaseAdminExecutor> actual = new
MySQLAdminExecutorCreator().create(sqlStatementContext, "", "",
Collections.emptyList());
assertTrue(actual.isPresent());
@@ -147,7 +142,6 @@ class MySQLAdminExecutorCreatorTest {
@Test
void assertCreateWithMySQLShowProcessListStatement() {
MySQLShowProcessListStatement sqlStatement = new
MySQLShowProcessListStatement(databaseType, false);
- sqlStatement.buildAttributes();
SQLStatementContext sqlStatementContext = new
CommonSQLStatementContext(sqlStatement);
Optional<DatabaseAdminExecutor> actual = new
MySQLAdminExecutorCreator().create(sqlStatementContext, "", "",
Collections.emptyList());
assertTrue(actual.isPresent());
@@ -157,7 +151,6 @@ class MySQLAdminExecutorCreatorTest {
@Test
void assertCreateWithMySQLShowCreateDatabaseStatement() {
MySQLShowCreateDatabaseStatement sqlStatement = new
MySQLShowCreateDatabaseStatement(databaseType, null);
- sqlStatement.buildAttributes();
SQLStatementContext sqlStatementContext = new
CommonSQLStatementContext(sqlStatement);
Optional<DatabaseAdminExecutor> actual = new
MySQLAdminExecutorCreator().create(sqlStatementContext, "", "",
Collections.emptyList());
assertTrue(actual.isPresent());
@@ -167,7 +160,6 @@ class MySQLAdminExecutorCreatorTest {
@Test
void assertCreateWithSetStatement() {
SetStatement sqlStatement = new SetStatement(databaseType,
Collections.emptyList());
- sqlStatement.buildAttributes();
SQLStatementContext sqlStatementContext = new
CommonSQLStatementContext(sqlStatement);
Optional<DatabaseAdminExecutor> actual = new
MySQLAdminExecutorCreator().create(sqlStatementContext, "", "",
Collections.emptyList());
assertTrue(actual.isPresent());
@@ -419,7 +411,6 @@ class MySQLAdminExecutorCreatorTest {
@Test
void assertCreateWithDMLStatement() {
DeleteStatement sqlStatement =
DeleteStatement.builder().databaseType(databaseType).build();
- sqlStatement.buildAttributes();
SQLStatementContext sqlStatementContext = new
CommonSQLStatementContext(sqlStatement);
Optional<DatabaseAdminExecutor> actual = new
MySQLAdminExecutorCreator().create(sqlStatementContext, "DELETE FROM t", "",
Collections.emptyList());
assertThat(actual, is(Optional.empty()));
diff --git
a/proxy/backend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreatorTest.java
b/proxy/backend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreatorTest.java
index 022bb4abce7..7105a939294 100644
---
a/proxy/backend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreatorTest.java
+++
b/proxy/backend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreatorTest.java
@@ -119,7 +119,6 @@ class PostgreSQLAdminExecutorCreatorTest {
@Test
void assertCreateWithSetStatement() {
SetStatement sqlStatement = new SetStatement(databaseType,
Collections.emptyList());
- sqlStatement.buildAttributes();
SQLStatementContext sqlStatementContext = new
CommonSQLStatementContext(sqlStatement);
Optional<DatabaseAdminExecutor> actual = new
PostgreSQLAdminExecutorCreator().create(sqlStatementContext, "SET
client_encoding = utf8", "", Collections.emptyList());
assertTrue(actual.isPresent());
@@ -129,7 +128,6 @@ class PostgreSQLAdminExecutorCreatorTest {
@Test
void assertCreateWithResetStatement() {
PostgreSQLResetParameterStatement sqlStatement = new
PostgreSQLResetParameterStatement(databaseType, "client_encoding");
- sqlStatement.buildAttributes();
Optional<DatabaseAdminExecutor> actual = new
PostgreSQLAdminExecutorCreator().create(new
CommonSQLStatementContext(sqlStatement), "RESET client_encoding", "",
Collections.emptyList());
assertTrue(actual.isPresent());
assertThat(actual.get(),
isA(PostgreSQLResetVariableAdminExecutor.class));
@@ -138,7 +136,6 @@ class PostgreSQLAdminExecutorCreatorTest {
@Test
void assertCreateWithShowSQLStatement() {
ShowStatement sqlStatement = new ShowStatement(databaseType,
"client_encoding");
- sqlStatement.buildAttributes();
Optional<DatabaseAdminExecutor> actual = new
PostgreSQLAdminExecutorCreator().create(new
CommonSQLStatementContext(sqlStatement), "SHOW client_encoding", "",
Collections.emptyList());
assertTrue(actual.isPresent());
assertThat(actual.get(), isA(PostgreSQLShowVariableExecutor.class));
diff --git
a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandPacketFactoryTest.java
b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandPacketFactoryTest.java
index ab420e53d3c..8b06e1766e1 100644
---
a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandPacketFactoryTest.java
+++
b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandPacketFactoryTest.java
@@ -101,7 +101,6 @@ class MySQLCommandPacketFactoryTest {
ServerPreparedStatementRegistry serverPreparedStatementRegistry = new
ServerPreparedStatementRegistry();
when(connectionSession.getServerPreparedStatementRegistry()).thenReturn(serverPreparedStatementRegistry);
SelectStatement sqlStatement =
SelectStatement.builder().databaseType(databaseType).build();
- sqlStatement.buildAttributes();
SQLStatementContext sqlStatementContext = new
CommonSQLStatementContext(sqlStatement);
serverPreparedStatementRegistry.addPreparedStatement(1, new
MySQLServerPreparedStatement("SELECT 1", sqlStatementContext, new
HintValueContext(), Collections.emptyList()));
assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_STMT_EXECUTE,
payload, connectionSession), isA(MySQLComStmtExecutePacket.class));
diff --git
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PortalTest.java
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PortalTest.java
index 0d72858a5ba..f5b82b99d32 100644
---
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PortalTest.java
+++
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PortalTest.java
@@ -227,7 +227,6 @@ class PortalTest {
when(proxyBackendHandler.next()).thenReturn(false);
String sql = "set client_encoding = utf8";
SetStatement setStatement = new SetStatement(databaseType,
Collections.singletonList(new VariableAssignSegment(0, 0, new
VariableSegment(0, 0, "client_encoding"), null)));
- setStatement.buildAttributes();
PostgreSQLServerPreparedStatement preparedStatement = new
PostgreSQLServerPreparedStatement(
sql, new CommonSQLStatementContext(setStatement), new
HintValueContext(), Collections.emptyList(), Collections.emptyList());
Portal portal = new Portal("", preparedStatement,
Collections.emptyList(), Collections.emptyList(), databaseConnectionManager);
@@ -314,7 +313,6 @@ class PortalTest {
when(proxyBackendHandler.next()).thenReturn(false);
VariableAssignSegment assignSegment = new VariableAssignSegment(0, 0,
new VariableSegment(0, 0, "client_encoding"), "'utf8'");
SetStatement setStatement = new SetStatement(databaseType,
Collections.singletonList(assignSegment));
- setStatement.buildAttributes();
PostgreSQLServerPreparedStatement preparedStatement = new
PostgreSQLServerPreparedStatement(
"", new CommonSQLStatementContext(setStatement), new
HintValueContext(), Collections.emptyList(), Collections.emptyList());
Portal portal = new Portal("", preparedStatement,
Collections.emptyList(), Collections.emptyList(), databaseConnectionManager);
diff --git
a/test/it/binder/src/test/java/org/apache/shardingsphere/test/it/sql/binder/SQLBinderIT.java
b/test/it/binder/src/test/java/org/apache/shardingsphere/test/it/sql/binder/SQLBinderIT.java
index b329cf4f912..7c6516bae24 100644
---
a/test/it/binder/src/test/java/org/apache/shardingsphere/test/it/sql/binder/SQLBinderIT.java
+++
b/test/it/binder/src/test/java/org/apache/shardingsphere/test/it/sql/binder/SQLBinderIT.java
@@ -84,7 +84,6 @@ public abstract class SQLBinderIT {
private SQLStatement bindSQLStatement(final String databaseType, final
String sql, final List<Object> parameters) {
HintValueContext hintValueContext = SQLHintUtils.extractHint(sql);
SQLStatement sqlStatement = new
SQLStatementVisitorEngine(databaseType).visit(new SQLParserEngine(databaseType,
new CacheOption(128, 1024L)).parse(sql, false));
- sqlStatement.buildAttributes();
return new
SQLBindEngine(mockMetaData(TypedSPILoader.getService(DatabaseType.class,
databaseType)), "foo_db_1",
hintValueContext).bind(sqlStatement).getSqlStatement();
}