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 2022/03/24 10:58:39 UTC
[GitHub] [shardingsphere] yx9o opened a new pull request #16341: Add more validation to `import` syntax.
yx9o opened a new pull request #16341:
URL: https://github.com/apache/shardingsphere/pull/16341
Add import `ShardingRuleConfiguration` configuration check.

--
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 merged pull request #16341: Add more validation to `import` syntax.
Posted by GitBox <gi...@apache.org>.
RaigorJiang merged pull request #16341:
URL: https://github.com/apache/shardingsphere/pull/16341
--
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 #16341: Add more validation to `import` syntax.
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #16341:
URL: https://github.com/apache/shardingsphere/pull/16341#issuecomment-1077983921
# [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/16341?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 [#16341](https://codecov.io/gh/apache/shardingsphere/pull/16341?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (0e87c4a) into [master](https://codecov.io/gh/apache/shardingsphere/commit/7ea2b4a908df350a0bf4f125895699038e05b412?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (7ea2b4a) will **decrease** coverage by `0.03%`.
> The diff coverage is `25.60%`.
```diff
@@ Coverage Diff @@
## master #16341 +/- ##
============================================
- Coverage 60.79% 60.76% -0.04%
- Complexity 2076 2077 +1
============================================
Files 3306 3311 +5
Lines 49992 50075 +83
Branches 8587 8589 +2
============================================
+ Hits 30395 30430 +35
- Misses 17048 17094 +46
- Partials 2549 2551 +2
```
| [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/16341?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...on/resource/ImportResourceNotExistedException.java](https://codecov.io/gh/apache/shardingsphere/pull/16341/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kaXN0c3FsL2V4Y2VwdGlvbi9yZXNvdXJjZS9JbXBvcnRSZXNvdXJjZU5vdEV4aXN0ZWRFeGNlcHRpb24uamF2YQ==) | `0.00% <0.00%> (ø)` | |
| [...ql/exception/rule/DuplicateAlgorithmException.java](https://codecov.io/gh/apache/shardingsphere/pull/16341/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kaXN0c3FsL2V4Y2VwdGlvbi9ydWxlL0R1cGxpY2F0ZUFsZ29yaXRobUV4Y2VwdGlvbi5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...fra/exception/ImportSchemaNotExistedException.java](https://codecov.io/gh/apache/shardingsphere/pull/16341/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9leGNlcHRpb24vSW1wb3J0U2NoZW1hTm90RXhpc3RlZEV4Y2VwdGlvbi5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...mmon/checker/ShardingRuleConfigurationChecker.java](https://codecov.io/gh/apache/shardingsphere/pull/16341/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-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC90ZXh0L2Rpc3RzcWwvcmFsL2NvbW1vbi9jaGVja2VyL1NoYXJkaW5nUnVsZUNvbmZpZ3VyYXRpb25DaGVja2VyLmphdmE=) | `10.63% <10.63%> (ø)` | |
| [...on/updatable/ImportSchemaConfigurationHandler.java](https://codecov.io/gh/apache/shardingsphere/pull/16341/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-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC90ZXh0L2Rpc3RzcWwvcmFsL2NvbW1vbi91cGRhdGFibGUvSW1wb3J0U2NoZW1hQ29uZmlndXJhdGlvbkhhbmRsZXIuamF2YQ==) | `57.35% <55.17%> (+3.11%)` | :arrow_up: |
| [...ling/update/UpdatableScalingRALBackendHandler.java](https://codecov.io/gh/apache/shardingsphere/pull/16341/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-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC90ZXh0L2Rpc3RzcWwvcmFsL3NjYWxpbmcvdXBkYXRlL1VwZGF0YWJsZVNjYWxpbmdSQUxCYWNrZW5kSGFuZGxlci5qYXZh) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...date/UpdatableScalingRALBackendHandlerFactory.java](https://codecov.io/gh/apache/shardingsphere/pull/16341/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-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC90ZXh0L2Rpc3RzcWwvcmFsL3NjYWxpbmcvdXBkYXRlL1VwZGF0YWJsZVNjYWxpbmdSQUxCYWNrZW5kSGFuZGxlckZhY3RvcnkuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...end/text/distsql/ral/RALBackendHandlerFactory.java](https://codecov.io/gh/apache/shardingsphere/pull/16341/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-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC90ZXh0L2Rpc3RzcWwvcmFsL1JBTEJhY2tlbmRIYW5kbGVyRmFjdG9yeS5qYXZh) | `89.09% <0.00%> (-3.64%)` | :arrow_down: |
| [.../mode/metadata/persist/MetaDataPersistService.java](https://codecov.io/gh/apache/shardingsphere/pull/16341/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-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL21vZGUvbWV0YWRhdGEvcGVyc2lzdC9NZXRhRGF0YVBlcnNpc3RTZXJ2aWNlLmphdmE=) | `59.18% <0.00%> (-2.52%)` | :arrow_down: |
| [.../manager/cluster/ClusterContextManagerBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/16341/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-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLXR5cGUvc2hhcmRpbmdzcGhlcmUtY2x1c3Rlci1tb2RlL3NoYXJkaW5nc3BoZXJlLWNsdXN0ZXItbW9kZS1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9tb2RlL21hbmFnZXIvY2x1c3Rlci9DbHVzdGVyQ29udGV4dE1hbmFnZXJCdWlsZGVyLmphdmE=) | `62.65% <0.00%> (-0.45%)` | :arrow_down: |
| ... and [15 more](https://codecov.io/gh/apache/shardingsphere/pull/16341/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/16341?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/16341?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 [7ea2b4a...0e87c4a](https://codecov.io/gh/apache/shardingsphere/pull/16341?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 #16341: Add more validation to `import` syntax.
Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on a change in pull request #16341:
URL: https://github.com/apache/shardingsphere/pull/16341#discussion_r834901127
##########
File path: shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/checker/ShardingRuleConfigurationChecker.java
##########
@@ -0,0 +1,138 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.checker;
+
+import org.apache.shardingsphere.infra.config.TypedSPIConfiguration;
+import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithm;
+import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.datanode.DataNode;
+import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
+import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
+import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
+import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
+import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
+import org.apache.shardingsphere.sharding.support.InlineExpressionParser;
+import org.apache.shardingsphere.spi.typed.TypedSPIRegistry;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Sharding rule configuration checker.
+ */
+public final class ShardingRuleConfigurationChecker {
+
+ private static final String SHARDING = "sharding";
+
+ private static final String KEY_GENERATOR = "key generator";
+
+ private static final Map<String, Class<? extends ShardingSphereAlgorithm>> ALGORITHM_TYPE_MAP = new HashMap<>(2, 1);
+
+ static {
+ ALGORITHM_TYPE_MAP.put(SHARDING, ShardingAlgorithm.class);
+ ALGORITHM_TYPE_MAP.put(KEY_GENERATOR, KeyGenerateAlgorithm.class);
+ }
+
+ /**
+ * Check sharding rule configuration.
+ *
+ * @param shardingSphereMetaData ShardingSphere meta data
+ * @param currentRuleConfig current rule configuration
+ * @throws DistSQLException definition violation exception
+ */
+ public void check(final ShardingSphereMetaData shardingSphereMetaData, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
+ if (null == shardingSphereMetaData || null == currentRuleConfig) {
+ return;
+ }
+ String schemaName = shardingSphereMetaData.getName();
+ checkLogicTables(schemaName, currentRuleConfig);
+ checkResources(schemaName, shardingSphereMetaData, currentRuleConfig);
+ checkKeyGenerators(currentRuleConfig);
+ checkShardingAlgorithms(currentRuleConfig);
+ }
+
+ private void checkLogicTables(final String schemaName, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
+ LinkedList<String> tablesLogicTables = currentRuleConfig.getTables().stream().map(ShardingTableRuleConfiguration::getLogicTable).collect(Collectors.toCollection(LinkedList::new));
Review comment:
Can `LinkedList<String>` be changed to `Collection<String>`?
--
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 #16341: Add more validation to `import` syntax.
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #16341:
URL: https://github.com/apache/shardingsphere/pull/16341#issuecomment-1077983921
# [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/16341?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 [#16341](https://codecov.io/gh/apache/shardingsphere/pull/16341?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (1583fcb) into [master](https://codecov.io/gh/apache/shardingsphere/commit/0590586192da9728e82de120ee5edd5d177a0042?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (0590586) will **decrease** coverage by `0.04%`.
> The diff coverage is `25.60%`.
```diff
@@ Coverage Diff @@
## master #16341 +/- ##
============================================
- Coverage 60.81% 60.76% -0.05%
- Complexity 2076 2077 +1
============================================
Files 3307 3311 +4
Lines 50012 50068 +56
Branches 8586 8587 +1
============================================
+ Hits 30414 30426 +12
- Misses 17046 17091 +45
+ Partials 2552 2551 -1
```
| [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/16341?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...on/resource/ImportResourceNotExistedException.java](https://codecov.io/gh/apache/shardingsphere/pull/16341/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kaXN0c3FsL2V4Y2VwdGlvbi9yZXNvdXJjZS9JbXBvcnRSZXNvdXJjZU5vdEV4aXN0ZWRFeGNlcHRpb24uamF2YQ==) | `0.00% <0.00%> (ø)` | |
| [...ql/exception/rule/DuplicateAlgorithmException.java](https://codecov.io/gh/apache/shardingsphere/pull/16341/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kaXN0c3FsL2V4Y2VwdGlvbi9ydWxlL0R1cGxpY2F0ZUFsZ29yaXRobUV4Y2VwdGlvbi5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...fra/exception/ImportSchemaNotExistedException.java](https://codecov.io/gh/apache/shardingsphere/pull/16341/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9leGNlcHRpb24vSW1wb3J0U2NoZW1hTm90RXhpc3RlZEV4Y2VwdGlvbi5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...mmon/checker/ShardingRuleConfigurationChecker.java](https://codecov.io/gh/apache/shardingsphere/pull/16341/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-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC90ZXh0L2Rpc3RzcWwvcmFsL2NvbW1vbi9jaGVja2VyL1NoYXJkaW5nUnVsZUNvbmZpZ3VyYXRpb25DaGVja2VyLmphdmE=) | `10.63% <10.63%> (ø)` | |
| [...on/updatable/ImportSchemaConfigurationHandler.java](https://codecov.io/gh/apache/shardingsphere/pull/16341/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-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC90ZXh0L2Rpc3RzcWwvcmFsL2NvbW1vbi91cGRhdGFibGUvSW1wb3J0U2NoZW1hQ29uZmlndXJhdGlvbkhhbmRsZXIuamF2YQ==) | `57.35% <55.17%> (+3.11%)` | :arrow_up: |
| [...sql/ral/common/updatable/AlterInstanceHandler.java](https://codecov.io/gh/apache/shardingsphere/pull/16341/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-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC90ZXh0L2Rpc3RzcWwvcmFsL2NvbW1vbi91cGRhdGFibGUvQWx0ZXJJbnN0YW5jZUhhbmRsZXIuamF2YQ==) | `0.00% <0.00%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/16341?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/16341?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 [0590586...1583fcb](https://codecov.io/gh/apache/shardingsphere/pull/16341?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] yx9o commented on a change in pull request #16341: Add more validation to `import` syntax.
Posted by GitBox <gi...@apache.org>.
yx9o commented on a change in pull request #16341:
URL: https://github.com/apache/shardingsphere/pull/16341#discussion_r834941669
##########
File path: shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/checker/ShardingRuleConfigurationChecker.java
##########
@@ -0,0 +1,138 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.checker;
+
+import org.apache.shardingsphere.infra.config.TypedSPIConfiguration;
+import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithm;
+import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.datanode.DataNode;
+import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
+import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
+import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
+import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
+import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
+import org.apache.shardingsphere.sharding.support.InlineExpressionParser;
+import org.apache.shardingsphere.spi.typed.TypedSPIRegistry;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Sharding rule configuration checker.
+ */
+public final class ShardingRuleConfigurationChecker {
+
+ private static final String SHARDING = "sharding";
+
+ private static final String KEY_GENERATOR = "key generator";
+
+ private static final Map<String, Class<? extends ShardingSphereAlgorithm>> ALGORITHM_TYPE_MAP = new HashMap<>(2, 1);
+
+ static {
+ ALGORITHM_TYPE_MAP.put(SHARDING, ShardingAlgorithm.class);
+ ALGORITHM_TYPE_MAP.put(KEY_GENERATOR, KeyGenerateAlgorithm.class);
+ }
+
+ /**
+ * Check sharding rule configuration.
+ *
+ * @param shardingSphereMetaData ShardingSphere meta data
+ * @param currentRuleConfig current rule configuration
+ * @throws DistSQLException definition violation exception
+ */
+ public void check(final ShardingSphereMetaData shardingSphereMetaData, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
+ if (null == shardingSphereMetaData || null == currentRuleConfig) {
+ return;
+ }
+ String schemaName = shardingSphereMetaData.getName();
+ checkLogicTables(schemaName, currentRuleConfig);
+ checkResources(schemaName, shardingSphereMetaData, currentRuleConfig);
+ checkKeyGenerators(currentRuleConfig);
+ checkShardingAlgorithms(currentRuleConfig);
+ }
+
+ private void checkLogicTables(final String schemaName, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
+ LinkedList<String> tablesLogicTables = currentRuleConfig.getTables().stream().map(ShardingTableRuleConfiguration::getLogicTable).collect(Collectors.toCollection(LinkedList::new));
Review comment:
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 #16341: Add more validation to `import` syntax.
Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on a change in pull request #16341:
URL: https://github.com/apache/shardingsphere/pull/16341#discussion_r834901292
##########
File path: shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/checker/ShardingRuleConfigurationChecker.java
##########
@@ -0,0 +1,138 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.checker;
+
+import org.apache.shardingsphere.infra.config.TypedSPIConfiguration;
+import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithm;
+import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.datanode.DataNode;
+import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
+import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.DuplicateRuleException;
+import org.apache.shardingsphere.infra.distsql.exception.rule.InvalidAlgorithmConfigurationException;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
+import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
+import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
+import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
+import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
+import org.apache.shardingsphere.sharding.support.InlineExpressionParser;
+import org.apache.shardingsphere.spi.typed.TypedSPIRegistry;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Sharding rule configuration checker.
+ */
+public final class ShardingRuleConfigurationChecker {
+
+ private static final String SHARDING = "sharding";
+
+ private static final String KEY_GENERATOR = "key generator";
+
+ private static final Map<String, Class<? extends ShardingSphereAlgorithm>> ALGORITHM_TYPE_MAP = new HashMap<>(2, 1);
+
+ static {
+ ALGORITHM_TYPE_MAP.put(SHARDING, ShardingAlgorithm.class);
+ ALGORITHM_TYPE_MAP.put(KEY_GENERATOR, KeyGenerateAlgorithm.class);
+ }
+
+ /**
+ * Check sharding rule configuration.
+ *
+ * @param shardingSphereMetaData ShardingSphere meta data
+ * @param currentRuleConfig current rule configuration
+ * @throws DistSQLException definition violation exception
+ */
+ public void check(final ShardingSphereMetaData shardingSphereMetaData, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
+ if (null == shardingSphereMetaData || null == currentRuleConfig) {
+ return;
+ }
+ String schemaName = shardingSphereMetaData.getName();
+ checkLogicTables(schemaName, currentRuleConfig);
+ checkResources(schemaName, shardingSphereMetaData, currentRuleConfig);
+ checkKeyGenerators(currentRuleConfig);
+ checkShardingAlgorithms(currentRuleConfig);
+ }
+
+ private void checkLogicTables(final String schemaName, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
+ LinkedList<String> tablesLogicTables = currentRuleConfig.getTables().stream().map(ShardingTableRuleConfiguration::getLogicTable).collect(Collectors.toCollection(LinkedList::new));
+ LinkedList<String> autoTablesLogicTables = currentRuleConfig.getAutoTables().stream().map(ShardingAutoTableRuleConfiguration::getLogicTable).collect(Collectors.toCollection(LinkedList::new));
+ LinkedList<String> allLogicTables = new LinkedList<>();
+ allLogicTables.addAll(tablesLogicTables);
+ allLogicTables.addAll(autoTablesLogicTables);
+ Set<String> duplicatedLogicTables = allLogicTables.stream().collect(Collectors.groupingBy(each -> each, Collectors.counting())).entrySet().stream()
+ .filter(each -> each.getValue() > 1).map(Map.Entry::getKey).collect(Collectors.toSet());
+ DistSQLException.predictionThrow(duplicatedLogicTables.isEmpty(), () -> new DuplicateRuleException(SHARDING, schemaName, duplicatedLogicTables));
+ }
+
+ private void checkShardingAlgorithms(final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
+ checkInvalidAlgorithms(SHARDING, currentRuleConfig.getShardingAlgorithms().values());
+ }
+
+ private void checkKeyGenerators(final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
+ checkInvalidAlgorithms(KEY_GENERATOR, currentRuleConfig.getKeyGenerators().values());
+ }
+
+ private void checkInvalidAlgorithms(final String algorithmType, final Collection<ShardingSphereAlgorithmConfiguration> algorithmConfigurations) throws DistSQLException {
+ Collection<String> invalidAlgorithms = algorithmConfigurations.stream()
+ .filter(each -> !TypedSPIRegistry.findRegisteredService(ALGORITHM_TYPE_MAP.get(algorithmType), each.getType(), new Properties()).isPresent())
+ .map(TypedSPIConfiguration::getType).collect(Collectors.toList());
+ DistSQLException.predictionThrow(invalidAlgorithms.isEmpty(), () -> new InvalidAlgorithmConfigurationException(algorithmType, invalidAlgorithms));
+ }
+
+ private Collection<String> getRequiredResources(final ShardingRuleConfiguration currentRuleConfig) {
+ Collection<String> result = new LinkedHashSet<>();
+ currentRuleConfig.getTables().forEach(each -> result.addAll(getDataSourceNames(each)));
+ currentRuleConfig.getAutoTables().forEach(each -> result.addAll(getDataSourceNames(each)));
+ return result;
+ }
+
+ private Collection<String> getDataSourceNames(final ShardingAutoTableRuleConfiguration shardingAutoTableRuleConfig) {
+ List<String> actualDataSources = new InlineExpressionParser(shardingAutoTableRuleConfig.getActualDataSources()).splitAndEvaluate();
Review comment:
Collection
--
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 #16341: Add more validation to `import` syntax.
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #16341:
URL: https://github.com/apache/shardingsphere/pull/16341#issuecomment-1077983921
# [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/16341?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 [#16341](https://codecov.io/gh/apache/shardingsphere/pull/16341?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b946ac7) into [master](https://codecov.io/gh/apache/shardingsphere/commit/588840832925d4e90c825c536e8573886f362871?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (5888408) will **decrease** coverage by `0.05%`.
> The diff coverage is `25.60%`.
```diff
@@ Coverage Diff @@
## master #16341 +/- ##
============================================
- Coverage 60.83% 60.77% -0.06%
- Complexity 2076 2077 +1
============================================
Files 3307 3311 +4
Lines 50002 50064 +62
Branches 8583 8586 +3
============================================
+ Hits 30417 30426 +9
- Misses 17033 17087 +54
+ Partials 2552 2551 -1
```
| [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/16341?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...on/resource/ImportResourceNotExistedException.java](https://codecov.io/gh/apache/shardingsphere/pull/16341/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kaXN0c3FsL2V4Y2VwdGlvbi9yZXNvdXJjZS9JbXBvcnRSZXNvdXJjZU5vdEV4aXN0ZWRFeGNlcHRpb24uamF2YQ==) | `0.00% <0.00%> (ø)` | |
| [...ql/exception/rule/DuplicateAlgorithmException.java](https://codecov.io/gh/apache/shardingsphere/pull/16341/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kaXN0c3FsL2V4Y2VwdGlvbi9ydWxlL0R1cGxpY2F0ZUFsZ29yaXRobUV4Y2VwdGlvbi5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...fra/exception/ImportSchemaNotExistedException.java](https://codecov.io/gh/apache/shardingsphere/pull/16341/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9leGNlcHRpb24vSW1wb3J0U2NoZW1hTm90RXhpc3RlZEV4Y2VwdGlvbi5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...mmon/checker/ShardingRuleConfigurationChecker.java](https://codecov.io/gh/apache/shardingsphere/pull/16341/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-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC90ZXh0L2Rpc3RzcWwvcmFsL2NvbW1vbi9jaGVja2VyL1NoYXJkaW5nUnVsZUNvbmZpZ3VyYXRpb25DaGVja2VyLmphdmE=) | `10.63% <10.63%> (ø)` | |
| [...on/updatable/ImportSchemaConfigurationHandler.java](https://codecov.io/gh/apache/shardingsphere/pull/16341/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-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC90ZXh0L2Rpc3RzcWwvcmFsL2NvbW1vbi91cGRhdGFibGUvSW1wb3J0U2NoZW1hQ29uZmlndXJhdGlvbkhhbmRsZXIuamF2YQ==) | `57.35% <55.17%> (+3.11%)` | :arrow_up: |
| [...d/text/distsql/ral/common/hint/HintSourceType.java](https://codecov.io/gh/apache/shardingsphere/pull/16341/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-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC90ZXh0L2Rpc3RzcWwvcmFsL2NvbW1vbi9oaW50L0hpbnRTb3VyY2VUeXBlLmphdmE=) | `0.00% <0.00%> (-42.86%)` | :arrow_down: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/16341?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/16341?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 [5888408...b946ac7](https://codecov.io/gh/apache/shardingsphere/pull/16341?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