This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 edb90c17255 support DistSQL drop sharding auditor (#20795)
edb90c17255 is described below
commit edb90c172556fd504cfed7dcd233ef6068f3dc08
Author: natehuang <[email protected]>
AuthorDate: Wed Sep 7 11:16:01 2022 +0800
support DistSQL drop sharding auditor (#20795)
---
.../DropShardingAuditorStatementUpdater.java | 98 ++++++++++++++++++++++
...here.infra.distsql.update.RuleDefinitionUpdater | 1 +
.../DropShardingAuditorStatementUpdaterTest.java | 93 ++++++++++++++++++++
.../main/antlr4/imports/sharding/RDLStatement.g4 | 4 +
.../parser/autogen/ShardingDistSQLStatement.g4 | 1 +
.../core/ShardingDistSQLStatementVisitor.java | 7 ++
.../statement/DropShardingAuditorStatement.java | 37 ++++++++
.../exception/rule/AuditorInUsedException.java | 32 +++++++
.../rule/RequiredAuditorMissedException.java | 29 +++++++
.../distsql/rdl/drop/DropRuleStatementAssert.java | 5 ++
.../impl/DropShardingAuditorStatementAssert.java | 51 +++++++++++
.../jaxb/cases/domain/SQLParserTestCases.java | 4 +
.../drop/DropShardingAuditorStatementTestCase.java | 35 ++++++++
.../src/main/resources/case/rdl/drop.xml | 10 ++-
.../src/main/resources/sql/supported/rdl/drop.xml | 2 +
15 files changed, 408 insertions(+), 1 deletion(-)
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAuditorStatementUpdater.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAuditorStatementUpdater.java
new file mode 100644
index 00000000000..ba0fc2e52f1
--- /dev/null
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAuditorStatementUpdater.java
@@ -0,0 +1,98 @@
+/*
+ * 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.sharding.distsql.handler.update;
+
+import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
+import
org.apache.shardingsphere.infra.distsql.exception.rule.AuditorInUsedException;
+import
org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAuditorMissedException;
+import
org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
+import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import
org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAuditStrategyConfiguration;
+import
org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingAuditorStatement;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+/**
+ * Drop sharding auditor statement updater.
+ */
+public final class DropShardingAuditorStatementUpdater implements
RuleDefinitionDropUpdater<DropShardingAuditorStatement,
ShardingRuleConfiguration> {
+
+ @Override
+ public void checkSQLStatement(final ShardingSphereDatabase database,
+ final DropShardingAuditorStatement
sqlStatement, final ShardingRuleConfiguration currentRuleConfig) throws
DistSQLException {
+ if (null == currentRuleConfig && sqlStatement.isIfExists()) {
+ return;
+ }
+ String databaseName = database.getName();
+ Collection<String> auditorNames = new
LinkedList<>(sqlStatement.getAuditorNames());
+ checkExist(databaseName, auditorNames, currentRuleConfig,
sqlStatement);
+ checkInUsed(databaseName, auditorNames, currentRuleConfig);
+ }
+
+ private void checkExist(final String databaseName, final
Collection<String> auditorNames, final ShardingRuleConfiguration
currentRuleConfig,
+ final DropShardingAuditorStatement sqlStatement)
throws DistSQLException {
+ if (sqlStatement.isIfExists()) {
+ return;
+ }
+ Collection<String> notExistAuditors =
auditorNames.stream().filter(each ->
!currentRuleConfig.getAuditors().containsKey(each)).collect(Collectors.toList());
+ DistSQLException.predictionThrow(notExistAuditors.isEmpty(), () -> new
RequiredAuditorMissedException("Sharding", databaseName, notExistAuditors));
+ }
+
+ private void checkInUsed(final String databaseName, final
Collection<String> auditorNames, final ShardingRuleConfiguration
currentRuleConfig) throws DistSQLException {
+ Collection<String> usedAuditors = getUsedAuditors(currentRuleConfig);
+ Collection<String> inUsedNames =
auditorNames.stream().filter(usedAuditors::contains).collect(Collectors.toList());
+ DistSQLException.predictionThrow(inUsedNames.isEmpty(), () -> new
AuditorInUsedException("Sharding", databaseName, inUsedNames));
+ }
+
+ private Collection<String> getUsedAuditors(final ShardingRuleConfiguration
shardingRuleConfig) {
+ Collection<String> result = new LinkedHashSet<>();
+ shardingRuleConfig.getTables().stream().filter(each ->
Objects.nonNull(each.getAuditStrategy())).forEach(each ->
result.addAll(each.getAuditStrategy().getAuditorNames()));
+ shardingRuleConfig.getAutoTables().stream().filter(each ->
Objects.nonNull(each.getAuditStrategy())).forEach(each ->
result.addAll(each.getAuditStrategy().getAuditorNames()));
+ ShardingAuditStrategyConfiguration auditStrategy =
shardingRuleConfig.getDefaultAuditStrategy();
+ if (Objects.nonNull(auditStrategy) &&
!auditStrategy.getAuditorNames().isEmpty()) {
+ result.addAll(auditStrategy.getAuditorNames());
+ }
+ return result;
+ }
+
+ @Override
+ public boolean updateCurrentRuleConfiguration(final
DropShardingAuditorStatement sqlStatement, final ShardingRuleConfiguration
currentRuleConfig) {
+
currentRuleConfig.getAuditors().keySet().removeIf(sqlStatement.getAuditorNames()::contains);
+ return false;
+ }
+
+ @Override
+ public boolean hasAnyOneToBeDropped(final DropShardingAuditorStatement
sqlStatement, final ShardingRuleConfiguration currentRuleConfig) {
+ return null != currentRuleConfig &&
!getIdenticalData(currentRuleConfig.getAuditors().keySet(),
sqlStatement.getAuditorNames()).isEmpty();
+ }
+
+ @Override
+ public Class<ShardingRuleConfiguration> getRuleConfigurationClass() {
+ return ShardingRuleConfiguration.class;
+ }
+
+ @Override
+ public String getType() {
+ return DropShardingAuditorStatement.class.getName();
+ }
+}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.update.RuleDefinitionUpdater
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.update.RuleDefinitionUpdater
index 785948a6587..52cde466985 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.update.RuleDefinitionUpdater
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.update.RuleDefinitionUpdater
@@ -31,6 +31,7 @@
org.apache.shardingsphere.sharding.distsql.handler.update.AlterShardingAlgorithm
org.apache.shardingsphere.sharding.distsql.handler.update.CreateShardingKeyGeneratorStatementUpdater
org.apache.shardingsphere.sharding.distsql.handler.update.AlterShardingKeyGeneratorStatementUpdater
org.apache.shardingsphere.sharding.distsql.handler.update.DropShardingKeyGeneratorStatementUpdater
+org.apache.shardingsphere.sharding.distsql.handler.update.DropShardingAuditorStatementUpdater
org.apache.shardingsphere.sharding.distsql.handler.update.CreateShardingAuditorStatementUpdater
org.apache.shardingsphere.sharding.distsql.handler.update.AlterShardingAuditorStatementUpdater
org.apache.shardingsphere.sharding.distsql.handler.update.AlterDefaultShardingStrategyStatementUpdater
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAuditorStatementUpdaterTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAuditorStatementUpdaterTest.java
new file mode 100644
index 00000000000..e39580d19f0
--- /dev/null
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAuditorStatementUpdaterTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.sharding.distsql.update;
+
+import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
+import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
+import
org.apache.shardingsphere.infra.distsql.exception.rule.AuditorInUsedException;
+import
org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAuditorMissedException;
+import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import
org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
+import
org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAuditStrategyConfiguration;
+import
org.apache.shardingsphere.sharding.distsql.handler.update.DropShardingAuditorStatementUpdater;
+import
org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingAuditorStatement;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Properties;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public final class DropShardingAuditorStatementUpdaterTest {
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private ShardingSphereDatabase database;
+
+ private final DropShardingAuditorStatementUpdater updater = new
DropShardingAuditorStatementUpdater();
+
+ @Before
+ public void before() {
+ when(database.getName()).thenReturn("test");
+ }
+
+ @Test(expected = RequiredAuditorMissedException.class)
+ public void assertExecuteWithNotExist() throws DistSQLException {
+ updater.checkSQLStatement(database,
createSQLStatement("sharding_key_required_auditor"), new
ShardingRuleConfiguration());
+ }
+
+ @Test
+ public void assertExecuteWithNotExistWithIfExists() throws
DistSQLException {
+ DropShardingAuditorStatement sqlStatement = new
DropShardingAuditorStatement(true,
Collections.singletonList("sharding_key_required_auditor"));
+ updater.checkSQLStatement(database, sqlStatement, new
ShardingRuleConfiguration());
+ }
+
+ @Test
+ public void assertDropSpecifiedAuditor() {
+ ShardingRuleConfiguration currentRuleConfig = new
ShardingRuleConfiguration();
+ currentRuleConfig.getAuditors().put("sharding_key_required_auditor",
new AlgorithmConfiguration("DML_SHARDING_CONDITIONS", new Properties()));
+
updater.updateCurrentRuleConfiguration(createSQLStatement("sharding_key_required_auditor"),
currentRuleConfig);
+ assertTrue(currentRuleConfig.getAuditors().isEmpty());
+ }
+
+ @Test(expected = AuditorInUsedException.class)
+ public void assertExecuteWithUsed() throws DistSQLException {
+ ShardingRuleConfiguration currentRuleConfig = new
ShardingRuleConfiguration();
+ currentRuleConfig.getAuditors().put("sharding_key_required_auditor",
new AlgorithmConfiguration("DML_SHARDING_CONDITIONS", null));
+
currentRuleConfig.getAutoTables().add(createShardingAutoTableRuleConfiguration());
+ updater.checkSQLStatement(database,
createSQLStatement("sharding_key_required_auditor"), currentRuleConfig);
+ }
+
+ private ShardingAutoTableRuleConfiguration
createShardingAutoTableRuleConfiguration() {
+ ShardingAutoTableRuleConfiguration result = new
ShardingAutoTableRuleConfiguration("auto_table", null);
+ result.setAuditStrategy(new
ShardingAuditStrategyConfiguration(Collections.singletonList("sharding_key_required_auditor"),
true));
+ return result;
+ }
+
+ private DropShardingAuditorStatement createSQLStatement(final String...
auditorNames) {
+ return new DropShardingAuditorStatement(false,
Arrays.asList(auditorNames));
+ }
+}
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 8e89e0692c4..f2e4e9a6cd3 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
@@ -99,6 +99,10 @@ alterShardingAuditor
: ALTER SHARDING AUDITOR auditorDefinition (COMMA auditorDefinition)*
;
+dropShardingAuditor
+ : DROP SHARDING AUDITOR ifExists? auditorName (COMMA auditorName)*
+ ;
+
shardingTableRuleDefinition
: (shardingAutoTableRule | shardingTableRule)
;
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/sharding/org/apache/shardingsphere/distsql/parser/autogen/ShardingDistSQLStatement.g4
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/sharding/org/apache/shardingsphere/distsql/parser/autogen/ShardingDistSQLStatement.g4
index 0b9446562d5..8f92e2b41c3 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/sharding/org/apache/shardingsphere/distsql/parser/autogen/ShardingDistSQLStatement.g4
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/sharding/org/apache/shardingsphere/distsql/parser/autogen/ShardingDistSQLStatement.g4
@@ -52,6 +52,7 @@ execute
| showShardingAuditors
| createShardingAuditor
| alterShardingAuditor
+ | dropShardingAuditor
| showShardingDefaultShardingStrategy
| alterDefaultShardingStrategy
| dropDefaultShardingStrategy
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 401ba83b423..02f8a05fb75 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
@@ -50,6 +50,7 @@ import
org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatement
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.DropShardingBroadcastTableRulesContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.DropShardingKeyGeneratorContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.DropShardingTableRuleContext;
+import
org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.DropShardingAuditorContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.KeyGenerateDefinitionContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.KeyGenerateStrategyContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.KeyGeneratorDefinitionContext;
@@ -103,6 +104,7 @@ import
org.apache.shardingsphere.sharding.distsql.parser.statement.CreateShardin
import
org.apache.shardingsphere.sharding.distsql.parser.statement.CreateShardingTableRuleStatement;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.DropDefaultShardingStrategyStatement;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingAlgorithmStatement;
+import
org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingAuditorStatement;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingBindingTableRulesStatement;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingBroadcastTableRulesStatement;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingKeyGeneratorStatement;
@@ -471,6 +473,11 @@ public final class ShardingDistSQLStatementVisitor extends
ShardingDistSQLStatem
return new
ShardingAuditorSegment(getIdentifierValue(ctx.auditorName()),
(AlgorithmSegment) visitAlgorithmDefinition(ctx.algorithmDefinition()));
}
+ @Override
+ public ASTNode visitDropShardingAuditor(final DropShardingAuditorContext
ctx) {
+ return new DropShardingAuditorStatement(null != ctx.ifExists(),
ctx.auditorName().stream().map(this::getIdentifierValue).collect(Collectors.toList()));
+ }
+
@Override
public ASTNode visitShowShardingAuditors(final ShowShardingAuditorsContext
ctx) {
return new
ShowShardingAuditorsStatement(Objects.nonNull(ctx.databaseName()) ?
(DatabaseSegment) visit(ctx.databaseName()) : null);
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-statement/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/statement/DropShardingAuditorStatement.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-statement/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/statement/DropShardingAuditorStatement.java
new file mode 100644
index 00000000000..7add2e3e539
--- /dev/null
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-statement/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/statement/DropShardingAuditorStatement.java
@@ -0,0 +1,37 @@
+/*
+ * 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.sharding.distsql.parser.statement;
+
+import lombok.Getter;
+import
org.apache.shardingsphere.distsql.parser.statement.rdl.drop.DropRuleStatement;
+
+import java.util.Collection;
+
+/**
+ * Drop sharding auditor statement.
+ */
+@Getter
+public final class DropShardingAuditorStatement extends DropRuleStatement {
+
+ private final Collection<String> auditorNames;
+
+ public DropShardingAuditorStatement(final boolean ifExists, final
Collection<String> auditorNames) {
+ super(ifExists);
+ this.auditorNames = auditorNames;
+ }
+}
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/AuditorInUsedException.java
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/AuditorInUsedException.java
new file mode 100644
index 00000000000..c13adf0199b
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/AuditorInUsedException.java
@@ -0,0 +1,32 @@
+/*
+ * 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.infra.distsql.exception.rule;
+
+import java.util.Collection;
+
+/**
+ * Auditor in used exception.
+ */
+public final class AuditorInUsedException extends
RuleDefinitionViolationException {
+
+ private static final long serialVersionUID = 367366381929736622L;
+
+ public AuditorInUsedException(final String ruleType, final String
databaseName, final Collection<String> auditorNames) {
+ super(1128, String.format("%s auditor `%s` in database `%s` are still
in used.", ruleType, auditorNames, databaseName));
+ }
+}
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RequiredAuditorMissedException.java
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RequiredAuditorMissedException.java
new file mode 100644
index 00000000000..62939728a22
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RequiredAuditorMissedException.java
@@ -0,0 +1,29 @@
+/*
+ * 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.infra.distsql.exception.rule;
+
+import java.util.Collection;
+
+public class RequiredAuditorMissedException extends
RuleDefinitionViolationException {
+
+ private static final long serialVersionUID = -1347038187749832773L;
+
+ public RequiredAuditorMissedException(final String type, final String
databaseName, final Collection<String> auditorNames) {
+ super(1127, String.format("%s auditor `%s` do not exist in database
`%s`.", type, auditorNames, databaseName));
+ }
+}
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/rdl/drop/DropRuleStatementAssert.java
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/rdl/drop/DropRuleStatementAssert.java
index 107f5f8ed79..c03620cef66 100644
---
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/rdl/drop/DropRuleStatementAssert.java
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/rdl/drop/DropRuleStatementAssert.java
@@ -29,6 +29,7 @@ import
org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.Dro
import
org.apache.shardingsphere.shadow.distsql.parser.statement.DropShadowRuleStatement;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.DropDefaultShardingStrategyStatement;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingAlgorithmStatement;
+import
org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingAuditorStatement;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingBindingTableRulesStatement;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingBroadcastTableRulesStatement;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingKeyGeneratorStatement;
@@ -43,6 +44,7 @@ import
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement
import
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.rdl.drop.impl.DropReadwriteSplittingRuleStatementAssert;
import
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.rdl.drop.impl.DropShadowRuleStatementAssert;
import
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.rdl.drop.impl.DropShardingAlgorithmStatementAssert;
+import
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.rdl.drop.impl.DropShardingAuditorStatementAssert;
import
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.rdl.drop.impl.DropShardingBindingTableRulesStatementAssert;
import
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.rdl.drop.impl.DropShardingBroadcastTableRulesStatementAssert;
import
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.rdl.drop.impl.DropShardingKeyGeneratorStatementAssert;
@@ -57,6 +59,7 @@ import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rdl.drop.DropReadwriteSplittingRuleStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rdl.drop.DropShadowRuleStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rdl.drop.DropShardingAlgorithmStatementTestCase;
+import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rdl.drop.DropShardingAuditorStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rdl.drop.DropShardingBindingTableRulesStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rdl.drop.DropShardingBroadcastTableRulesStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rdl.drop.DropShardingKeyGeneratorStatementTestCase;
@@ -102,6 +105,8 @@ public final class DropRuleStatementAssert {
DropShardingAlgorithmStatementAssert.assertIs(assertContext,
(DropShardingAlgorithmStatement) actual,
(DropShardingAlgorithmStatementTestCase) expected);
} else if (actual instanceof DropShardingKeyGeneratorStatement) {
DropShardingKeyGeneratorStatementAssert.assertIs(assertContext,
(DropShardingKeyGeneratorStatement) actual,
(DropShardingKeyGeneratorStatementTestCase) expected);
+ } else if (actual instanceof DropShardingAuditorStatement) {
+ DropShardingAuditorStatementAssert.assertIs(assertContext,
(DropShardingAuditorStatement) actual, (DropShardingAuditorStatementTestCase)
expected);
}
}
}
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/rdl/drop/impl/DropShardingAuditorStatementAssert.java
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/rdl/drop/impl/DropShardingAuditorStatementAssert.java
new file mode 100644
index 00000000000..be36c439f00
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/rdl/drop/impl/DropShardingAuditorStatementAssert.java
@@ -0,0 +1,51 @@
+/*
+ * 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.test.sql.parser.parameterized.asserts.statement.distsql.rdl.drop.impl;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import
org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingAuditorStatement;
+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.DropShardingAuditorStatementTestCase;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Drop sharding auditor statement assert.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class DropShardingAuditorStatementAssert {
+
+ /**
+ * Assert drop sharding auditor statement is correct with expected parser
result.
+ *
+ * @param assertContext assert context
+ * @param actual actual drop sharding auditor statement
+ * @param expected expected drop sharding auditor statement test case
+ */
+ public static void assertIs(final SQLCaseAssertContext assertContext,
final DropShardingAuditorStatement actual, final
DropShardingAuditorStatementTestCase expected) {
+ if (null == expected.getAuditorName()) {
+ assertNull(assertContext.getText("Actual auditor name should not
exist."), actual);
+ } else {
+ assertThat(assertContext.getText("Auditor names assertion error:
"), actual.getAuditorNames(), is(expected.getAuditorName()));
+ assertThat(assertContext.getText("Contains exist clause assertion
error: "), actual.isIfExists(), is(expected.isIfExists()));
+ }
+ }
+}
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
index 102d1264e53..9e5517011aa 100644
---
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
@@ -368,6 +368,7 @@ import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rdl.drop.DropShadowAlgorithmStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rdl.drop.DropShadowRuleStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rdl.drop.DropShardingAlgorithmStatementTestCase;
+import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rdl.drop.DropShardingAuditorStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rdl.drop.DropShardingBindingTableRulesStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rdl.drop.DropShardingBroadcastTableRulesStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rdl.drop.DropShardingKeyGeneratorStatementTestCase;
@@ -1199,6 +1200,9 @@ public final class SQLParserTestCases {
@XmlElement(name = "drop-sharding-key-generator")
private final List<DropShardingKeyGeneratorStatementTestCase>
dropShardingKeyGeneratorTestCases = new LinkedList<>();
+ @XmlElement(name = "drop-sharding-auditor")
+ private final List<DropShardingAuditorStatementTestCase>
dropShardingAuditorTestCases = new LinkedList<>();
+
@XmlElement(name = "drop-default-sharding-strategy")
private final List<DropDefaultShardingStrategyStatementTestCase>
dropDefaultShardingStrategyTestCases = new LinkedList<>();
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/DropShardingAuditorStatementTestCase.java
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/rdl/drop/DropShardingAuditorStatementTestCase.java
new file mode 100644
index 00000000000..bcb9d7290a8
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/rdl/drop/DropShardingAuditorStatementTestCase.java
@@ -0,0 +1,35 @@
+/*
+ * 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.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rdl.drop;
+
+import lombok.Getter;
+import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.DropRuleStatementTestCase;
+
+import java.util.LinkedList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ * Drop sharding auditor statement test case.
+ */
+@Getter
+public final class DropShardingAuditorStatementTestCase extends
DropRuleStatementTestCase {
+
+ @XmlElement(name = "auditor")
+ private final List<String> auditorName = 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 5f348fb7421..35bc36d5a30 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
@@ -148,7 +148,15 @@
<drop-sharding-key-generator
sql-case-id="drop-sharding-key-generator-if-exists" if-exists="true">
<key-generator>uuid_key_generator</key-generator>
</drop-sharding-key-generator>
-
+
+ <drop-sharding-auditor sql-case-id="drop-sharding-auditor" >
+ <auditor>sharding_key_required_auditor</auditor>
+ </drop-sharding-auditor>
+
+ <drop-sharding-auditor sql-case-id="drop-sharding-auditor-if-exists"
if-exists="true">
+ <auditor>sharding_key_required_auditor</auditor>
+ </drop-sharding-auditor>
+
<drop-default-sharding-strategy
sql-case-id="drop-default-sharding-strategy" type="table"/>
<drop-default-sharding-strategy
sql-case-id="drop-default-sharding-strategy-if-exists" type="table"
if-exists="true"/>
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 eb49c064cc1..d47e084c09e 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
@@ -47,6 +47,8 @@
<distsql-case id="drop-default-single-table-if-exists" value="DROP DEFAULT
SINGLE TABLE RULE IF EXISTS" />
<distsql-case id="drop-sharding-key-generator" value="DROP SHARDING KEY
GENERATOR uuid_key_generator" />
<distsql-case id="drop-sharding-key-generator-if-exists" value="DROP
SHARDING KEY GENERATOR IF EXISTS uuid_key_generator" />
+ <distsql-case id="drop-sharding-auditor" value="DROP SHARDING AUDITOR
sharding_key_required_auditor" />
+ <distsql-case id="drop-sharding-auditor-if-exists" value="DROP SHARDING
AUDITOR IF EXISTS sharding_key_required_auditor" />
<distsql-case id="drop-default-sharding-strategy" value="DROP DEFAULT
SHARDING TABLE STRATEGY" />
<distsql-case id="drop-default-sharding-strategy-if-exists" value="DROP
DEFAULT SHARDING TABLE STRATEGY IF EXISTS" />
<distsql-case id="drop-sharding-algorithm" value="DROP SHARDING ALGORITHM
IF EXISTS t_order_hash_mod" />