You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ji...@apache.org on 2021/10/29 04:10:36 UTC
[shardingsphere] branch master updated: `drop sharding broadcast
table rule` can specify table deletion (#13325)
This is an automated email from the ASF dual-hosted git repository.
jianglongtao 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 e064fbd `drop sharding broadcast table rule` can specify table deletion (#13325)
e064fbd is described below
commit e064fbd8515e941b142dd3c44e48f27ed7fc8f39
Author: lanchengx <52...@users.noreply.github.com>
AuthorDate: Thu Oct 28 23:09:55 2021 -0500
`drop sharding broadcast table rule` can specify table deletion (#13325)
* `drop sharding broadcast table rule` can specify table deletion
* Add a blank line.
* Add a blank line.
* Modify the grammar.
* Remove a blank line.
* Modify the grammar.
* Modify field name.
---
.../distsql/syntax/rdl/rdl-sharding-rule.cn.md | 4 ++-
.../src/main/antlr4/imports/encrypt/Keyword.g4 | 1 -
...ShardingBroadcastTableRuleStatementUpdater.java | 35 ++++++++++++++++------
...dingBroadcastTableRuleStatementUpdaterTest.java | 33 ++++++++++++++------
.../main/antlr4/imports/sharding/RDLStatement.g4 | 2 +-
.../core/ShardingDistSQLStatementVisitor.java | 17 ++++++-----
.../DropShardingBroadcastTableRulesStatement.java | 8 +++++
...ShardingBroadcastTableRulesStatementAssert.java | 11 +++++++
...ardingBroadcastTableRulesStatementTestCase.java | 11 +++++++
.../src/main/resources/case/rdl/drop.xml | 6 +++-
.../src/main/resources/sql/supported/rdl/drop.xml | 1 +
11 files changed, 100 insertions(+), 29 deletions(-)
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/usage/distsql/syntax/rdl/rdl-sharding-rule.cn.md b/docs/document/content/user-manual/shardingsphere-proxy/usage/distsql/syntax/rdl/rdl-sharding-rule.cn.md
index d607701..6ebfdf8 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/usage/distsql/syntax/rdl/rdl-sharding-rule.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/usage/distsql/syntax/rdl/rdl-sharding-rule.cn.md
@@ -77,7 +77,7 @@ CREATE SHARDING BROADCAST TABLE RULES (tableName [, tableName] ...)
ALTER SHARDING BROADCAST TABLE RULES (tableName [, tableName] ...)
-DROP SHARDING BROADCAST TABLE RULES
+DROP SHARDING BROADCAST TABLE RULES (tableName [, tableName] ...)
```
- `ALTER` 会使用新的配置直接覆盖数据库内的广播表配置
@@ -128,4 +128,6 @@ CREATE SHARDING BROADCAST TABLE RULES (t_b,t_a);
ALTER SHARDING BROADCAST TABLE RULES (t_b,t_a,t_3);
DROP SHARDING BROADCAST TABLE RULES;
+
+DROP SHARDING BROADCAST TABLE RULES t_b;
```
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-parser/src/main/antlr4/imports/encrypt/Keyword.g4 b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-parser/src/main/antlr4/imports/encrypt/Keyword.g4
index 093c65b..cdc2741 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-parser/src/main/antlr4/imports/encrypt/Keyword.g4
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-parser/src/main/antlr4/imports/encrypt/Keyword.g4
@@ -106,4 +106,3 @@ TRUE
FALSE
: F A L S E
;
-
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingBroadcastTableRuleStatementUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingBroadcastTableRuleStatementUpd [...]
index 653354b..9639202 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingBroadcastTableRuleStatementUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingBroadcastTableRuleStatementUpdater.java
@@ -17,33 +17,50 @@
package org.apache.shardingsphere.sharding.distsql.handler.update;
-import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
+import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RuleDefinitionViolationException;
+import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingBroadcastTableRulesStatement;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.stream.Collectors;
+
/**
* Drop sharding broadcast table rule statement updater.
*/
public final class DropShardingBroadcastTableRuleStatementUpdater implements RuleDefinitionDropUpdater<DropShardingBroadcastTableRulesStatement, ShardingRuleConfiguration> {
@Override
- public void checkSQLStatement(final ShardingSphereMetaData shardingSphereMetaData, final DropShardingBroadcastTableRulesStatement sqlStatement,
- final ShardingRuleConfiguration currentRuleConfig) throws RuleDefinitionViolationException {
- checkCurrentRuleConfiguration(shardingSphereMetaData.getName(), currentRuleConfig);
+ public void checkSQLStatement(final ShardingSphereMetaData shardingSphereMetaData, final DropShardingBroadcastTableRulesStatement sqlStatement,
+ final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
+ String schemaName = shardingSphereMetaData.getName();
+ checkCurrentRuleConfiguration(schemaName, currentRuleConfig);
+ checkBroadCastTableRuleExist(schemaName, sqlStatement, currentRuleConfig);
}
- private void checkCurrentRuleConfiguration(final String schemaName, final ShardingRuleConfiguration currentRuleConfig) throws RequiredRuleMissedException {
- if (null == currentRuleConfig || currentRuleConfig.getBroadcastTables().isEmpty()) {
- throw new RequiredRuleMissedException("Broadcast", schemaName);
+ private void checkBroadCastTableRuleExist(final String schemaName, final DropShardingBroadcastTableRulesStatement sqlStatement,
+ final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
+ if (!sqlStatement.getRules().isEmpty()) {
+ Collection<String> currentRules = currentRuleConfig.getBroadcastTables();
+ LinkedList<String> notExistRules = sqlStatement.getRules().stream().filter(each -> !currentRules.contains(each)).collect(Collectors.toCollection(LinkedList::new));
+ DistSQLException.predictionThrow(notExistRules.isEmpty(), new RequiredRuleMissedException("Broadcast", schemaName, notExistRules));
}
}
+ private void checkCurrentRuleConfiguration(final String schemaName, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
+ DistSQLException.predictionThrow(null != currentRuleConfig, new RequiredRuleMissedException("Broadcast", schemaName));
+ }
+
@Override
public boolean updateCurrentRuleConfiguration(final DropShardingBroadcastTableRulesStatement sqlStatement, final ShardingRuleConfiguration currentRuleConfig) {
- currentRuleConfig.getBroadcastTables().clear();
+ if (sqlStatement.getRules().isEmpty()) {
+ currentRuleConfig.getBroadcastTables().clear();
+ } else {
+ currentRuleConfig.getBroadcastTables().removeIf(sqlStatement.getRules()::contains);
+ }
return false;
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingBroadcastTableRuleStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingBroadcastTableRuleStatementUpdaterTest.java
index 4da7ffe..4b0deea 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingBroadcastTableRuleStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingBroadcastTableRuleStatementUpdaterTest.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.sharding.distsql.update;
+import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredRuleMissedException;
-import org.apache.shardingsphere.infra.distsql.exception.rule.RuleDefinitionViolationException;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
@@ -30,6 +30,8 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import java.util.Collections;
+
import static org.junit.Assert.assertTrue;
@RunWith(MockitoJUnitRunner.class)
@@ -41,24 +43,37 @@ public final class DropShardingBroadcastTableRuleStatementUpdaterTest {
private final DropShardingBroadcastTableRuleStatementUpdater updater = new DropShardingBroadcastTableRuleStatementUpdater();
@Test(expected = RequiredRuleMissedException.class)
- public void assertCheckSQLStatementWithoutCurrentRule() throws RuleDefinitionViolationException {
- updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(), null);
+ public void assertCheckSQLStatementWithoutCurrentRule() throws DistSQLException {
+ updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement("t_order"), null);
}
@Test(expected = RequiredRuleMissedException.class)
- public void assertCheckSQLStatementWithoutExistBroadcastTableRule() throws RuleDefinitionViolationException {
- updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement(), new ShardingRuleConfiguration());
+ public void assertCheckSQLStatementWithoutExistBroadcastTableRule() throws DistSQLException {
+ updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement("t_order"), new ShardingRuleConfiguration());
+ }
+
+ @Test(expected = RequiredRuleMissedException.class)
+ public void assertCheckSQLStatementWithBroadcastTableRuleAreNotTheSame() throws DistSQLException {
+ updater.checkSQLStatement(shardingSphereMetaData, createSQLStatement("t_order_item"), createCurrentRuleConfiguration());
+ }
+
+ @Test
+ public void assertDropSpecifiedCurrentRuleConfiguration() {
+ ShardingRuleConfiguration currentRuleConfig = createCurrentRuleConfiguration();
+ updater.updateCurrentRuleConfiguration(createSQLStatement("t_order"), currentRuleConfig);
+ assertTrue(currentRuleConfig.getBroadcastTables().isEmpty());
}
@Test
- public void assertUpdateCurrentRuleConfiguration() {
+ public void assertAllCurrentRuleConfiguration() {
ShardingRuleConfiguration currentRuleConfig = createCurrentRuleConfiguration();
- updater.updateCurrentRuleConfiguration(createSQLStatement(), currentRuleConfig);
+ updater.updateCurrentRuleConfiguration(createSQLStatement(null), currentRuleConfig);
assertTrue(currentRuleConfig.getBroadcastTables().isEmpty());
}
- private DropShardingBroadcastTableRulesStatement createSQLStatement() {
- return new DropShardingBroadcastTableRulesStatement();
+ private DropShardingBroadcastTableRulesStatement createSQLStatement(final String tableName) {
+ return null == tableName ? new DropShardingBroadcastTableRulesStatement(Collections.emptyList())
+ : new DropShardingBroadcastTableRulesStatement(Collections.singleton(tableName));
}
private ShardingRuleConfiguration createCurrentRuleConfiguration() {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/RDLStatement.g4 b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/RDLStatement.g4
index 8cb6a9c..a691acc 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/RDLStatement.g4
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/RDLStatement.g4
@@ -60,7 +60,7 @@ dropShardingBindingTableRules
;
dropShardingBroadcastTableRules
- : DROP SHARDING BROADCAST TABLE RULES
+ : DROP SHARDING BROADCAST TABLE RULES (tableName (COMMA tableName)*)?
;
dropShardingAlgorithm
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java
index 864b59b..560fd8c 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java
@@ -29,8 +29,8 @@ import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatement
import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.AlterShardingTableRuleContext;
import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.BindTableRulesDefinitionContext;
import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.ClearShardingHintContext;
-import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.CreateShardingAlgorithmContext;
import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.CreateDefaultShardingStrategyContext;
+import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.CreateShardingAlgorithmContext;
import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.CreateShardingBindingTableRulesContext;
import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.CreateShardingBroadcastTableRulesContext;
import org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.CreateShardingTableRuleContext;
@@ -57,11 +57,11 @@ import org.apache.shardingsphere.sharding.distsql.parser.segment.TableRuleSegmen
import org.apache.shardingsphere.sharding.distsql.parser.statement.AlterShardingBindingTableRulesStatement;
import org.apache.shardingsphere.sharding.distsql.parser.statement.AlterShardingBroadcastTableRulesStatement;
import org.apache.shardingsphere.sharding.distsql.parser.statement.AlterShardingTableRuleStatement;
+import org.apache.shardingsphere.sharding.distsql.parser.statement.CreateDefaultShardingStrategyStatement;
+import org.apache.shardingsphere.sharding.distsql.parser.statement.CreateShardingAlgorithmStatement;
import org.apache.shardingsphere.sharding.distsql.parser.statement.CreateShardingBindingTableRulesStatement;
import org.apache.shardingsphere.sharding.distsql.parser.statement.CreateShardingBroadcastTableRulesStatement;
-import org.apache.shardingsphere.sharding.distsql.parser.statement.CreateDefaultShardingStrategyStatement;
import org.apache.shardingsphere.sharding.distsql.parser.statement.CreateShardingTableRuleStatement;
-import org.apache.shardingsphere.sharding.distsql.parser.statement.CreateShardingAlgorithmStatement;
import org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingAlgorithmStatement;
import org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingBindingTableRulesStatement;
import org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingBroadcastTableRulesStatement;
@@ -82,6 +82,7 @@ import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.Tab
import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
import java.util.Collection;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.Objects;
import java.util.Properties;
@@ -148,9 +149,9 @@ public final class ShardingDistSQLStatementVisitor extends ShardingDistSQLStatem
@Override
public ASTNode visitCreateDefaultShardingStrategy(final CreateDefaultShardingStrategyContext ctx) {
ShardingStrategyContext shardingStrategyContext = ctx.shardingStrategy();
- return new CreateDefaultShardingStrategyStatement(new IdentifierValue(ctx.type.getText()).getValue().toLowerCase(),
+ return new CreateDefaultShardingStrategyStatement(new IdentifierValue(ctx.type.getText()).getValue().toLowerCase(),
getIdentifierValue(shardingStrategyContext.strategyType()).toLowerCase(),
- getIdentifierValue(shardingStrategyContext.shardingColumn().columnName()).toLowerCase(),
+ getIdentifierValue(shardingStrategyContext.shardingColumn().columnName()).toLowerCase(),
getIdentifierValue(shardingStrategyContext.shardingAlgorithm().shardingAlgorithmName()).toLowerCase());
}
@@ -181,7 +182,9 @@ public final class ShardingDistSQLStatementVisitor extends ShardingDistSQLStatem
@Override
public ASTNode visitDropShardingBroadcastTableRules(final DropShardingBroadcastTableRulesContext ctx) {
- return new DropShardingBroadcastTableRulesStatement();
+ Collection<String> tableNames = ctx.tableName() == null ? Collections.emptyList()
+ : ctx.tableName().stream().map(each -> getIdentifierValue(each)).collect(Collectors.toCollection(LinkedList::new));
+ return new DropShardingBroadcastTableRulesStatement(tableNames);
}
@Override
@@ -191,7 +194,7 @@ public final class ShardingDistSQLStatementVisitor extends ShardingDistSQLStatem
@Override
public ASTNode visitShowShardingTableRules(final ShowShardingTableRulesContext ctx) {
- return new ShowShardingTableRulesStatement(null == ctx.tableRule() ? null : getIdentifierValue(ctx.tableRule().tableName()),
+ return new ShowShardingTableRulesStatement(null == ctx.tableRule() ? null : getIdentifierValue(ctx.tableRule().tableName()),
null == ctx.schemaName() ? null : (SchemaSegment) visit(ctx.schemaName()));
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-statement/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/statement/DropShardingBroadcastTableRulesStatement.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-statement/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/statement/DropShardingBroadcastTableRulesStatement.java
index 06acf02..6d541da 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-statement/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/statement/DropShardingBroadcastTableRulesStatement.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-statement/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/statement/DropShardingBroadcastTableRulesStatement.java
@@ -17,10 +17,18 @@
package org.apache.shardingsphere.sharding.distsql.parser.statement;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.distsql.parser.statement.rdl.drop.DropRuleStatement;
+import java.util.Collection;
+
/**
* Drop sharding broadcast table rules statement.
*/
+@Getter
+@RequiredArgsConstructor
public final class DropShardingBroadcastTableRulesStatement extends DropRuleStatement {
+
+ private final Collection<String> rules;
}
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/rdl/drop/impl/DropShardingBroadcastTableRulesStatementAssert.java b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/rdl/drop/impl/DropShardingBroadcastTableRulesStatementAssert.java
index 4e536af..0797c96 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/rdl/drop/impl/DropShardingBroadcastTableRulesStatementAssert.java
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/rdl/drop/impl/DropShardingBroadcastTableRulesStatementAssert.java
@@ -23,6 +23,11 @@ import org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingB
import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rdl.drop.DropShardingBroadcastTableRulesStatementTestCase;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
+
/**
* Drop sharding broadcast table rule statement assert.
*/
@@ -37,5 +42,11 @@ public final class DropShardingBroadcastTableRulesStatementAssert {
* @param expected expected drop sharding broadcast table rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DropShardingBroadcastTableRulesStatement actual, final DropShardingBroadcastTableRulesStatementTestCase expected) {
+ if (null == expected) {
+ assertNull(assertContext.getText("Actual statement should not exist."), actual);
+ } else {
+ assertNotNull(assertContext.getText("Actual statement should exist."), actual);
+ assertThat(assertContext.getText("readwrite splitting assertion error: "), actual.getRules(), is(expected.getTableName()));
+ }
}
}
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/rdl/drop/DropShardingBroadcastTableRulesStatementTestCase.java b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/rdl/drop/DropShardingBroadcastTableRulesStatementTestCase.java
index ce69f3d..cb0aa51 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/rdl/drop/DropShardingBroadcastTableRulesStatementTestCase.java
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/rdl/drop/DropShardingBroadcastTableRulesStatementTestCase.java
@@ -17,10 +17,21 @@
package org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rdl.drop;
+import lombok.Getter;
+import lombok.Setter;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.SQLParserTestCase;
+import javax.xml.bind.annotation.XmlElement;
+import java.util.LinkedList;
+import java.util.List;
+
/**
* Drop sharding broadcast table rules statement test cast.
*/
+@Getter
+@Setter
public final class DropShardingBroadcastTableRulesStatementTestCase extends SQLParserTestCase {
+
+ @XmlElement(name = "table")
+ private final List<String> tableName = new LinkedList<>();
}
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/rdl/drop.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/rdl/drop.xml
index af16286..ba13920 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/rdl/drop.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/rdl/drop.xml
@@ -34,7 +34,11 @@
<drop-sharding-binding-table-rules sql-case-id="drop-sharding-binding-table-rules" />
<drop-sharding-broadcast-table-rules sql-case-id="drop-sharding-broadcast-table-rules" />
-
+
+ <drop-sharding-broadcast-table-rules sql-case-id="drop-sharding-broadcast-table-specified-table" >
+ <table>t_order</table>
+ </drop-sharding-broadcast-table-rules>
+
<drop-readwrite-splitting-rule sql-case-id="drop-readwrite-splitting-rule">
<rule>ms_group_0</rule>
<rule>ms_group_1</rule>
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/rdl/drop.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/rdl/drop.xml
index 9705923..66412c7 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/rdl/drop.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/rdl/drop.xml
@@ -22,6 +22,7 @@
<distsql-case id="drop-sharding-table-rule" value="DROP SHARDING TABLE RULE t_order,t_order_item" />
<distsql-case id="drop-sharding-binding-table-rules" value="DROP SHARDING BINDING TABLE RULES" />
<distsql-case id="drop-sharding-broadcast-table-rules" value="DROP SHARDING BROADCAST TABLE RULES" />
+ <distsql-case id="drop-sharding-broadcast-table-specified-table" value="DROP SHARDING BROADCAST TABLE RULES t_order" />
<distsql-case id="drop-readwrite-splitting-rule" value="DROP READWRITE_SPLITTING RULE ms_group_0,ms_group_1" />
<distsql-case id="drop-database-discovery-rule" value="DROP DB_DISCOVERY RULE ha_group_0,ha_group_1" />
<distsql-case id="drop-encrypt-rule" value="DROP ENCRYPT RULE t_encrypt,t_encrypt_order" />