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 50e638a  Add syntax for DROP SHARDING KEY GENERATOR (#14247)
50e638a is described below

commit 50e638abd56d9842c74da4360597eaa178282afb
Author: Liangda-w <[email protected]>
AuthorDate: Sun Dec 26 07:01:46 2021 +0100

    Add syntax for DROP SHARDING KEY GENERATOR (#14247)
    
    * Add syntax for DROP SHARDING KEY GENERATOR
    
    * Add license header
    
    * Remove duplicate line
---
 .../DropShardingKeyGeneratorStatementUpdater.java  | 74 +++++++++++++++++++
 ...here.infra.distsql.update.RuleDefinitionUpdater |  1 +
 ...opShardingKeyGeneratorStatementUpdaterTest.java | 86 ++++++++++++++++++++++
 .../main/antlr4/imports/sharding/RDLStatement.g4   |  4 +
 .../parser/autogen/ShardingDistSQLStatement.g4     |  1 +
 .../core/ShardingDistSQLStatementVisitor.java      |  7 ++
 .../DropShardingKeyGeneratorStatement.java         | 34 +++++++++
 .../rule/RequiredKeyGeneratorMissedException.java  | 30 ++++++++
 .../jaxb/cases/domain/SQLParserTestCases.java      |  7 +-
 .../DropShardingKeyGeneratorStatementTestCase.java | 35 +++++++++
 .../src/main/resources/case/rdl/drop.xml           |  4 +
 .../src/main/resources/sql/supported/rdl/drop.xml  |  1 +
 12 files changed, 283 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/DropShardingKeyGeneratorStatementUpdater.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingKeyGeneratorStatementUpdater.java
new file mode 100644
index 0000000..5818e22
--- /dev/null
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingKeyGeneratorStatementUpdater.java
@@ -0,0 +1,74 @@
+/*
+ * 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.DuplicateKeyGeneratorException;
+import 
org.apache.shardingsphere.infra.distsql.exception.rule.RequiredKeyGeneratorMissedException;
+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.DropShardingKeyGeneratorStatement;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Drop sharding key generator statement updater.
+ */
+public final class DropShardingKeyGeneratorStatementUpdater implements 
RuleDefinitionDropUpdater<DropShardingKeyGeneratorStatement, 
ShardingRuleConfiguration> {
+    
+    @Override
+    public void checkSQLStatement(final ShardingSphereMetaData 
shardingSphereMetaData, final DropShardingKeyGeneratorStatement sqlStatement,
+                                  final ShardingRuleConfiguration 
currentRuleConfig) throws DistSQLException {
+        String schemaName = shardingSphereMetaData.getName();
+        LinkedList<String> keyGeneratorNames = 
sqlStatement.getKeyGeneratorNames().stream().collect(Collectors.toCollection(LinkedList::new));
+        checkDuplicate(schemaName, keyGeneratorNames);
+        checkExist(schemaName, keyGeneratorNames, currentRuleConfig);
+    }
+
+    private void checkDuplicate(final String schemaName, final 
Collection<String> keyGeneratorNames) throws DistSQLException {
+        Set<String> duplicateNames = 
keyGeneratorNames.stream().collect(Collectors.groupingBy(each -> each, 
Collectors.counting())).entrySet().stream()
+                .filter(each -> each.getValue() > 
1).map(Map.Entry::getKey).collect(Collectors.toSet());
+        DistSQLException.predictionThrow(duplicateNames.isEmpty(), new 
DuplicateKeyGeneratorException("sharding", schemaName, duplicateNames));
+    }
+    
+    private void checkExist(final String schemaName, final Collection<String> 
keyGeneratorNames, final ShardingRuleConfiguration currentRuleConfig) throws 
DistSQLException {
+        LinkedList<String> notExistKeyGenerators = 
keyGeneratorNames.stream().filter(each -> 
!currentRuleConfig.getKeyGenerators().containsKey(each)).collect(Collectors.toCollection(LinkedList::new));
+        DistSQLException.predictionThrow(notExistKeyGenerators.isEmpty(), new 
RequiredKeyGeneratorMissedException("sharding", schemaName, 
notExistKeyGenerators));
+    }
+
+    @Override
+    public boolean updateCurrentRuleConfiguration(final 
DropShardingKeyGeneratorStatement sqlStatement, final ShardingRuleConfiguration 
currentRuleConfig) {
+        
currentRuleConfig.getKeyGenerators().keySet().removeIf(sqlStatement.getKeyGeneratorNames()::contains);
+        return false;
+    }
+    
+    @Override
+    public Class<ShardingRuleConfiguration> getRuleConfigurationClass() {
+        return ShardingRuleConfiguration.class;
+    }
+    
+    @Override
+    public String getType() {
+        return DropShardingKeyGeneratorStatement.class.getCanonicalName();
+    }
+}
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 0a912e4..343cc6b 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
@@ -30,3 +30,4 @@ 
org.apache.shardingsphere.sharding.distsql.handler.update.CreateDefaultShardingS
 
org.apache.shardingsphere.sharding.distsql.handler.update.AlterShardingAlgorithmStatementUpdater
 
org.apache.shardingsphere.sharding.distsql.handler.update.CreateShardingKeyGeneratorStatementUpdater
 
org.apache.shardingsphere.sharding.distsql.handler.update.AlterShardingKeyGeneratorStatementUpdater
+org.apache.shardingsphere.sharding.distsql.handler.update.DropShardingKeyGeneratorStatementUpdater
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingKeyGeneratorStatementUpdaterTest.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingKeyGeneratorStatementUpdaterTest.java
new file mode 100644
index 0000000..9a30346
--- /dev/null
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingKeyGeneratorStatementUpdaterTest.java
@@ -0,0 +1,86 @@
+/*
+ * 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.distsql.parser.segment.AlgorithmSegment;
+import 
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
+import 
org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateKeyGeneratorException;
+import 
org.apache.shardingsphere.infra.distsql.exception.rule.RequiredKeyGeneratorMissedException;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import 
org.apache.shardingsphere.sharding.distsql.handler.update.DropShardingKeyGeneratorStatementUpdater;
+import 
org.apache.shardingsphere.sharding.distsql.parser.segment.ShardingKeyGeneratorSegment;
+import 
org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingKeyGeneratorStatement;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public final class DropShardingKeyGeneratorStatementUpdaterTest {
+    
+    @Mock
+    private ShardingSphereMetaData shardingSphereMetaData;
+    
+    private final DropShardingKeyGeneratorStatementUpdater updater = new 
DropShardingKeyGeneratorStatementUpdater();
+    
+    @Before
+    public void before() {
+        when(shardingSphereMetaData.getName()).thenReturn("test");
+    }
+    
+    @Test(expected = DuplicateKeyGeneratorException.class)
+    public void assertExecuteWithDuplicate() throws DistSQLException {
+        updater.checkSQLStatement(shardingSphereMetaData, 
createSQLStatement("uuid_key_generator", "uuid_key_generator"), null);
+    }
+    
+    @Test(expected = RequiredKeyGeneratorMissedException.class)
+    public void assertExecuteWithNotExist() throws DistSQLException {
+        updater.checkSQLStatement(shardingSphereMetaData, 
createSQLStatement("uuid_key_generator"), new ShardingRuleConfiguration());
+    }
+
+    @Test
+    public void assertDropSpecifiedKeyGenerator() {
+        ShardingRuleConfiguration currentRuleConfig = new 
ShardingRuleConfiguration();
+        currentRuleConfig.getKeyGenerators().put("uuid_key_generator", new 
ShardingSphereAlgorithmConfiguration("uuid", buildProps()));
+        
updater.updateCurrentRuleConfiguration(createSQLStatement("uuid_key_generator"),
 currentRuleConfig);
+        assertTrue(currentRuleConfig.getKeyGenerators().isEmpty());
+    }
+    
+    private DropShardingKeyGeneratorStatement createSQLStatement(final 
String... keyGeneratorNames) {
+        return new 
DropShardingKeyGeneratorStatement(Arrays.asList(keyGeneratorNames));
+    }
+
+    private ShardingKeyGeneratorSegment buildShardingKeyGeneratorSegment() {
+        return new ShardingKeyGeneratorSegment("uuid_key_generator", new 
AlgorithmSegment("uuid", buildProps()));
+    }
+
+    private Properties buildProps() {
+        Properties props = new Properties();
+        props.put("worker-id", "123");
+        return props;
+    }
+}
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 0cce750..635ead9 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
@@ -79,6 +79,10 @@ dropShardingAlgorithm
     : DROP SHARDING ALGORITHM algorithmName (COMMA algorithmName)*
     ;
 
+dropShardingKeyGenerator
+    : DROP SHARDING KEY GENERATOR keyGeneratorName (COMMA keyGeneratorName)*
+    ;
+
 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 67a014c..7fcaa71 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
@@ -46,5 +46,6 @@ execute
     | createShardingKeyGenerator
     | alterShardingKeyGenerator
     | showShardingKeyGenerators
+    | dropShardingKeyGenerator
     ) SEMI?
     ;
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 102d15f..2668140 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
@@ -41,6 +41,7 @@ import 
org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatement
 import 
org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.DropShardingAlgorithmContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.DropShardingBindingTableRulesContext;
 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.KeyGenerateStrategyContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.KeyGeneratorDefinationContext;
@@ -84,6 +85,7 @@ import 
org.apache.shardingsphere.sharding.distsql.parser.statement.CreateShardin
 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;
+import 
org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingKeyGeneratorStatement;
 import 
org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingTableRuleStatement;
 import 
org.apache.shardingsphere.sharding.distsql.parser.statement.ShowShardingAlgorithmsStatement;
 import 
org.apache.shardingsphere.sharding.distsql.parser.statement.ShowShardingBindingTableRulesStatement;
@@ -372,4 +374,9 @@ public final class ShardingDistSQLStatementVisitor extends 
ShardingDistSQLStatem
     public ASTNode visitShowShardingKeyGenerators(final 
ShowShardingKeyGeneratorsContext ctx) {
         return new 
ShowShardingKeyGeneratorsStatement(Objects.nonNull(ctx.schemaName()) ? 
(SchemaSegment) visit(ctx.schemaName()) : null);
     }
+
+    @Override
+    public ASTNode visitDropShardingKeyGenerator(final 
DropShardingKeyGeneratorContext ctx) {
+        return new 
DropShardingKeyGeneratorStatement(ctx.keyGeneratorName().stream().map(each -> 
getIdentifierValue(each)).collect(Collectors.toList()));
+    }
 }
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-statement/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/statement/DropShardingKeyGeneratorStatement.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-statement/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/statement/DropShardingKeyGeneratorStatement.java
new file mode 100644
index 0000000..5c1b4d7
--- /dev/null
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-statement/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/statement/DropShardingKeyGeneratorStatement.java
@@ -0,0 +1,34 @@
+/*
+ * 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 lombok.RequiredArgsConstructor;
+import 
org.apache.shardingsphere.distsql.parser.statement.rdl.drop.DropRuleStatement;
+
+import java.util.Collection;
+
+/**
+ * Drop sharding key generator statement.
+ */
+@RequiredArgsConstructor
+@Getter
+public final class DropShardingKeyGeneratorStatement extends DropRuleStatement 
{
+
+    private final Collection<String> keyGeneratorNames;
+}
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RequiredKeyGeneratorMissedException.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RequiredKeyGeneratorMissedException.java
new file mode 100644
index 0000000..9cde8a3
--- /dev/null
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/exception/rule/RequiredKeyGeneratorMissedException.java
@@ -0,0 +1,30 @@
+/*
+ * 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 RequiredKeyGeneratorMissedException extends 
RuleDefinitionViolationException {
+
+    private static final long serialVersionUID = -2391552466149640249L;
+
+    public RequiredKeyGeneratorMissedException(final String type, final String 
schemaName, final Collection<String> keyGeneratorNames) {
+        super(1118, String.format("%s key generator `%s` do not exist in 
schema `%s`.", type, keyGeneratorNames, schemaName));
+    }
+    
+}
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 f3041a4..938ace2 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
@@ -204,6 +204,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.DropShadowRuleStatementTestCase;
 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;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rdl.drop.DropShardingTableRuleStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowDataBaseDiscoveryRulesStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowEncryptRulesStatementTestCase;
@@ -829,6 +830,9 @@ public final class SQLParserTestCases {
     
     @XmlElement(name = "alter-sharding-key-generator")
     private final List<AlterShardingKeyGeneratorStatementTestCase> 
alterShardingKeyGeneratorStatementTestCases = new LinkedList<>();
+
+    @XmlElement(name = "drop-sharding-key-generator")
+    private final List<DropShardingKeyGeneratorStatementTestCase> 
dropShardingKeyGeneratorStatementTestCases = new LinkedList<>();
     
     @XmlElement(name = "reset")
     private final List<ResetStatementTestCase> resetStatementTestCases = new 
LinkedList<>();
@@ -1112,7 +1116,8 @@ public final class SQLParserTestCases {
         putAll(showCharacterSetStatementTestCases, result);
         putAll(showCollationStatementTestCases, result);
         putAll(showVariablesStatementTestCases, result);
-        putAll(showShardingKeyGeneratorsStatementTestCases, result);
+        putAll(showShardingKeyGeneratorsStatementTestCases,result);
+        putAll(dropShardingKeyGeneratorStatementTestCases, result);
         putAll(delimiterStatementTestCases, result);
         putAll(dropDomainStatementTestCases, result);
         putAll(showSQLParserRuleStatementTestCases, result);
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/DropShardingKeyGeneratorStatementTestCase.java
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/rdl/drop/DropShardingKeyGeneratorStatementTestCase.java
new file mode 100644
index 0000000..3f394e7
--- /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/DropShardingKeyGeneratorStatementTestCase.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.SQLParserTestCase;
+
+import javax.xml.bind.annotation.XmlElement;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Drop sharding key generator statement test case.
+ */
+@Getter
+public final class DropShardingKeyGeneratorStatementTestCase extends 
SQLParserTestCase {
+    
+    @XmlElement(name = "key-generator")
+    private final List<String> keyGeneratorName = 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 eb8dff4..eab1208 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
@@ -79,4 +79,8 @@
     </drop-shadow-algorithm>
 
     <drop-default-single-table sql-case-id="drop-default-single-table" />
+
+    <drop-sharding-key-generator sql-case-id="drop-sharding-key-generator" >
+        <key-generator>uuid_key_generator</key-generator>
+    </drop-sharding-key-generator>
 </sql-parser-test-cases>
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 788b53b..3c4366d 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
@@ -32,4 +32,5 @@
     <distsql-case id="drop-shadow-rule" value="DROP SHADOW RULE 
shadow_rule_1,shadow_rule_2" />
     <distsql-case id="drop-shadow-algorithm" value="DROP SHADOW algorithm 
shadow_algorithm_1,shadow_algorithm_2" />
     <distsql-case id="drop-default-single-table" value="DROP DEFAULT SINGLE 
TABLE RULE" />
+    <distsql-case id="drop-sharding-key-generator" value="DROP SHARDING KEY 
GENERATOR uuid_key_generator" />
 </sql-cases>

Reply via email to