You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/07/15 09:16:07 UTC

[GitHub] [shardingsphere] RaigorJiang opened a new pull request #11346: Add distSQL syntax: 'drop sharding algorithm'.

RaigorJiang opened a new pull request #11346:
URL: https://github.com/apache/shardingsphere/pull/11346


   Add distSQL syntax: 'drop sharding algorithm'.
   
   example: 
   ```
   DROP SHARDING ALGORITHM t_user_mod;
   
   DROP SHARDING ALGORITHM t_order_item_inline,t_order_inline, database_inline;
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] codecov-commenter edited a comment on pull request #11346: Add distSQL syntax: 'drop sharding algorithm'.

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #11346:
URL: https://github.com/apache/shardingsphere/pull/11346#issuecomment-880585974


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#11346](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b34faac) into [master](https://codecov.io/gh/apache/shardingsphere/commit/e50546265b8cdcb10300c6b7293bceb7402aaae1?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (e505462) will **increase** coverage by `0.00%`.
   > The diff coverage is `66.66%`.
   
   > :exclamation: Current head b34faac differs from pull request most recent head b51c0c9. Consider uploading reports for the commit b51c0c9 to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/11346/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff            @@
   ##             master   #11346   +/-   ##
   =========================================
     Coverage     63.52%   63.53%           
   - Complexity     1028     1061   +33     
   =========================================
     Files          2216     2219    +3     
     Lines         33752    33793   +41     
     Branches       5896     5897    +1     
   =========================================
   + Hits          21441    21469   +28     
   - Misses        10605    10615   +10     
   - Partials       1706     1709    +3     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...l/parser/core/ShardingRuleSQLStatementVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctZGlzdHNxbC9zaGFyZGluZ3NwaGVyZS1zaGFyZGluZy1kaXN0c3FsLXBhcnNlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvZGlzdHNxbC9wYXJzZXIvY29yZS9TaGFyZGluZ1J1bGVTUUxTdGF0ZW1lbnRWaXNpdG9yLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...stsql/exception/rule/AlgorithmInUsedException.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kaXN0c3FsL2V4Y2VwdGlvbi9ydWxlL0FsZ29yaXRobUluVXNlZEV4Y2VwdGlvbi5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...ception/rule/RequiredAlgorithmMissedException.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kaXN0c3FsL2V4Y2VwdGlvbi9ydWxlL1JlcXVpcmVkQWxnb3JpdGhtTWlzc2VkRXhjZXB0aW9uLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [.../update/DropShardingAlgorithmStatementUpdater.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctZGlzdHNxbC9zaGFyZGluZ3NwaGVyZS1zaGFyZGluZy1kaXN0c3FsLWhhbmRsZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NoYXJkaW5nL2Rpc3RzcWwvaGFuZGxlci91cGRhdGUvRHJvcFNoYXJkaW5nQWxnb3JpdGhtU3RhdGVtZW50VXBkYXRlci5qYXZh) | `80.00% <80.00%> (ø)` | |
   | [...mmunication/jdbc/connection/BackendConnection.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC9jb21tdW5pY2F0aW9uL2pkYmMvY29ubmVjdGlvbi9CYWNrZW5kQ29ubmVjdGlvbi5qYXZh) | `80.86% <0.00%> (+0.69%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [e505462...b51c0c9](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] menghaoranss merged pull request #11346: Add distSQL syntax: 'drop sharding algorithm'.

Posted by GitBox <gi...@apache.org>.
menghaoranss merged pull request #11346:
URL: https://github.com/apache/shardingsphere/pull/11346


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] codecov-commenter commented on pull request #11346: Add distSQL syntax: 'drop sharding algorithm'.

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #11346:
URL: https://github.com/apache/shardingsphere/pull/11346#issuecomment-880585974


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#11346](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (97c0aad) into [master](https://codecov.io/gh/apache/shardingsphere/commit/e50546265b8cdcb10300c6b7293bceb7402aaae1?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (e505462) will **increase** coverage by `0.00%`.
   > The diff coverage is `66.66%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/11346/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff            @@
   ##             master   #11346   +/-   ##
   =========================================
     Coverage     63.52%   63.52%           
     Complexity     1028     1028           
   =========================================
     Files          2216     2219    +3     
     Lines         33752    33794   +42     
     Branches       5896     5903    +7     
   =========================================
   + Hits          21441    21469   +28     
   - Misses        10605    10616   +11     
   - Partials       1706     1709    +3     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...l/parser/core/ShardingRuleSQLStatementVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctZGlzdHNxbC9zaGFyZGluZ3NwaGVyZS1zaGFyZGluZy1kaXN0c3FsLXBhcnNlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvZGlzdHNxbC9wYXJzZXIvY29yZS9TaGFyZGluZ1J1bGVTUUxTdGF0ZW1lbnRWaXNpdG9yLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...stsql/exception/rule/AlgorithmInUsedException.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kaXN0c3FsL2V4Y2VwdGlvbi9ydWxlL0FsZ29yaXRobUluVXNlZEV4Y2VwdGlvbi5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...ception/rule/RequiredAlgorithmMissedException.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kaXN0c3FsL2V4Y2VwdGlvbi9ydWxlL1JlcXVpcmVkQWxnb3JpdGhtTWlzc2VkRXhjZXB0aW9uLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [.../update/DropShardingAlgorithmStatementUpdater.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctZGlzdHNxbC9zaGFyZGluZ3NwaGVyZS1zaGFyZGluZy1kaXN0c3FsLWhhbmRsZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NoYXJkaW5nL2Rpc3RzcWwvaGFuZGxlci91cGRhdGUvRHJvcFNoYXJkaW5nQWxnb3JpdGhtU3RhdGVtZW50VXBkYXRlci5qYXZh) | `80.00% <80.00%> (ø)` | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [e505462...97c0aad](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on a change in pull request #11346: Add distSQL syntax: 'drop sharding algorithm'.

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on a change in pull request #11346:
URL: https://github.com/apache/shardingsphere/pull/11346#discussion_r670810807



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmStatementUpdater.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.rule.RuleDefinitionViolationException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
+import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
+import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingAlgorithmStatement;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.stream.Collectors;
+
+/**
+ * Drop sharding algorithm statement updater.
+ */
+public final class DropShardingAlgorithmStatementUpdater implements RuleDefinitionDropUpdater<DropShardingAlgorithmStatement, ShardingRuleConfiguration> {
+    
+    @Override
+    public void checkSQLStatement(final String schemaName, final DropShardingAlgorithmStatement sqlStatement, 
+                                  final ShardingRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws RuleDefinitionViolationException {
+        checkCurrentRuleConfiguration(schemaName, currentRuleConfig);
+        checkShardingAlgorithmsExisted(schemaName, sqlStatement, currentRuleConfig);
+        checkShardingAlgorithmsInUsed(schemaName, sqlStatement, currentRuleConfig);
+    }
+    
+    private void checkCurrentRuleConfiguration(final String schemaName, final ShardingRuleConfiguration currentRuleConfig) throws RequiredAlgorithmMissedException {
+        if (null == currentRuleConfig) {
+            throw new RequiredAlgorithmMissedException(schemaName);
+        }
+    }
+    
+    private void checkShardingAlgorithmsExisted(final String schemaName, final DropShardingAlgorithmStatement sqlStatement,

Review comment:
       This is a plural form, and ‘is’ is not suitable. If necessary, I prefer ‘checkShardingAlgorithmsIsExist’,  similar to ’File.exists‘




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] codecov-commenter edited a comment on pull request #11346: Add distSQL syntax: 'drop sharding algorithm'.

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #11346:
URL: https://github.com/apache/shardingsphere/pull/11346#issuecomment-880585974


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#11346](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2150feb) into [master](https://codecov.io/gh/apache/shardingsphere/commit/e50546265b8cdcb10300c6b7293bceb7402aaae1?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (e505462) will **increase** coverage by `0.04%`.
   > The diff coverage is `68.18%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/11346/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #11346      +/-   ##
   ============================================
   + Coverage     63.52%   63.56%   +0.04%     
   - Complexity     1028     1061      +33     
   ============================================
     Files          2216     2219       +3     
     Lines         33752    33794      +42     
     Branches       5896     5897       +1     
   ============================================
   + Hits          21441    21482      +41     
   + Misses        10605    10600       -5     
   - Partials       1706     1712       +6     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...l/parser/core/ShardingRuleSQLStatementVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctZGlzdHNxbC9zaGFyZGluZ3NwaGVyZS1zaGFyZGluZy1kaXN0c3FsLXBhcnNlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvZGlzdHNxbC9wYXJzZXIvY29yZS9TaGFyZGluZ1J1bGVTUUxTdGF0ZW1lbnRWaXNpdG9yLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...stsql/exception/rule/AlgorithmInUsedException.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kaXN0c3FsL2V4Y2VwdGlvbi9ydWxlL0FsZ29yaXRobUluVXNlZEV4Y2VwdGlvbi5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...ception/rule/RequiredAlgorithmMissedException.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kaXN0c3FsL2V4Y2VwdGlvbi9ydWxlL1JlcXVpcmVkQWxnb3JpdGhtTWlzc2VkRXhjZXB0aW9uLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [.../update/DropShardingAlgorithmStatementUpdater.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctZGlzdHNxbC9zaGFyZGluZ3NwaGVyZS1zaGFyZGluZy1kaXN0c3FsLWhhbmRsZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NoYXJkaW5nL2Rpc3RzcWwvaGFuZGxlci91cGRhdGUvRHJvcFNoYXJkaW5nQWxnb3JpdGhtU3RhdGVtZW50VXBkYXRlci5qYXZh) | `81.08% <81.08%> (ø)` | |
   | [.../config/service/impl/PropertiesPersistService.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZ292ZXJuYW5jZS9zaGFyZGluZ3NwaGVyZS1nb3Zlcm5hbmNlLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2dvdmVybmFuY2UvY29yZS9yZWdpc3RyeS9jb25maWcvc2VydmljZS9pbXBsL1Byb3BlcnRpZXNQZXJzaXN0U2VydmljZS5qYXZh) | | |
   | [...sphere/governance/core/registry/PersistCenter.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZ292ZXJuYW5jZS9zaGFyZGluZ3NwaGVyZS1nb3Zlcm5hbmNlLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2dvdmVybmFuY2UvY29yZS9yZWdpc3RyeS9QZXJzaXN0Q2VudGVyLmphdmE=) | | |
   | [.../config/service/impl/DataSourcePersistService.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZ292ZXJuYW5jZS9zaGFyZGluZ3NwaGVyZS1nb3Zlcm5hbmNlLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2dvdmVybmFuY2UvY29yZS9yZWdpc3RyeS9jb25maWcvc2VydmljZS9pbXBsL0RhdGFTb3VyY2VQZXJzaXN0U2VydmljZS5qYXZh) | | |
   | [...vernance/core/registry/config/node/GlobalNode.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZ292ZXJuYW5jZS9zaGFyZGluZ3NwaGVyZS1nb3Zlcm5hbmNlLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2dvdmVybmFuY2UvY29yZS9yZWdpc3RyeS9jb25maWcvbm9kZS9HbG9iYWxOb2RlLmphdmE=) | | |
   | [.../config/service/impl/SchemaRulePersistService.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZ292ZXJuYW5jZS9zaGFyZGluZ3NwaGVyZS1nb3Zlcm5hbmNlLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2dvdmVybmFuY2UvY29yZS9yZWdpc3RyeS9jb25maWcvc2VydmljZS9pbXBsL1NjaGVtYVJ1bGVQZXJzaXN0U2VydmljZS5qYXZh) | | |
   | [.../config/service/impl/GlobalRulePersistService.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZ292ZXJuYW5jZS9zaGFyZGluZ3NwaGVyZS1nb3Zlcm5hbmNlLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2dvdmVybmFuY2UvY29yZS9yZWdpc3RyeS9jb25maWcvc2VydmljZS9pbXBsL0dsb2JhbFJ1bGVQZXJzaXN0U2VydmljZS5qYXZh) | | |
   | ... and [13 more](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [e505462...2150feb](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on a change in pull request #11346: Add distSQL syntax: 'drop sharding algorithm'.

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on a change in pull request #11346:
URL: https://github.com/apache/shardingsphere/pull/11346#discussion_r670730035



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmStatementUpdater.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.rule.RuleDefinitionViolationException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
+import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
+import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingAlgorithmStatement;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.stream.Collectors;
+
+/**
+ * Drop sharding algorithm statement updater.
+ */
+public final class DropShardingAlgorithmStatementUpdater implements RuleDefinitionDropUpdater<DropShardingAlgorithmStatement, ShardingRuleConfiguration> {
+    
+    @Override
+    public void checkSQLStatement(final String schemaName, final DropShardingAlgorithmStatement sqlStatement, 
+                                  final ShardingRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws RuleDefinitionViolationException {
+        checkCurrentRuleConfiguration(schemaName, currentRuleConfig);
+        checkShardingAlgorithmsExisted(schemaName, sqlStatement, currentRuleConfig);
+        checkShardingAlgorithmsInUsed(schemaName, sqlStatement, currentRuleConfig);
+    }
+    
+    private void checkCurrentRuleConfiguration(final String schemaName, final ShardingRuleConfiguration currentRuleConfig) throws RequiredAlgorithmMissedException {
+        if (null == currentRuleConfig) {
+            throw new RequiredAlgorithmMissedException(schemaName);

Review comment:
       'shardingAlgorithms'  is part of the ‘ShardingRuleConfiguration’, it is not a rule itself, so I created RequiredAlgorithmMissedException.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] menghaoranss commented on a change in pull request #11346: Add distSQL syntax: 'drop sharding algorithm'.

Posted by GitBox <gi...@apache.org>.
menghaoranss commented on a change in pull request #11346:
URL: https://github.com/apache/shardingsphere/pull/11346#discussion_r670369266



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmStatementUpdater.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.rule.RuleDefinitionViolationException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
+import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
+import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingAlgorithmStatement;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.stream.Collectors;
+
+/**
+ * Drop sharding algorithm statement updater.
+ */
+public final class DropShardingAlgorithmStatementUpdater implements RuleDefinitionDropUpdater<DropShardingAlgorithmStatement, ShardingRuleConfiguration> {
+    
+    @Override
+    public void checkSQLStatement(final String schemaName, final DropShardingAlgorithmStatement sqlStatement, 
+                                  final ShardingRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws RuleDefinitionViolationException {
+        checkCurrentRuleConfiguration(schemaName, currentRuleConfig);
+        checkShardingAlgorithmsExisted(schemaName, sqlStatement, currentRuleConfig);
+        checkShardingAlgorithmsInUsed(schemaName, sqlStatement, currentRuleConfig);
+    }
+    
+    private void checkCurrentRuleConfiguration(final String schemaName, final ShardingRuleConfiguration currentRuleConfig) throws RequiredAlgorithmMissedException {
+        if (null == currentRuleConfig) {
+            throw new RequiredAlgorithmMissedException(schemaName);

Review comment:
       RequiredRuleMissedException should be thrown here

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmStatementUpdater.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.rule.RuleDefinitionViolationException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
+import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
+import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingAlgorithmStatement;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.stream.Collectors;
+
+/**
+ * Drop sharding algorithm statement updater.
+ */
+public final class DropShardingAlgorithmStatementUpdater implements RuleDefinitionDropUpdater<DropShardingAlgorithmStatement, ShardingRuleConfiguration> {
+    
+    @Override
+    public void checkSQLStatement(final String schemaName, final DropShardingAlgorithmStatement sqlStatement, 
+                                  final ShardingRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws RuleDefinitionViolationException {
+        checkCurrentRuleConfiguration(schemaName, currentRuleConfig);
+        checkShardingAlgorithmsExisted(schemaName, sqlStatement, currentRuleConfig);
+        checkShardingAlgorithmsInUsed(schemaName, sqlStatement, currentRuleConfig);
+    }
+    
+    private void checkCurrentRuleConfiguration(final String schemaName, final ShardingRuleConfiguration currentRuleConfig) throws RequiredAlgorithmMissedException {
+        if (null == currentRuleConfig) {
+            throw new RequiredAlgorithmMissedException(schemaName);
+        }
+    }
+    
+    private void checkShardingAlgorithmsExisted(final String schemaName, final DropShardingAlgorithmStatement sqlStatement,

Review comment:
       checkShardingAlgorithmsIsExisted is better?

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmStatementUpdater.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.rule.RuleDefinitionViolationException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
+import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
+import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingAlgorithmStatement;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.stream.Collectors;
+
+/**
+ * Drop sharding algorithm statement updater.
+ */
+public final class DropShardingAlgorithmStatementUpdater implements RuleDefinitionDropUpdater<DropShardingAlgorithmStatement, ShardingRuleConfiguration> {
+    
+    @Override
+    public void checkSQLStatement(final String schemaName, final DropShardingAlgorithmStatement sqlStatement, 
+                                  final ShardingRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws RuleDefinitionViolationException {
+        checkCurrentRuleConfiguration(schemaName, currentRuleConfig);
+        checkShardingAlgorithmsExisted(schemaName, sqlStatement, currentRuleConfig);
+        checkShardingAlgorithmsInUsed(schemaName, sqlStatement, currentRuleConfig);
+    }
+    
+    private void checkCurrentRuleConfiguration(final String schemaName, final ShardingRuleConfiguration currentRuleConfig) throws RequiredAlgorithmMissedException {
+        if (null == currentRuleConfig) {
+            throw new RequiredAlgorithmMissedException(schemaName);
+        }
+    }
+    
+    private void checkShardingAlgorithmsExisted(final String schemaName, final DropShardingAlgorithmStatement sqlStatement,
+                                                final ShardingRuleConfiguration currentRuleConfig) throws RequiredAlgorithmMissedException {
+        Collection<String> currentShardingAlgorithms = getCurrentShardingAlgorithms(currentRuleConfig);
+        Collection<String> notExistedAlgorithms = sqlStatement.getAlgorithmNames().stream().filter(each -> !currentShardingAlgorithms.contains(each)).collect(Collectors.toList());
+        if (!notExistedAlgorithms.isEmpty()) {
+            throw new RequiredAlgorithmMissedException(schemaName, notExistedAlgorithms);
+        }
+    }
+    
+    private void checkShardingAlgorithmsInUsed(final String schemaName, final DropShardingAlgorithmStatement sqlStatement, final ShardingRuleConfiguration currentRuleConfig) 

Review comment:
       checkShardingAlgorithmsIsInUsed

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmStatementUpdater.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.rule.RuleDefinitionViolationException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
+import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
+import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingAlgorithmStatement;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.stream.Collectors;
+
+/**
+ * Drop sharding algorithm statement updater.
+ */
+public final class DropShardingAlgorithmStatementUpdater implements RuleDefinitionDropUpdater<DropShardingAlgorithmStatement, ShardingRuleConfiguration> {
+    
+    @Override
+    public void checkSQLStatement(final String schemaName, final DropShardingAlgorithmStatement sqlStatement, 
+                                  final ShardingRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws RuleDefinitionViolationException {
+        checkCurrentRuleConfiguration(schemaName, currentRuleConfig);
+        checkShardingAlgorithmsExisted(schemaName, sqlStatement, currentRuleConfig);
+        checkShardingAlgorithmsInUsed(schemaName, sqlStatement, currentRuleConfig);
+    }
+    
+    private void checkCurrentRuleConfiguration(final String schemaName, final ShardingRuleConfiguration currentRuleConfig) throws RequiredAlgorithmMissedException {
+        if (null == currentRuleConfig) {
+            throw new RequiredAlgorithmMissedException(schemaName);
+        }
+    }
+    
+    private void checkShardingAlgorithmsExisted(final String schemaName, final DropShardingAlgorithmStatement sqlStatement,
+                                                final ShardingRuleConfiguration currentRuleConfig) throws RequiredAlgorithmMissedException {
+        Collection<String> currentShardingAlgorithms = getCurrentShardingAlgorithms(currentRuleConfig);
+        Collection<String> notExistedAlgorithms = sqlStatement.getAlgorithmNames().stream().filter(each -> !currentShardingAlgorithms.contains(each)).collect(Collectors.toList());
+        if (!notExistedAlgorithms.isEmpty()) {
+            throw new RequiredAlgorithmMissedException(schemaName, notExistedAlgorithms);
+        }
+    }
+    
+    private void checkShardingAlgorithmsInUsed(final String schemaName, final DropShardingAlgorithmStatement sqlStatement, final ShardingRuleConfiguration currentRuleConfig) 
+            throws AlgorithmInUsedException {
+        Collection<String> allInUsed = getAllOfAlgorithmsInUsed(currentRuleConfig);
+        Collection<String> usedAlgorithms = sqlStatement.getAlgorithmNames().stream().filter(allInUsed::contains).collect(Collectors.toList());
+        if (!usedAlgorithms.isEmpty()) {
+            throw new AlgorithmInUsedException(schemaName, usedAlgorithms);
+        }
+    }
+    
+    private Collection<String> getAllOfAlgorithmsInUsed(final ShardingRuleConfiguration shardingRuleConfig) {
+        Collection<String> result = new LinkedHashSet<>();
+        shardingRuleConfig.getTables().stream().forEach(each -> {
+            if (null != each.getDatabaseShardingStrategy()) {
+                result.add(each.getDatabaseShardingStrategy().getShardingAlgorithmName());
+            }
+            if (null != each.getTableShardingStrategy()) {
+                result.add(each.getTableShardingStrategy().getShardingAlgorithmName());
+            }
+        });
+        return result;
+    }
+    
+    private Collection<String> getCurrentShardingAlgorithms(final ShardingRuleConfiguration shardingRuleConfig) {
+        return shardingRuleConfig.getShardingAlgorithms().keySet();
+    }
+    
+    @Override
+    public boolean updateCurrentRuleConfiguration(final DropShardingAlgorithmStatement sqlStatement, final ShardingRuleConfiguration currentRuleConfig) {
+        for (String each : sqlStatement.getAlgorithmNames()) {
+            dropShardingAlgorithm(currentRuleConfig, each);
+        }
+        return false;

Review comment:
       should real result be returned here?

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmStatementUpdater.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.rule.RuleDefinitionViolationException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
+import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
+import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingAlgorithmStatement;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.stream.Collectors;
+
+/**
+ * Drop sharding algorithm statement updater.
+ */
+public final class DropShardingAlgorithmStatementUpdater implements RuleDefinitionDropUpdater<DropShardingAlgorithmStatement, ShardingRuleConfiguration> {
+    
+    @Override
+    public void checkSQLStatement(final String schemaName, final DropShardingAlgorithmStatement sqlStatement, 
+                                  final ShardingRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws RuleDefinitionViolationException {
+        checkCurrentRuleConfiguration(schemaName, currentRuleConfig);
+        checkShardingAlgorithmsExisted(schemaName, sqlStatement, currentRuleConfig);
+        checkShardingAlgorithmsInUsed(schemaName, sqlStatement, currentRuleConfig);
+    }
+    
+    private void checkCurrentRuleConfiguration(final String schemaName, final ShardingRuleConfiguration currentRuleConfig) throws RequiredAlgorithmMissedException {
+        if (null == currentRuleConfig) {
+            throw new RequiredAlgorithmMissedException(schemaName);
+        }
+    }
+    
+    private void checkShardingAlgorithmsExisted(final String schemaName, final DropShardingAlgorithmStatement sqlStatement,
+                                                final ShardingRuleConfiguration currentRuleConfig) throws RequiredAlgorithmMissedException {
+        Collection<String> currentShardingAlgorithms = getCurrentShardingAlgorithms(currentRuleConfig);
+        Collection<String> notExistedAlgorithms = sqlStatement.getAlgorithmNames().stream().filter(each -> !currentShardingAlgorithms.contains(each)).collect(Collectors.toList());
+        if (!notExistedAlgorithms.isEmpty()) {
+            throw new RequiredAlgorithmMissedException(schemaName, notExistedAlgorithms);
+        }
+    }
+    
+    private void checkShardingAlgorithmsInUsed(final String schemaName, final DropShardingAlgorithmStatement sqlStatement, final ShardingRuleConfiguration currentRuleConfig) 
+            throws AlgorithmInUsedException {
+        Collection<String> allInUsed = getAllOfAlgorithmsInUsed(currentRuleConfig);
+        Collection<String> usedAlgorithms = sqlStatement.getAlgorithmNames().stream().filter(allInUsed::contains).collect(Collectors.toList());
+        if (!usedAlgorithms.isEmpty()) {
+            throw new AlgorithmInUsedException(schemaName, usedAlgorithms);
+        }
+    }
+    
+    private Collection<String> getAllOfAlgorithmsInUsed(final ShardingRuleConfiguration shardingRuleConfig) {
+        Collection<String> result = new LinkedHashSet<>();
+        shardingRuleConfig.getTables().stream().forEach(each -> {

Review comment:
       autoTables in ShardingRuleConfiguration should also be added

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/RDLStatement.g4
##########
@@ -54,6 +54,10 @@ dropShardingBindingTableRules
 dropShardingBroadcastTableRules
     : DROP SHARDING BROADCAST TABLE RULES
     ;
+    
+dropShardingAlgorithm
+    : DROP SHARDING ALGORITHM algorithmName (COMMA algorithmName)*

Review comment:
       Does we need support `from schema`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] codecov-commenter edited a comment on pull request #11346: Add distSQL syntax: 'drop sharding algorithm'.

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #11346:
URL: https://github.com/apache/shardingsphere/pull/11346#issuecomment-880585974


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#11346](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b51c0c9) into [master](https://codecov.io/gh/apache/shardingsphere/commit/e50546265b8cdcb10300c6b7293bceb7402aaae1?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (e505462) will **increase** coverage by `0.00%`.
   > The diff coverage is `66.66%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/11346/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff            @@
   ##             master   #11346   +/-   ##
   =========================================
     Coverage     63.52%   63.53%           
   - Complexity     1028     1061   +33     
   =========================================
     Files          2216     2219    +3     
     Lines         33752    33793   +41     
     Branches       5896     5897    +1     
   =========================================
   + Hits          21441    21469   +28     
   - Misses        10605    10615   +10     
   - Partials       1706     1709    +3     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...l/parser/core/ShardingRuleSQLStatementVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctZGlzdHNxbC9zaGFyZGluZ3NwaGVyZS1zaGFyZGluZy1kaXN0c3FsLXBhcnNlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvZGlzdHNxbC9wYXJzZXIvY29yZS9TaGFyZGluZ1J1bGVTUUxTdGF0ZW1lbnRWaXNpdG9yLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...stsql/exception/rule/AlgorithmInUsedException.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kaXN0c3FsL2V4Y2VwdGlvbi9ydWxlL0FsZ29yaXRobUluVXNlZEV4Y2VwdGlvbi5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...ception/rule/RequiredAlgorithmMissedException.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kaXN0c3FsL2V4Y2VwdGlvbi9ydWxlL1JlcXVpcmVkQWxnb3JpdGhtTWlzc2VkRXhjZXB0aW9uLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [.../update/DropShardingAlgorithmStatementUpdater.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctZGlzdHNxbC9zaGFyZGluZ3NwaGVyZS1zaGFyZGluZy1kaXN0c3FsLWhhbmRsZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NoYXJkaW5nL2Rpc3RzcWwvaGFuZGxlci91cGRhdGUvRHJvcFNoYXJkaW5nQWxnb3JpdGhtU3RhdGVtZW50VXBkYXRlci5qYXZh) | `80.00% <80.00%> (ø)` | |
   | [...mmunication/jdbc/connection/BackendConnection.java](https://codecov.io/gh/apache/shardingsphere/pull/11346/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC9jb21tdW5pY2F0aW9uL2pkYmMvY29ubmVjdGlvbi9CYWNrZW5kQ29ubmVjdGlvbi5qYXZh) | `80.86% <0.00%> (+0.69%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [e505462...b51c0c9](https://codecov.io/gh/apache/shardingsphere/pull/11346?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on a change in pull request #11346: Add distSQL syntax: 'drop sharding algorithm'.

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on a change in pull request #11346:
URL: https://github.com/apache/shardingsphere/pull/11346#discussion_r670822599



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/RDLStatement.g4
##########
@@ -54,6 +54,10 @@ dropShardingBindingTableRules
 dropShardingBroadcastTableRules
     : DROP SHARDING BROADCAST TABLE RULES
     ;
+    
+dropShardingAlgorithm
+    : DROP SHARDING ALGORITHM algorithmName (COMMA algorithmName)*

Review comment:
       I don't think so.   'Sharding Algorithm' is part of sharding rule, and 'Drop Sharing Rule' does not support from schema yet.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on a change in pull request #11346: Add distSQL syntax: 'drop sharding algorithm'.

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on a change in pull request #11346:
URL: https://github.com/apache/shardingsphere/pull/11346#discussion_r671005410



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmStatementUpdater.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.rule.RuleDefinitionViolationException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
+import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
+import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingAlgorithmStatement;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.stream.Collectors;
+
+/**
+ * Drop sharding algorithm statement updater.
+ */
+public final class DropShardingAlgorithmStatementUpdater implements RuleDefinitionDropUpdater<DropShardingAlgorithmStatement, ShardingRuleConfiguration> {
+    
+    @Override
+    public void checkSQLStatement(final String schemaName, final DropShardingAlgorithmStatement sqlStatement, 
+                                  final ShardingRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws RuleDefinitionViolationException {
+        checkCurrentRuleConfiguration(schemaName, currentRuleConfig);
+        checkShardingAlgorithmsExisted(schemaName, sqlStatement, currentRuleConfig);
+        checkShardingAlgorithmsInUsed(schemaName, sqlStatement, currentRuleConfig);
+    }
+    
+    private void checkCurrentRuleConfiguration(final String schemaName, final ShardingRuleConfiguration currentRuleConfig) throws RequiredAlgorithmMissedException {
+        if (null == currentRuleConfig) {
+            throw new RequiredAlgorithmMissedException(schemaName);
+        }
+    }
+    
+    private void checkShardingAlgorithmsExisted(final String schemaName, final DropShardingAlgorithmStatement sqlStatement,

Review comment:
       Finally, I change it to `checkToBeDroppedShardingAlgorithms`, like the `checkToBeDroppedShardingTableNames` int `DropShardingTableRuleStatementUpdater`, is it OK?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on a change in pull request #11346: Add distSQL syntax: 'drop sharding algorithm'.

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on a change in pull request #11346:
URL: https://github.com/apache/shardingsphere/pull/11346#discussion_r670821274



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmStatementUpdater.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.rule.RuleDefinitionViolationException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
+import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
+import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingAlgorithmStatement;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.stream.Collectors;
+
+/**
+ * Drop sharding algorithm statement updater.
+ */
+public final class DropShardingAlgorithmStatementUpdater implements RuleDefinitionDropUpdater<DropShardingAlgorithmStatement, ShardingRuleConfiguration> {
+    
+    @Override
+    public void checkSQLStatement(final String schemaName, final DropShardingAlgorithmStatement sqlStatement, 
+                                  final ShardingRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws RuleDefinitionViolationException {
+        checkCurrentRuleConfiguration(schemaName, currentRuleConfig);
+        checkShardingAlgorithmsExisted(schemaName, sqlStatement, currentRuleConfig);
+        checkShardingAlgorithmsInUsed(schemaName, sqlStatement, currentRuleConfig);
+    }
+    
+    private void checkCurrentRuleConfiguration(final String schemaName, final ShardingRuleConfiguration currentRuleConfig) throws RequiredAlgorithmMissedException {
+        if (null == currentRuleConfig) {
+            throw new RequiredAlgorithmMissedException(schemaName);
+        }
+    }
+    
+    private void checkShardingAlgorithmsExisted(final String schemaName, final DropShardingAlgorithmStatement sqlStatement,
+                                                final ShardingRuleConfiguration currentRuleConfig) throws RequiredAlgorithmMissedException {
+        Collection<String> currentShardingAlgorithms = getCurrentShardingAlgorithms(currentRuleConfig);
+        Collection<String> notExistedAlgorithms = sqlStatement.getAlgorithmNames().stream().filter(each -> !currentShardingAlgorithms.contains(each)).collect(Collectors.toList());
+        if (!notExistedAlgorithms.isEmpty()) {
+            throw new RequiredAlgorithmMissedException(schemaName, notExistedAlgorithms);
+        }
+    }
+    
+    private void checkShardingAlgorithmsInUsed(final String schemaName, final DropShardingAlgorithmStatement sqlStatement, final ShardingRuleConfiguration currentRuleConfig) 
+            throws AlgorithmInUsedException {
+        Collection<String> allInUsed = getAllOfAlgorithmsInUsed(currentRuleConfig);
+        Collection<String> usedAlgorithms = sqlStatement.getAlgorithmNames().stream().filter(allInUsed::contains).collect(Collectors.toList());
+        if (!usedAlgorithms.isEmpty()) {
+            throw new AlgorithmInUsedException(schemaName, usedAlgorithms);
+        }
+    }
+    
+    private Collection<String> getAllOfAlgorithmsInUsed(final ShardingRuleConfiguration shardingRuleConfig) {
+        Collection<String> result = new LinkedHashSet<>();
+        shardingRuleConfig.getTables().stream().forEach(each -> {
+            if (null != each.getDatabaseShardingStrategy()) {
+                result.add(each.getDatabaseShardingStrategy().getShardingAlgorithmName());
+            }
+            if (null != each.getTableShardingStrategy()) {
+                result.add(each.getTableShardingStrategy().getShardingAlgorithmName());
+            }
+        });
+        return result;
+    }
+    
+    private Collection<String> getCurrentShardingAlgorithms(final ShardingRuleConfiguration shardingRuleConfig) {
+        return shardingRuleConfig.getShardingAlgorithms().keySet();
+    }
+    
+    @Override
+    public boolean updateCurrentRuleConfiguration(final DropShardingAlgorithmStatement sqlStatement, final ShardingRuleConfiguration currentRuleConfig) {
+        for (String each : sqlStatement.getAlgorithmNames()) {
+            dropShardingAlgorithm(currentRuleConfig, each);
+        }
+        return false;

Review comment:
       refer to `DropShardingTableRuleStatementUpdater` and `DropShardingBindingTableRuleStatementUpdater`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on a change in pull request #11346: Add distSQL syntax: 'drop sharding algorithm'.

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on a change in pull request #11346:
URL: https://github.com/apache/shardingsphere/pull/11346#discussion_r670730783



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmStatementUpdater.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.rule.RuleDefinitionViolationException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
+import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
+import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingAlgorithmStatement;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.stream.Collectors;
+
+/**
+ * Drop sharding algorithm statement updater.
+ */
+public final class DropShardingAlgorithmStatementUpdater implements RuleDefinitionDropUpdater<DropShardingAlgorithmStatement, ShardingRuleConfiguration> {
+    
+    @Override
+    public void checkSQLStatement(final String schemaName, final DropShardingAlgorithmStatement sqlStatement, 
+                                  final ShardingRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws RuleDefinitionViolationException {
+        checkCurrentRuleConfiguration(schemaName, currentRuleConfig);
+        checkShardingAlgorithmsExisted(schemaName, sqlStatement, currentRuleConfig);
+        checkShardingAlgorithmsInUsed(schemaName, sqlStatement, currentRuleConfig);
+    }
+    
+    private void checkCurrentRuleConfiguration(final String schemaName, final ShardingRuleConfiguration currentRuleConfig) throws RequiredAlgorithmMissedException {
+        if (null == currentRuleConfig) {
+            throw new RequiredAlgorithmMissedException(schemaName);
+        }
+    }
+    
+    private void checkShardingAlgorithmsExisted(final String schemaName, final DropShardingAlgorithmStatement sqlStatement,
+                                                final ShardingRuleConfiguration currentRuleConfig) throws RequiredAlgorithmMissedException {
+        Collection<String> currentShardingAlgorithms = getCurrentShardingAlgorithms(currentRuleConfig);
+        Collection<String> notExistedAlgorithms = sqlStatement.getAlgorithmNames().stream().filter(each -> !currentShardingAlgorithms.contains(each)).collect(Collectors.toList());
+        if (!notExistedAlgorithms.isEmpty()) {
+            throw new RequiredAlgorithmMissedException(schemaName, notExistedAlgorithms);
+        }
+    }
+    
+    private void checkShardingAlgorithmsInUsed(final String schemaName, final DropShardingAlgorithmStatement sqlStatement, final ShardingRuleConfiguration currentRuleConfig) 
+            throws AlgorithmInUsedException {
+        Collection<String> allInUsed = getAllOfAlgorithmsInUsed(currentRuleConfig);
+        Collection<String> usedAlgorithms = sqlStatement.getAlgorithmNames().stream().filter(allInUsed::contains).collect(Collectors.toList());
+        if (!usedAlgorithms.isEmpty()) {
+            throw new AlgorithmInUsedException(schemaName, usedAlgorithms);
+        }
+    }
+    
+    private Collection<String> getAllOfAlgorithmsInUsed(final ShardingRuleConfiguration shardingRuleConfig) {
+        Collection<String> result = new LinkedHashSet<>();
+        shardingRuleConfig.getTables().stream().forEach(each -> {

Review comment:
       Good idea 👍 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] menghaoranss commented on a change in pull request #11346: Add distSQL syntax: 'drop sharding algorithm'.

Posted by GitBox <gi...@apache.org>.
menghaoranss commented on a change in pull request #11346:
URL: https://github.com/apache/shardingsphere/pull/11346#discussion_r670384372



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/RDLStatement.g4
##########
@@ -54,6 +54,10 @@ dropShardingBindingTableRules
 dropShardingBroadcastTableRules
     : DROP SHARDING BROADCAST TABLE RULES
     ;
+    
+dropShardingAlgorithm
+    : DROP SHARDING ALGORITHM algorithmName (COMMA algorithmName)*

Review comment:
       Do we need support `from schema`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on a change in pull request #11346: Add distSQL syntax: 'drop sharding algorithm'.

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on a change in pull request #11346:
URL: https://github.com/apache/shardingsphere/pull/11346#discussion_r670811041



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmStatementUpdater.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.rule.RuleDefinitionViolationException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.RequiredAlgorithmMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.AlgorithmInUsedException;
+import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
+import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
+import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingAlgorithmStatement;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.stream.Collectors;
+
+/**
+ * Drop sharding algorithm statement updater.
+ */
+public final class DropShardingAlgorithmStatementUpdater implements RuleDefinitionDropUpdater<DropShardingAlgorithmStatement, ShardingRuleConfiguration> {
+    
+    @Override
+    public void checkSQLStatement(final String schemaName, final DropShardingAlgorithmStatement sqlStatement, 
+                                  final ShardingRuleConfiguration currentRuleConfig, final ShardingSphereResource resource) throws RuleDefinitionViolationException {
+        checkCurrentRuleConfiguration(schemaName, currentRuleConfig);
+        checkShardingAlgorithmsExisted(schemaName, sqlStatement, currentRuleConfig);
+        checkShardingAlgorithmsInUsed(schemaName, sqlStatement, currentRuleConfig);
+    }
+    
+    private void checkCurrentRuleConfiguration(final String schemaName, final ShardingRuleConfiguration currentRuleConfig) throws RequiredAlgorithmMissedException {
+        if (null == currentRuleConfig) {
+            throw new RequiredAlgorithmMissedException(schemaName);
+        }
+    }
+    
+    private void checkShardingAlgorithmsExisted(final String schemaName, final DropShardingAlgorithmStatement sqlStatement,
+                                                final ShardingRuleConfiguration currentRuleConfig) throws RequiredAlgorithmMissedException {
+        Collection<String> currentShardingAlgorithms = getCurrentShardingAlgorithms(currentRuleConfig);
+        Collection<String> notExistedAlgorithms = sqlStatement.getAlgorithmNames().stream().filter(each -> !currentShardingAlgorithms.contains(each)).collect(Collectors.toList());
+        if (!notExistedAlgorithms.isEmpty()) {
+            throw new RequiredAlgorithmMissedException(schemaName, notExistedAlgorithms);
+        }
+    }
+    
+    private void checkShardingAlgorithmsInUsed(final String schemaName, final DropShardingAlgorithmStatement sqlStatement, final ShardingRuleConfiguration currentRuleConfig) 

Review comment:
       Plural form too.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org