This is an automated email from the ASF dual-hosted git repository.
zhaojinchao 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 9573628a88e Add `count broadcast rule` DistSQL (#26386)
9573628a88e is described below
commit 9573628a88ef2b2d72766ee41a1c7cfb5bf4fd27
Author: jiangML <[email protected]>
AuthorDate: Fri Jun 16 19:52:08 2023 +0800
Add `count broadcast rule` DistSQL (#26386)
* add count broadcast rule DistSQL
* optimize broadcast rule
* fix error
* Update broadcast table configuration order
---
.../route/engine/BroadcastRouteEngineFactory.java | 32 ++++-----
.../broadcast/rule/BroadcastRule.java | 25 ++++---
...ecutor.java => CountBroadcastRuleExecutor.java} | 27 ++++---
.../query/ShowBroadcastTableRuleExecutor.java | 7 +-
.../DropBroadcastTableRuleStatementUpdater.java | 4 +-
...hardingsphere.distsql.handler.query.RQLExecutor | 1 +
.../query/CountBroadcastRuleExecutorTest.java | 76 ++++++++++++++++++++
.../query/ShowBroadcastTableRuleExecutorTest.java | 83 ++++++++++++++++++++++
...eateBroadcastTableRuleStatementUpdaterTest.java | 62 ++++++++++++++++
...DropBroadcastTableRuleStatementUpdaterTest.java | 67 +++++++++++++++++
.../parser/autogen/BroadcastDistSQLStatement.g4 | 1 +
.../main/antlr4/imports/broadcast/RQLStatement.g4 | 4 ++
.../core/BroadcastDistSQLStatementVisitor.java | 7 ++
.../statement/CountBroadcastRuleStatement.java} | 20 +++---
.../scenario/db/proxy/conf/mysql/config-db.yaml | 2 +-
.../db/proxy/conf/opengauss/config-db.yaml | 2 +-
.../db/proxy/conf/postgresql/config-db.yaml | 2 +-
.../src/test/resources/env/scenario/db/rules.yaml | 2 +-
.../config-dbtbl-with-readwrite-splitting.yaml | 2 +-
.../config-dbtbl-with-readwrite-splitting.yaml | 2 +-
.../config-dbtbl-with-readwrite-splitting.yaml | 2 +-
.../dbtbl_with_readwrite_splitting/rules.yaml | 2 +-
...dbtbl-with-readwrite-splitting-and-encrypt.yaml | 2 +-
...dbtbl-with-readwrite-splitting-and-encrypt.yaml | 2 +-
...dbtbl-with-readwrite-splitting-and-encrypt.yaml | 2 +-
.../rules.yaml | 2 +-
.../conf/mysql/config-sharding-and-encrypt.yaml | 2 +-
.../opengauss/config-sharding-and-encrypt.yaml | 2 +-
.../postgresql/config-sharding-and-encrypt.yaml | 2 +-
.../env/scenario/sharding_and_encrypt/rules.yaml | 2 +-
30 files changed, 378 insertions(+), 70 deletions(-)
diff --git
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/route/engine/BroadcastRouteEngineFactory.java
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/route/engine/BroadcastRouteEngineFactory.java
index e51e015b3e7..0705cbe305a 100644
---
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/route/engine/BroadcastRouteEngineFactory.java
+++
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/route/engine/BroadcastRouteEngineFactory.java
@@ -77,6 +77,9 @@ public final class BroadcastRouteEngineFactory {
return new BroadcastDatabaseBroadcastRoutingEngine();
}
if (sqlStatement instanceof DDLStatement) {
+ if (sqlStatementContext instanceof CursorAvailable) {
+ return getCursorRouteEngine(broadcastRule,
sqlStatementContext, connectionContext);
+ }
return getDDLRoutingEngine(broadcastRule, database, queryContext,
connectionContext);
}
if (sqlStatement instanceof DALStatement) {
@@ -88,12 +91,22 @@ public final class BroadcastRouteEngineFactory {
return getDQLRoutingEngine(broadcastRule, queryContext,
connectionContext);
}
+ private static BroadcastRouteEngine getCursorRouteEngine(final
BroadcastRule broadcastRule, final SQLStatementContext sqlStatementContext,
final ConnectionContext connectionContext) {
+ if (sqlStatementContext instanceof CloseStatementContext &&
((CloseStatementContext) sqlStatementContext).getSqlStatement().isCloseAll()) {
+ return new BroadcastDatabaseBroadcastRoutingEngine();
+ }
+ Collection<String> tableNames = sqlStatementContext instanceof
TableAvailable
+ ? ((TableAvailable)
sqlStatementContext).getAllTables().stream().map(each ->
each.getTableName().getIdentifier().getValue()).collect(Collectors.toSet())
+ : sqlStatementContext.getTablesContext().getTableNames();
+ if (broadcastRule.isAllBroadcastTables(tableNames)) {
+ return new BroadcastUnicastRoutingEngine(sqlStatementContext,
tableNames, connectionContext);
+ }
+ return new BroadcastIgnoreRoutingEngine();
+ }
+
private static BroadcastRouteEngine getDDLRoutingEngine(final
BroadcastRule broadcastRule, final ShardingSphereDatabase database,
final QueryContext
queryContext, final ConnectionContext connectionContext) {
SQLStatementContext sqlStatementContext =
queryContext.getSqlStatementContext();
- if (sqlStatementContext instanceof CursorAvailable) {
- return getCursorRouteEngine(broadcastRule, sqlStatementContext,
connectionContext);
- }
Collection<String> tableNames = getTableNames(database,
sqlStatementContext);
if (broadcastRule.isAllBroadcastTables(tableNames)) {
return new BroadcastTableBroadcastRoutingEngine(tableNames);
@@ -121,19 +134,6 @@ public final class BroadcastRouteEngineFactory {
return result;
}
- private static BroadcastRouteEngine getCursorRouteEngine(final
BroadcastRule broadcastRule, final SQLStatementContext sqlStatementContext,
final ConnectionContext connectionContext) {
- if (sqlStatementContext instanceof CloseStatementContext &&
((CloseStatementContext) sqlStatementContext).getSqlStatement().isCloseAll()) {
- return new BroadcastIgnoreRoutingEngine();
- }
- Collection<String> tableNames = sqlStatementContext instanceof
TableAvailable
- ? ((TableAvailable)
sqlStatementContext).getAllTables().stream().map(each ->
each.getTableName().getIdentifier().getValue()).collect(Collectors.toSet())
- : sqlStatementContext.getTablesContext().getTableNames();
- if (broadcastRule.isAllBroadcastTables(tableNames)) {
- return new BroadcastUnicastRoutingEngine(sqlStatementContext,
tableNames, connectionContext);
- }
- return new BroadcastIgnoreRoutingEngine();
- }
-
private static BroadcastRouteEngine getDALRoutingEngine(final
BroadcastRule broadcastRule, final ShardingSphereDatabase database, final
QueryContext queryContext) {
SQLStatementContext sqlStatementContext =
queryContext.getSqlStatementContext();
SQLStatement sqlStatement = sqlStatementContext.getSqlStatement();
diff --git
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/rule/BroadcastRule.java
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/rule/BroadcastRule.java
index 052a760beca..ae0ced2d75b 100644
---
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/rule/BroadcastRule.java
+++
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/rule/BroadcastRule.java
@@ -29,6 +29,7 @@ import javax.sql.DataSource;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
+import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Optional;
@@ -43,11 +44,11 @@ public final class BroadcastRule implements DatabaseRule,
DataNodeContainedRule,
private final BroadcastRuleConfiguration configuration;
- private final Collection<String> tables;
-
private final String databaseName;
- private final Map<String, DataSource> dataSources;
+ private final Collection<String> tables;
+
+ private final Collection<String> dataSourceNames;
private final Map<String, Collection<DataNode>> tableDataNodes;
@@ -58,11 +59,19 @@ public final class BroadcastRule implements DatabaseRule,
DataNodeContainedRule,
public BroadcastRule(final BroadcastRuleConfiguration configuration, final
String databaseName, final Map<String, DataSource> dataSources) {
this.configuration = configuration;
this.databaseName = databaseName;
- this.dataSources = dataSources;
+ dataSourceNames = getDataSourceNames(dataSources);
tables = createBroadcastTables(configuration.getTables());
- tableDataNodes = createShardingTableDataNodes();
logicalTableMapper = createLogicalTableMapper();
actualTableMapper = createActualTableMapper();
+ tableDataNodes = createShardingTableDataNodes(dataSourceNames);
+ }
+
+ private Collection<String> getDataSourceNames(final Map<String,
DataSource> dataSources) {
+ Collection<String> result = new LinkedHashSet<>();
+ if (null != dataSources) {
+ result.addAll(dataSources.keySet());
+ }
+ return result;
}
private TableNamesMapper createLogicalTableMapper() {
@@ -83,10 +92,10 @@ public final class BroadcastRule implements DatabaseRule,
DataNodeContainedRule,
return result;
}
- private Map<String, Collection<DataNode>> createShardingTableDataNodes() {
+ private Map<String, Collection<DataNode>>
createShardingTableDataNodes(final Collection<String> dataSourceNames) {
Map<String, Collection<DataNode>> result = new
HashMap<>(tables.size(), 1F);
for (String each : tables) {
- result.put(each.toLowerCase(), generateDataNodes(each,
dataSources.keySet()));
+ result.put(each.toLowerCase(), generateDataNodes(each,
dataSourceNames));
}
return result;
}
@@ -165,7 +174,7 @@ public final class BroadcastRule implements DatabaseRule,
DataNodeContainedRule,
* @return datasource names
*/
public Collection<String> getAvailableDataSourceNames() {
- return dataSources.keySet();
+ return dataSourceNames;
}
@Override
diff --git
a/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/query/ShowBroadcastTableRuleExecutor.java
b/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/query/CountBroadcastRuleExecutor.java
similarity index 74%
copy from
features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/query/ShowBroadcastTableRuleExecutor.java
copy to
features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/query/CountBroadcastRuleExecutor.java
index 0f1371f73ff..13f19f0256a 100644
---
a/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/query/ShowBroadcastTableRuleExecutor.java
+++
b/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/query/CountBroadcastRuleExecutor.java
@@ -17,40 +17,37 @@
package org.apache.shardingsphere.broadcast.distsql.handler.query;
-import
org.apache.shardingsphere.broadcast.distsql.parser.statement.ShowBroadcastTableRulesStatement;
+import
org.apache.shardingsphere.broadcast.distsql.parser.statement.CountBroadcastRuleStatement;
import org.apache.shardingsphere.broadcast.rule.BroadcastRule;
import org.apache.shardingsphere.distsql.handler.query.RQLExecutor;
import
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.LinkedList;
import java.util.Optional;
/**
- * Show broadcast table rule executor.
+ * Count broadcast rule executor.
*/
-public final class ShowBroadcastTableRuleExecutor implements
RQLExecutor<ShowBroadcastTableRulesStatement> {
+public final class CountBroadcastRuleExecutor implements
RQLExecutor<CountBroadcastRuleStatement> {
@Override
- public Collection<LocalDataQueryResultRow> getRows(final
ShardingSphereDatabase database, final ShowBroadcastTableRulesStatement
sqlStatement) {
- Optional<BroadcastRule> rule =
database.getRuleMetaData().findSingleRule(BroadcastRule.class);
- if (!rule.isPresent()) {
- return Collections.emptyList();
- }
- Collection<LocalDataQueryResultRow> result = new LinkedList<>();
- rule.get().getTables().forEach(each -> result.add(new
LocalDataQueryResultRow(each)));
- return result;
+ public Collection<String> getColumnNames() {
+ return Arrays.asList("rule_name", "database", "count");
}
@Override
- public Collection<String> getColumnNames() {
- return Collections.singleton("broadcast_table");
+ public Collection<LocalDataQueryResultRow> getRows(final
ShardingSphereDatabase database, final CountBroadcastRuleStatement
sqlStatement) {
+ Optional<BroadcastRule> rule =
database.getRuleMetaData().findSingleRule(BroadcastRule.class);
+ Collection<LocalDataQueryResultRow> result = new LinkedList<>();
+ rule.ifPresent(optional -> result.add(new
LocalDataQueryResultRow("broadcast_table", database.getName(),
optional.getConfiguration().getTables().size())));
+ return result;
}
@Override
public String getType() {
- return ShowBroadcastTableRulesStatement.class.getName();
+ return CountBroadcastRuleStatement.class.getName();
}
}
diff --git
a/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/query/ShowBroadcastTableRuleExecutor.java
b/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/query/ShowBroadcastTableRuleExecutor.java
index 0f1371f73ff..7a030f78588 100644
---
a/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/query/ShowBroadcastTableRuleExecutor.java
+++
b/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/query/ShowBroadcastTableRuleExecutor.java
@@ -35,12 +35,9 @@ public final class ShowBroadcastTableRuleExecutor implements
RQLExecutor<ShowBro
@Override
public Collection<LocalDataQueryResultRow> getRows(final
ShardingSphereDatabase database, final ShowBroadcastTableRulesStatement
sqlStatement) {
- Optional<BroadcastRule> rule =
database.getRuleMetaData().findSingleRule(BroadcastRule.class);
- if (!rule.isPresent()) {
- return Collections.emptyList();
- }
Collection<LocalDataQueryResultRow> result = new LinkedList<>();
- rule.get().getTables().forEach(each -> result.add(new
LocalDataQueryResultRow(each)));
+ Optional<BroadcastRule> rule =
database.getRuleMetaData().findSingleRule(BroadcastRule.class);
+ rule.ifPresent(optional ->
optional.getConfiguration().getTables().forEach(each -> result.add(new
LocalDataQueryResultRow(each))));
return result;
}
diff --git
a/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleStatementUpdater.java
b/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleStatementUpdater.java
index 8a5f41c8f38..0fc0070fecd 100644
---
a/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleStatementUpdater.java
+++
b/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleStatementUpdater.java
@@ -33,8 +33,8 @@ import java.util.stream.Collectors;
public final class DropBroadcastTableRuleStatementUpdater implements
RuleDefinitionDropUpdater<DropBroadcastTableRuleStatement,
BroadcastRuleConfiguration> {
@Override
- public void checkSQLStatement(final ShardingSphereDatabase database,
- final DropBroadcastTableRuleStatement
sqlStatement, final BroadcastRuleConfiguration currentRuleConfig) {
+ public void checkSQLStatement(final ShardingSphereDatabase database, final
DropBroadcastTableRuleStatement sqlStatement,
+ final BroadcastRuleConfiguration
currentRuleConfig) {
if (!isExistRuleConfig(currentRuleConfig) &&
sqlStatement.isIfExists()) {
return;
}
diff --git
a/features/broadcast/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.query.RQLExecutor
b/features/broadcast/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.query.RQLExecutor
index 397e9b8fb0e..2b9dc501453 100644
---
a/features/broadcast/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.query.RQLExecutor
+++
b/features/broadcast/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.query.RQLExecutor
@@ -16,3 +16,4 @@
#
org.apache.shardingsphere.broadcast.distsql.handler.query.ShowBroadcastTableRuleExecutor
+org.apache.shardingsphere.broadcast.distsql.handler.query.CountBroadcastRuleExecutor
diff --git
a/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/query/CountBroadcastRuleExecutorTest.java
b/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/query/CountBroadcastRuleExecutorTest.java
new file mode 100644
index 00000000000..727824e54aa
--- /dev/null
+++
b/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/query/CountBroadcastRuleExecutorTest.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.broadcast.distsql.handler.query;
+
+import
org.apache.shardingsphere.broadcast.api.config.BroadcastRuleConfiguration;
+import
org.apache.shardingsphere.broadcast.distsql.parser.statement.CountBroadcastRuleStatement;
+import org.apache.shardingsphere.broadcast.rule.BroadcastRule;
+import
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
+import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import
org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.junit.jupiter.api.Test;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+class CountBroadcastRuleExecutorTest {
+
+ @Test
+ void assertGetRowData() {
+ Collection<LocalDataQueryResultRow> actual = new
CountBroadcastRuleExecutor().getRows(mockDatabase(),
mock(CountBroadcastRuleStatement.class));
+ assertThat(actual.size(), is(1));
+ Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
+ LocalDataQueryResultRow row = iterator.next();
+ assertThat(row.getCell(1), is("broadcast_table"));
+ assertThat(row.getCell(2), is("sharding_db"));
+ assertThat(row.getCell(3), is(1));
+ }
+
+ @Test
+ void assertGetColumnNames() {
+ Collection<String> columns = new
CountBroadcastRuleExecutor().getColumnNames();
+ assertThat(columns.size(), is(3));
+ Iterator<String> iterator = columns.iterator();
+ assertThat(iterator.next(), is("rule_name"));
+ assertThat(iterator.next(), is("database"));
+ assertThat(iterator.next(), is("count"));
+ }
+
+ private ShardingSphereDatabase mockDatabase() {
+ ShardingSphereDatabase result = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
+ when(result.getName()).thenReturn("sharding_db");
+ ShardingSphereRuleMetaData ruleMetaData = new
ShardingSphereRuleMetaData(Collections.singleton(mockBroadcastRule()));
+ when(result.getRuleMetaData()).thenReturn(ruleMetaData);
+ return result;
+ }
+
+ private BroadcastRule mockBroadcastRule() {
+ BroadcastRule result = mock(BroadcastRule.class);
+ BroadcastRuleConfiguration configuration =
mock(BroadcastRuleConfiguration.class);
+
when(configuration.getTables()).thenReturn(Collections.singleton("t_address"));
+ when(result.getConfiguration()).thenReturn(configuration);
+ return result;
+ }
+}
diff --git
a/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/query/ShowBroadcastTableRuleExecutorTest.java
b/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/query/ShowBroadcastTableRuleExecutorTest.java
new file mode 100644
index 00000000000..d230037d9ac
--- /dev/null
+++
b/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/query/ShowBroadcastTableRuleExecutorTest.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.broadcast.distsql.handler.query;
+
+import
org.apache.shardingsphere.broadcast.api.config.BroadcastRuleConfiguration;
+import
org.apache.shardingsphere.broadcast.distsql.parser.statement.ShowBroadcastTableRulesStatement;
+import org.apache.shardingsphere.broadcast.rule.BroadcastRule;
+import org.apache.shardingsphere.distsql.handler.query.RQLExecutor;
+import
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
+import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import
org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.junit.jupiter.api.Test;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+class ShowBroadcastTableRuleExecutorTest {
+
+ @Test
+ void assertGetRowData() {
+ ShardingSphereDatabase database = mockDatabase();
+ RQLExecutor<ShowBroadcastTableRulesStatement> executor = new
ShowBroadcastTableRuleExecutor();
+ Collection<LocalDataQueryResultRow> actual =
executor.getRows(database, mock(ShowBroadcastTableRulesStatement.class));
+ assertThat(actual.size(), is(1));
+ Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
+ LocalDataQueryResultRow row = iterator.next();
+ assertThat(row.getCell(1), is("t_address"));
+ }
+
+ @Test
+ void assertGetRowDataWithoutMaskRule() {
+ ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
+ Collection<LocalDataQueryResultRow> actual = new
ShowBroadcastTableRuleExecutor().getRows(database,
mock(ShowBroadcastTableRulesStatement.class));
+ assertTrue(actual.isEmpty());
+ }
+
+ @Test
+ void assertGetColumnNames() {
+ RQLExecutor<ShowBroadcastTableRulesStatement> executor = new
ShowBroadcastTableRuleExecutor();
+ Collection<String> columns = executor.getColumnNames();
+ assertThat(columns.size(), is(1));
+ Iterator<String> iterator = columns.iterator();
+ assertThat(iterator.next(), is("broadcast_table"));
+ }
+
+ private ShardingSphereDatabase mockDatabase() {
+ ShardingSphereDatabase result = mock(ShardingSphereDatabase.class);
+ ShardingSphereRuleMetaData ruleMetaData = new
ShardingSphereRuleMetaData(Collections.singleton(mockBroadcastRule()));
+ when(result.getRuleMetaData()).thenReturn(ruleMetaData);
+ return result;
+ }
+
+ private BroadcastRule mockBroadcastRule() {
+ BroadcastRule result = mock(BroadcastRule.class);
+ BroadcastRuleConfiguration configuration =
mock(BroadcastRuleConfiguration.class);
+
when(configuration.getTables()).thenReturn(Collections.singleton("t_address"));
+ when(result.getConfiguration()).thenReturn(configuration);
+ return result;
+ }
+}
diff --git
a/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/CreateBroadcastTableRuleStatementUpdaterTest.java
b/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/CreateBroadcastTableRuleStatementUpdaterTest.java
new file mode 100644
index 00000000000..7b0b18e9cde
--- /dev/null
+++
b/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/CreateBroadcastTableRuleStatementUpdaterTest.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.broadcast.distsql.handler.update;
+
+import
org.apache.shardingsphere.broadcast.api.config.BroadcastRuleConfiguration;
+import
org.apache.shardingsphere.broadcast.distsql.parser.statement.CreateBroadcastTableRuleStatement;
+import
org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException;
+import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.junit.jupiter.api.Test;
+import org.mockito.Answers;
+import org.mockito.Mock;
+
+import java.util.Collections;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+class CreateBroadcastTableRuleStatementUpdaterTest {
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private ShardingSphereDatabase database;
+
+ private final CreateBroadcastTableRuleStatementUpdater updater = new
CreateBroadcastTableRuleStatementUpdater();
+
+ @Test
+ void assertCheckSQLStatementWithDuplicateBroadcastRule() {
+ BroadcastRuleConfiguration currentConfiguration =
mock(BroadcastRuleConfiguration.class);
+
when(currentConfiguration.getTables()).thenReturn(Collections.singleton("t_address"));
+ CreateBroadcastTableRuleStatement statement = new
CreateBroadcastTableRuleStatement(false, Collections.singleton("t_address"));
+ assertThrows(DuplicateRuleException.class, () ->
updater.checkSQLStatement(database, statement, currentConfiguration));
+ }
+
+ @Test
+ void assertBuildToBeCreatedRuleConfiguration() {
+ BroadcastRuleConfiguration currentConfig = new
BroadcastRuleConfiguration();
+ CreateBroadcastTableRuleStatement statement = new
CreateBroadcastTableRuleStatement(false, Collections.singleton("t_address"));
+ updater.checkSQLStatement(database, statement, currentConfig);
+ BroadcastRuleConfiguration toBeCreatedRuleConfig =
updater.buildToBeCreatedRuleConfiguration(currentConfig, statement);
+ updater.updateCurrentRuleConfiguration(currentConfig,
toBeCreatedRuleConfig);
+ assertThat(currentConfig.getTables().size(), is(1));
+ assertThat(currentConfig.getTables().iterator().next(),
is("t_address"));
+ updater.updateCurrentRuleConfiguration(currentConfig,
toBeCreatedRuleConfig);
+ }
+}
diff --git
a/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleStatementUpdaterTest.java
b/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleStatementUpdaterTest.java
new file mode 100644
index 00000000000..b6954c03826
--- /dev/null
+++
b/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleStatementUpdaterTest.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.broadcast.distsql.handler.update;
+
+import
org.apache.shardingsphere.broadcast.api.config.BroadcastRuleConfiguration;
+import
org.apache.shardingsphere.broadcast.distsql.parser.statement.DropBroadcastTableRuleStatement;
+import
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
+import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.Collections;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+class DropBroadcastTableRuleStatementUpdaterTest {
+
+ private ShardingSphereDatabase database;
+
+ private final DropBroadcastTableRuleStatementUpdater updater = new
DropBroadcastTableRuleStatementUpdater();
+
+ @BeforeEach
+ void setUp() {
+ database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
+ when(database.getName()).thenReturn("sharding_db");
+ }
+
+ @Test
+ void assertCheckSQLStatementWithoutCurrentRule() {
+ DropBroadcastTableRuleStatement statement = new
DropBroadcastTableRuleStatement(false, Collections.singleton("t_address"));
+ assertThrows(MissingRequiredRuleException.class, () ->
updater.checkSQLStatement(database, statement, null));
+ }
+
+ @Test
+ void assertCheckSQLStatementWithoutToBeDroppedRule() {
+ DropBroadcastTableRuleStatement statement = new
DropBroadcastTableRuleStatement(false, Collections.singleton("t_address"));
+ assertThrows(MissingRequiredRuleException.class, () ->
updater.checkSQLStatement(database, statement, new
BroadcastRuleConfiguration()));
+ }
+
+ @Test
+ void assertUpdateCurrentRuleConfiguration() {
+ BroadcastRuleConfiguration configuration = new
BroadcastRuleConfiguration();
+ configuration.getTables().add("t_address");
+ DropBroadcastTableRuleStatement statement = new
DropBroadcastTableRuleStatement(false, Collections.singleton("t_address"));
+ assertTrue(updater.updateCurrentRuleConfiguration(statement,
configuration));
+ assertTrue(configuration.getTables().isEmpty());
+ }
+}
diff --git
a/features/broadcast/distsql/parser/src/main/antlr4/broadcast/org/apache/shardingsphere/distsql/parser/autogen/BroadcastDistSQLStatement.g4
b/features/broadcast/distsql/parser/src/main/antlr4/broadcast/org/apache/shardingsphere/distsql/parser/autogen/BroadcastDistSQLStatement.g4
index 09fa5770b42..6ac6a39021d 100644
---
a/features/broadcast/distsql/parser/src/main/antlr4/broadcast/org/apache/shardingsphere/distsql/parser/autogen/BroadcastDistSQLStatement.g4
+++
b/features/broadcast/distsql/parser/src/main/antlr4/broadcast/org/apache/shardingsphere/distsql/parser/autogen/BroadcastDistSQLStatement.g4
@@ -23,5 +23,6 @@ execute
: (createBroadcastTableRule
| dropBroadcastTableRule
| showBroadcastTableRules
+ | countBroadcastRule
) SEMI_? EOF
;
diff --git
a/features/broadcast/distsql/parser/src/main/antlr4/imports/broadcast/RQLStatement.g4
b/features/broadcast/distsql/parser/src/main/antlr4/imports/broadcast/RQLStatement.g4
index 32bfd731ba4..8be020768d9 100644
---
a/features/broadcast/distsql/parser/src/main/antlr4/imports/broadcast/RQLStatement.g4
+++
b/features/broadcast/distsql/parser/src/main/antlr4/imports/broadcast/RQLStatement.g4
@@ -22,3 +22,7 @@ import BaseRule;
showBroadcastTableRules
: SHOW BROADCAST TABLE RULES (FROM databaseName)?
;
+
+countBroadcastRule
+ : COUNT BROADCAST RULE (FROM databaseName)?
+ ;
diff --git
a/features/broadcast/distsql/parser/src/main/java/org/apache/shardingsphere/broadcast/distsql/parser/core/BroadcastDistSQLStatementVisitor.java
b/features/broadcast/distsql/parser/src/main/java/org/apache/shardingsphere/broadcast/distsql/parser/core/BroadcastDistSQLStatementVisitor.java
index e1b1ca4ce7f..73c553c251d 100644
---
a/features/broadcast/distsql/parser/src/main/java/org/apache/shardingsphere/broadcast/distsql/parser/core/BroadcastDistSQLStatementVisitor.java
+++
b/features/broadcast/distsql/parser/src/main/java/org/apache/shardingsphere/broadcast/distsql/parser/core/BroadcastDistSQLStatementVisitor.java
@@ -18,10 +18,12 @@
package org.apache.shardingsphere.broadcast.distsql.parser.core;
import org.antlr.v4.runtime.tree.ParseTree;
+import
org.apache.shardingsphere.broadcast.distsql.parser.statement.CountBroadcastRuleStatement;
import
org.apache.shardingsphere.broadcast.distsql.parser.statement.CreateBroadcastTableRuleStatement;
import
org.apache.shardingsphere.broadcast.distsql.parser.statement.DropBroadcastTableRuleStatement;
import
org.apache.shardingsphere.broadcast.distsql.parser.statement.ShowBroadcastTableRulesStatement;
import
org.apache.shardingsphere.distsql.parser.autogen.BroadcastDistSQLStatementBaseVisitor;
+import
org.apache.shardingsphere.distsql.parser.autogen.BroadcastDistSQLStatementParser.CountBroadcastRuleContext;
import
org.apache.shardingsphere.distsql.parser.autogen.BroadcastDistSQLStatementParser.CreateBroadcastTableRuleContext;
import
org.apache.shardingsphere.distsql.parser.autogen.BroadcastDistSQLStatementParser.DatabaseNameContext;
import
org.apache.shardingsphere.distsql.parser.autogen.BroadcastDistSQLStatementParser.DropBroadcastTableRuleContext;
@@ -55,6 +57,11 @@ public final class BroadcastDistSQLStatementVisitor extends
BroadcastDistSQLStat
return new ShowBroadcastTableRulesStatement(null == ctx.databaseName()
? null : (DatabaseSegment) visit(ctx.databaseName()));
}
+ @Override
+ public ASTNode visitCountBroadcastRule(final CountBroadcastRuleContext
ctx) {
+ return new CountBroadcastRuleStatement(null == ctx.databaseName() ?
null : (DatabaseSegment) visit(ctx.databaseName()));
+ }
+
@Override
public ASTNode visitDatabaseName(final DatabaseNameContext ctx) {
return new DatabaseSegment(ctx.getStart().getStartIndex(),
ctx.getStop().getStopIndex(), new IdentifierValue(ctx.getText()));
diff --git
a/features/broadcast/distsql/parser/src/main/antlr4/broadcast/org/apache/shardingsphere/distsql/parser/autogen/BroadcastDistSQLStatement.g4
b/features/broadcast/distsql/statement/src/main/java/org/apache/shardingsphere/broadcast/distsql/parser/statement/CountBroadcastRuleStatement.java
similarity index 62%
copy from
features/broadcast/distsql/parser/src/main/antlr4/broadcast/org/apache/shardingsphere/distsql/parser/autogen/BroadcastDistSQLStatement.g4
copy to
features/broadcast/distsql/statement/src/main/java/org/apache/shardingsphere/broadcast/distsql/parser/statement/CountBroadcastRuleStatement.java
index 09fa5770b42..80f3b4f1fbd 100644
---
a/features/broadcast/distsql/parser/src/main/antlr4/broadcast/org/apache/shardingsphere/distsql/parser/autogen/BroadcastDistSQLStatement.g4
+++
b/features/broadcast/distsql/statement/src/main/java/org/apache/shardingsphere/broadcast/distsql/parser/statement/CountBroadcastRuleStatement.java
@@ -15,13 +15,17 @@
* limitations under the License.
*/
-grammar BroadcastDistSQLStatement;
+package org.apache.shardingsphere.broadcast.distsql.parser.statement;
-import Symbol, RDLStatement, RQLStatement;
+import
org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowRulesStatement;
+import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.DatabaseSegment;
-execute
- : (createBroadcastTableRule
- | dropBroadcastTableRule
- | showBroadcastTableRules
- ) SEMI_? EOF
- ;
+/**
+ * Count broadcast rule statement.
+ */
+public final class CountBroadcastRuleStatement extends ShowRulesStatement {
+
+ public CountBroadcastRuleStatement(final DatabaseSegment database) {
+ super(database);
+ }
+}
diff --git
a/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/mysql/config-db.yaml
b/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/mysql/config-db.yaml
index 8eb34c046a6..e81903ebad5 100644
---
a/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/mysql/config-db.yaml
+++
b/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/mysql/config-db.yaml
@@ -178,5 +178,5 @@ rules:
tables:
- t_broadcast_table
- t_broadcast_table_for_ddl
- - t_product_category
- t_country
+ - t_product_category
diff --git
a/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/opengauss/config-db.yaml
b/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/opengauss/config-db.yaml
index 576adde6d58..de6b5f6c6a4 100644
---
a/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/opengauss/config-db.yaml
+++
b/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/opengauss/config-db.yaml
@@ -178,5 +178,5 @@ rules:
tables:
- t_broadcast_table
- t_broadcast_table_for_ddl
- - t_product_category
- t_country
+ - t_product_category
diff --git
a/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/postgresql/config-db.yaml
b/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/postgresql/config-db.yaml
index ceeb58ae366..d92ce7506d3 100644
---
a/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/postgresql/config-db.yaml
+++
b/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/postgresql/config-db.yaml
@@ -178,5 +178,5 @@ rules:
tables:
- t_broadcast_table
- t_broadcast_table_for_ddl
- - t_product_category
- t_country
+ - t_product_category
diff --git a/test/e2e/sql/src/test/resources/env/scenario/db/rules.yaml
b/test/e2e/sql/src/test/resources/env/scenario/db/rules.yaml
index be35ad69c2f..53f60974681 100644
--- a/test/e2e/sql/src/test/resources/env/scenario/db/rules.yaml
+++ b/test/e2e/sql/src/test/resources/env/scenario/db/rules.yaml
@@ -86,8 +86,8 @@ rules:
tables:
- t_broadcast_table
- t_broadcast_table_for_ddl
- - t_product_category
- t_country
+ - t_product_category
sqlFederation:
sqlFederationEnabled: true
diff --git
a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting/proxy/conf/mysql/config-dbtbl-with-readwrite-splitting.yaml
b/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting/proxy/conf/mysql/config-dbtbl-with-readwrite-splitting.yaml
index 71495074c50..c02807cd129 100644
---
a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting/proxy/conf/mysql/config-dbtbl-with-readwrite-splitting.yaml
+++
b/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting/proxy/conf/mysql/config-dbtbl-with-readwrite-splitting.yaml
@@ -280,8 +280,8 @@ rules:
tables:
- t_broadcast_table
- t_broadcast_table_for_ddl
- - t_product_category
- t_country
+ - t_product_category
- !READWRITE_SPLITTING
dataSources:
diff --git
a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting/proxy/conf/opengauss/config-dbtbl-with-readwrite-splitting.yaml
b/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting/proxy/conf/opengauss/config-dbtbl-with-readwrite-splitting.yaml
index 89c66916226..d40fef00d12 100644
---
a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting/proxy/conf/opengauss/config-dbtbl-with-readwrite-splitting.yaml
+++
b/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting/proxy/conf/opengauss/config-dbtbl-with-readwrite-splitting.yaml
@@ -280,8 +280,8 @@ rules:
tables:
- t_broadcast_table
- t_broadcast_table_for_ddl
- - t_product_category
- t_country
+ - t_product_category
- !READWRITE_SPLITTING
dataSources:
diff --git
a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting/proxy/conf/postgresql/config-dbtbl-with-readwrite-splitting.yaml
b/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting/proxy/conf/postgresql/config-dbtbl-with-readwrite-splitting.yaml
index 884248388ee..0824cf5f7ec 100644
---
a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting/proxy/conf/postgresql/config-dbtbl-with-readwrite-splitting.yaml
+++
b/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting/proxy/conf/postgresql/config-dbtbl-with-readwrite-splitting.yaml
@@ -280,8 +280,8 @@ rules:
tables:
- t_broadcast_table
- t_broadcast_table_for_ddl
- - t_product_category
- t_country
+ - t_product_category
- !READWRITE_SPLITTING
dataSources:
diff --git
a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting/rules.yaml
b/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting/rules.yaml
index 230f2c99088..965d5f321c9 100644
---
a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting/rules.yaml
+++
b/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting/rules.yaml
@@ -97,8 +97,8 @@ rules:
tables:
- t_broadcast_table
- t_broadcast_table_for_ddl
- - t_product_category
- t_country
+ - t_product_category
- !READWRITE_SPLITTING
dataSources:
diff --git
a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting_and_encrypt/proxy/conf/mysql/config-dbtbl-with-readwrite-splitting-and-encrypt.yaml
b/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting_and_encrypt/proxy/conf/mysql/config-dbtbl-with-readwrite-splitting-and-encrypt.yaml
index 7949ee8494e..4fed209f0bc 100644
---
a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting_and_encrypt/proxy/conf/mysql/config-dbtbl-with-readwrite-splitting-and-encrypt.yaml
+++
b/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting_and_encrypt/proxy/conf/mysql/config-dbtbl-with-readwrite-splitting-and-encrypt.yaml
@@ -325,8 +325,8 @@ rules:
- !BROADCAST
tables:
- - t_product_category
- t_country
+ - t_product_category
- !READWRITE_SPLITTING
dataSources:
diff --git
a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting_and_encrypt/proxy/conf/opengauss/config-dbtbl-with-readwrite-splitting-and-encrypt.yaml
b/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting_and_encrypt/proxy/conf/opengauss/config-dbtbl-with-readwrite-splitting-and-encrypt.yaml
index 08fc3e1d310..2ccdfaf7dc4 100644
---
a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting_and_encrypt/proxy/conf/opengauss/config-dbtbl-with-readwrite-splitting-and-encrypt.yaml
+++
b/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting_and_encrypt/proxy/conf/opengauss/config-dbtbl-with-readwrite-splitting-and-encrypt.yaml
@@ -324,8 +324,8 @@ rules:
- !BROADCAST
tables:
- - t_product_category
- t_country
+ - t_product_category
- !READWRITE_SPLITTING
dataSources:
diff --git
a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting_and_encrypt/proxy/conf/postgresql/config-dbtbl-with-readwrite-splitting-and-encrypt.yaml
b/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting_and_encrypt/proxy/conf/postgresql/config-dbtbl-with-readwrite-splitting-and-encrypt.yaml
index 918a1c56945..f74a68d8814 100644
---
a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting_and_encrypt/proxy/conf/postgresql/config-dbtbl-with-readwrite-splitting-and-encrypt.yaml
+++
b/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting_and_encrypt/proxy/conf/postgresql/config-dbtbl-with-readwrite-splitting-and-encrypt.yaml
@@ -324,8 +324,8 @@ rules:
- !BROADCAST
tables:
- - t_product_category
- t_country
+ - t_product_category
- !READWRITE_SPLITTING
dataSources:
diff --git
a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting_and_encrypt/rules.yaml
b/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting_and_encrypt/rules.yaml
index 2c98920c8a4..3a5a5eeb90d 100644
---
a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting_and_encrypt/rules.yaml
+++
b/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting_and_encrypt/rules.yaml
@@ -192,8 +192,8 @@ rules:
- !BROADCAST
tables:
- - t_product_category
- t_country
+ - t_product_category
- !ENCRYPT
encryptors:
diff --git
a/test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/proxy/conf/mysql/config-sharding-and-encrypt.yaml
b/test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/proxy/conf/mysql/config-sharding-and-encrypt.yaml
index dae6bd938c0..25d880b4596 100644
---
a/test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/proxy/conf/mysql/config-sharding-and-encrypt.yaml
+++
b/test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/proxy/conf/mysql/config-sharding-and-encrypt.yaml
@@ -235,8 +235,8 @@ rules:
- !BROADCAST
tables:
- - t_product_category
- t_country
+ - t_product_category
- !ENCRYPT
encryptors:
diff --git
a/test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/proxy/conf/opengauss/config-sharding-and-encrypt.yaml
b/test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/proxy/conf/opengauss/config-sharding-and-encrypt.yaml
index fbcfd12a33b..6df8547ca80 100644
---
a/test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/proxy/conf/opengauss/config-sharding-and-encrypt.yaml
+++
b/test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/proxy/conf/opengauss/config-sharding-and-encrypt.yaml
@@ -235,8 +235,8 @@ rules:
- !BROADCAST
tables:
- - t_product_category
- t_country
+ - t_product_category
- !ENCRYPT
encryptors:
diff --git
a/test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/proxy/conf/postgresql/config-sharding-and-encrypt.yaml
b/test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/proxy/conf/postgresql/config-sharding-and-encrypt.yaml
index 1037defe94c..9f883963a56 100644
---
a/test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/proxy/conf/postgresql/config-sharding-and-encrypt.yaml
+++
b/test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/proxy/conf/postgresql/config-sharding-and-encrypt.yaml
@@ -235,8 +235,8 @@ rules:
- !BROADCAST
tables:
- - t_product_category
- t_country
+ - t_product_category
- !ENCRYPT
encryptors:
diff --git
a/test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/rules.yaml
b/test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/rules.yaml
index da87613d784..33e321cec7f 100644
---
a/test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/rules.yaml
+++
b/test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/rules.yaml
@@ -141,8 +141,8 @@ rules:
- !BROADCAST
tables:
- - t_product_category
- t_country
+ - t_product_category
- !ENCRYPT
encryptors: