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/01/18 10:23:25 UTC

[GitHub] [shardingsphere] cheese8 opened a new pull request #14864: validate whether the sharding rules of the binding tables are consistent

cheese8 opened a new pull request #14864:
URL: https://github.com/apache/shardingsphere/pull/14864


   Ref  #13596.
   
   Changes proposed in this pull request:
   - checkTheSameActualDataSourceNames per  bindingTableGroup while createBindingTableRule
   - checkTheSameDatabaseShardingStrategy per  bindingTableGroup while createBindingTableRule
   - checkTheSameTableShardingStrategy per  bindingTableGroup while createBindingTableRule
   


-- 
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 #14864: validate whether the sharding rules of the binding tables are consistent

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


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/14864?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 [#14864](https://codecov.io/gh/apache/shardingsphere/pull/14864?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (76be10c) into [master](https://codecov.io/gh/apache/shardingsphere/commit/522c4385238c2905f03f43cba17ac737d95756e2?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (522c438) will **increase** coverage by `0.08%`.
   > The diff coverage is `75.00%`.
   
   > :exclamation: Current head 76be10c differs from pull request most recent head c909fbd. Consider uploading reports for the commit c909fbd to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/14864/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/14864?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   #14864      +/-   ##
   ============================================
   + Coverage     59.00%   59.09%   +0.08%     
   - Complexity     1852     1870      +18     
   ============================================
     Files          3114     3131      +17     
     Lines         46637    46735      +98     
     Branches       7909     7924      +15     
   ============================================
   + Hits          27520    27619      +99     
   + Misses        16944    16938       -6     
   - Partials       2173     2178       +5     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/14864?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...che/shardingsphere/sharding/rule/ShardingRule.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvcnVsZS9TaGFyZGluZ1J1bGUuamF2YQ==) | `78.12% <75.00%> (-0.85%)` | :arrow_down: |
   | [...extended/execute/PostgreSQLComExecuteExecutor.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktZnJvbnRlbmQvc2hhcmRpbmdzcGhlcmUtcHJveHktZnJvbnRlbmQtcG9zdGdyZXNxbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvZnJvbnRlbmQvcG9zdGdyZXNxbC9jb21tYW5kL3F1ZXJ5L2V4dGVuZGVkL2V4ZWN1dGUvUG9zdGdyZVNRTENvbUV4ZWN1dGVFeGVjdXRvci5qYXZh) | `83.33% <0.00%> (-13.34%)` | :arrow_down: |
   | [...ng/algorithm/keygen/CosIdKeyGenerateAlgorithm.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvYWxnb3JpdGhtL2tleWdlbi9Db3NJZEtleUdlbmVyYXRlQWxnb3JpdGhtLmphdmE=) | `78.57% <0.00%> (-13.10%)` | :arrow_down: |
   | [...ostgresql/command/PostgreSQLConnectionContext.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktZnJvbnRlbmQvc2hhcmRpbmdzcGhlcmUtcHJveHktZnJvbnRlbmQtcG9zdGdyZXNxbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvZnJvbnRlbmQvcG9zdGdyZXNxbC9jb21tYW5kL1Bvc3RncmVTUUxDb25uZWN0aW9uQ29udGV4dC5qYXZh) | `84.21% <0.00%> (-11.45%)` | :arrow_down: |
   | [...shardingsphere/sharding/rule/BindingTableRule.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvcnVsZS9CaW5kaW5nVGFibGVSdWxlLmphdmE=) | `58.82% <0.00%> (-7.85%)` | :arrow_down: |
   | [...ardingsphere/singletable/rule/SingleTableRule.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLXNpbmdsZS10YWJsZS9zaGFyZGluZ3NwaGVyZS1zaW5nbGUtdGFibGUtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2luZ2xldGFibGUvcnVsZS9TaW5nbGVUYWJsZVJ1bGUuamF2YQ==) | `72.22% <0.00%> (-3.15%)` | :arrow_down: |
   | [...ate/DropDatabaseDiscoveryRuleStatementUpdater.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtZGItZGlzY292ZXJ5L3NoYXJkaW5nc3BoZXJlLWRiLWRpc2NvdmVyeS1kaXN0c3FsL3NoYXJkaW5nc3BoZXJlLWRiLWRpc2NvdmVyeS1kaXN0c3FsLWhhbmRsZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RiZGlzY292ZXJ5L2Rpc3RzcWwvaGFuZGxlci91cGRhdGUvRHJvcERhdGFiYXNlRGlzY292ZXJ5UnVsZVN0YXRlbWVudFVwZGF0ZXIuamF2YQ==) | `56.66% <0.00%> (-1.96%)` | :arrow_down: |
   | [...ata/persist/service/ComputeNodePersistService.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL21vZGUvbWV0YWRhdGEvcGVyc2lzdC9zZXJ2aWNlL0NvbXB1dGVOb2RlUGVyc2lzdFNlcnZpY2UuamF2YQ==) | `2.43% <0.00%> (-0.13%)` | :arrow_down: |
   | [...l/parser/core/database/visitor/SQLVisitorRule.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWVuZ2luZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9jb3JlL2RhdGFiYXNlL3Zpc2l0b3IvU1FMVmlzaXRvclJ1bGUuamF2YQ==) | `100.00% <0.00%> (ø)` | |
   | ... and [46 more](https://codecov.io/gh/apache/shardingsphere/pull/14864/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/14864?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/14864?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 [7ecac4f...c909fbd](https://codecov.io/gh/apache/shardingsphere/pull/14864?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] codecov-commenter edited a comment on pull request #14864: validate whether the sharding rules of the binding tables are consistent

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


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/14864?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 [#14864](https://codecov.io/gh/apache/shardingsphere/pull/14864?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (264480a) into [master](https://codecov.io/gh/apache/shardingsphere/commit/7ecac4fdd25f9854a8e2db76e6268c6593fc2459?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (7ecac4f) will **increase** coverage by `0.60%`.
   > The diff coverage is `48.07%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/14864/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/14864?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   #14864      +/-   ##
   ============================================
   + Coverage     59.08%   59.68%   +0.60%     
   - Complexity     1860     1918      +58     
   ============================================
     Files          3131     3162      +31     
     Lines         46696    47267     +571     
     Branches       7912     8034     +122     
   ============================================
   + Hits          27589    28212     +623     
   + Misses        16936    16792     -144     
   - Partials       2171     2263      +92     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/14864?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...phere/sharding/support/InlineExpressionParser.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9zaGFyZGluZy9zdXBwb3J0L0lubGluZUV4cHJlc3Npb25QYXJzZXIuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...shardingsphere/sharding/rule/BindingTableRule.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvcnVsZS9CaW5kaW5nVGFibGVSdWxlLmphdmE=) | `41.66% <0.00%> (-17.16%)` | :arrow_down: |
   | [...che/shardingsphere/sharding/rule/ShardingRule.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvcnVsZS9TaGFyZGluZ1J1bGUuamF2YQ==) | `77.22% <59.52%> (-2.51%)` | :arrow_down: |
   | [...s/domain/segment/impl/charset/ExpectedCollate.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtdGVzdC9zaGFyZGluZ3NwaGVyZS1wYXJzZXItdGVzdC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvdGVzdC9zcWwvcGFyc2VyL3BhcmFtZXRlcml6ZWQvamF4Yi9jYXNlcy9kb21haW4vc2VnbWVudC9pbXBsL2NoYXJzZXQvRXhwZWN0ZWRDb2xsYXRlLmphdmE=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...s/domain/statement/dml/TableStatementTestCase.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtdGVzdC9zaGFyZGluZ3NwaGVyZS1wYXJzZXItdGVzdC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvdGVzdC9zcWwvcGFyc2VyL3BhcmFtZXRlcml6ZWQvamF4Yi9jYXNlcy9kb21haW4vc3RhdGVtZW50L2RtbC9UYWJsZVN0YXRlbWVudFRlc3RDYXNlLmphdmE=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...litting/rule/ReadwriteSplittingDataSourceRule.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtcmVhZHdyaXRlLXNwbGl0dGluZy9zaGFyZGluZ3NwaGVyZS1yZWFkd3JpdGUtc3BsaXR0aW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3JlYWR3cml0ZXNwbGl0dGluZy9ydWxlL1JlYWR3cml0ZVNwbGl0dGluZ0RhdGFTb3VyY2VSdWxlLmphdmE=) | `63.63% <0.00%> (-29.23%)` | :arrow_down: |
   | [...or/statement/impl/MySQLTCLStatementSQLVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWRpYWxlY3Qvc2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci1teXNxbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9teXNxbC92aXNpdG9yL3N0YXRlbWVudC9pbXBsL015U1FMVENMU3RhdGVtZW50U1FMVmlzaXRvci5qYXZh) | `74.00% <0.00%> (-26.00%)` | :arrow_down: |
   | [...lect/statement/mysql/dml/MySQLSelectStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLXN0YXRlbWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9zcWwvZGlhbGVjdC9zdGF0ZW1lbnQvbXlzcWwvZG1sL015U1FMU2VsZWN0U3RhdGVtZW50LmphdmE=) | `80.00% <0.00%> (-20.00%)` | :arrow_down: |
   | [...ache/shardingsphere/encrypt/rule/EncryptTable.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtZW5jcnlwdC9zaGFyZGluZ3NwaGVyZS1lbmNyeXB0LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2VuY3J5cHQvcnVsZS9FbmNyeXB0VGFibGUuamF2YQ==) | `85.00% <0.00%> (-11.88%)` | :arrow_down: |
   | [...re/infra/rewrite/engine/RouteSQLRewriteEngine.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtcmV3cml0ZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvaW5mcmEvcmV3cml0ZS9lbmdpbmUvUm91dGVTUUxSZXdyaXRlRW5naW5lLmphdmE=) | `75.80% <0.00%> (-11.30%)` | :arrow_down: |
   | ... and [237 more](https://codecov.io/gh/apache/shardingsphere/pull/14864/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/14864?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/14864?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 [7ecac4f...264480a](https://codecov.io/gh/apache/shardingsphere/pull/14864?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] cheese8 commented on a change in pull request #14864: validate whether the sharding rules of the binding tables are consistent

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



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -204,6 +208,105 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        if (null == bindingTableGroups || bindingTableGroups.isEmpty()) {
+            return;
+        }
+        for (String bindingTableGroup : bindingTableGroups) {
+            List<String> bindingTableList = Splitter.on(",").trimResults().splitToList(bindingTableGroup.toLowerCase());
+            TableRule savedTableRule = null;
+            for (String bindingTable : bindingTableList) {
+                TableRule tableRule = bindingTableRules.get(bindingTable).getTableRules().get(bindingTable);
+                if (null == savedTableRule) {
+                    savedTableRule = tableRule;

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] codecov-commenter edited a comment on pull request #14864: validate whether the sharding rules of the binding tables are consistent

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


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/14864?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 [#14864](https://codecov.io/gh/apache/shardingsphere/pull/14864?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (6198bd1) into [master](https://codecov.io/gh/apache/shardingsphere/commit/d8ee21fb37f602512bafc4aa925450a52354658c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (d8ee21f) will **decrease** coverage by `0.00%`.
   > The diff coverage is `79.41%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/14864/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/14864?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   #14864      +/-   ##
   ============================================
   - Coverage     60.49%   60.48%   -0.01%     
   - Complexity     1954     1982      +28     
   ============================================
     Files          3220     3223       +3     
     Lines         48250    48551     +301     
     Branches       8233     8293      +60     
   ============================================
   + Hits          29188    29367     +179     
   - Misses        16692    16777      +85     
   - Partials       2370     2407      +37     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/14864?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...che/shardingsphere/sharding/rule/ShardingRule.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvcnVsZS9TaGFyZGluZ1J1bGUuamF2YQ==) | `80.95% <79.41%> (+0.30%)` | :arrow_up: |
   | [...ealtered/YamlOnRuleAlteredActionConfiguration.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS95YW1sL2NvbmZpZy9wb2pvL3J1bGVhbHRlcmVkL1lhbWxPblJ1bGVBbHRlcmVkQWN0aW9uQ29uZmlndXJhdGlvbi5qYXZh) | `11.11% <0.00%> (-88.89%)` | :arrow_down: |
   | [...ana/config/NarayanaConfigurationFileGenerator.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLXRyYW5zYWN0aW9uL3NoYXJkaW5nc3BoZXJlLXRyYW5zYWN0aW9uLXR5cGUvc2hhcmRpbmdzcGhlcmUtdHJhbnNhY3Rpb24teGEvc2hhcmRpbmdzcGhlcmUtdHJhbnNhY3Rpb24teGEtcHJvdmlkZXIvc2hhcmRpbmdzcGhlcmUtdHJhbnNhY3Rpb24teGEtbmFyYXlhbmEvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3RyYW5zYWN0aW9uL3hhL25hcmF5YW5hL2NvbmZpZy9OYXJheWFuYUNvbmZpZ3VyYXRpb25GaWxlR2VuZXJhdG9yLmphdmE=) | `61.22% <0.00%> (-30.45%)` | :arrow_down: |
   | [...a/type/hikari/HikariDataSourceJdbcUrlMetaData.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kYXRhc291cmNlL3Bvb2wvbWV0YWRhdGEvdHlwZS9oaWthcmkvSGlrYXJpRGF0YVNvdXJjZUpkYmNVcmxNZXRhRGF0YS5qYXZh) | `75.00% <0.00%> (-25.00%)` | :arrow_down: |
   | [...infra/database/type/dialect/MySQLDatabaseType.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kYXRhYmFzZS90eXBlL2RpYWxlY3QvTXlTUUxEYXRhYmFzZVR5cGUuamF2YQ==) | `83.33% <0.00%> (-16.67%)` | :arrow_down: |
   | [...infra/database/type/dialect/SQL92DatabaseType.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kYXRhYmFzZS90eXBlL2RpYWxlY3QvU1FMOTJEYXRhYmFzZVR5cGUuamF2YQ==) | `83.33% <0.00%> (-16.67%)` | :arrow_down: |
   | [...a/database/type/dialect/SQLServerDatabaseType.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kYXRhYmFzZS90eXBlL2RpYWxlY3QvU1FMU2VydmVyRGF0YWJhc2VUeXBlLmphdmE=) | `83.33% <0.00%> (-16.67%)` | :arrow_down: |
   | [.../database/type/dialect/PostgreSQLDatabaseType.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kYXRhYmFzZS90eXBlL2RpYWxlY3QvUG9zdGdyZVNRTERhdGFiYXNlVHlwZS5qYXZh) | `83.33% <0.00%> (-16.67%)` | :arrow_down: |
   | [...adata/type/dbcp/DBCPDataSourceJdbcUrlMetaData.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kYXRhc291cmNlL3Bvb2wvbWV0YWRhdGEvdHlwZS9kYmNwL0RCQ1BEYXRhU291cmNlSmRiY1VybE1ldGFEYXRhLmphdmE=) | `72.72% <0.00%> (-16.17%)` | :arrow_down: |
   | [...type/dbcp/TomcatDBCPDataSourceJdbcUrlMetaData.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kYXRhc291cmNlL3Bvb2wvbWV0YWRhdGEvdHlwZS9kYmNwL1RvbWNhdERCQ1BEYXRhU291cmNlSmRiY1VybE1ldGFEYXRhLmphdmE=) | `72.72% <0.00%> (-16.17%)` | :arrow_down: |
   | ... and [145 more](https://codecov.io/gh/apache/shardingsphere/pull/14864/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/14864?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/14864?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 [d8ee21f...6198bd1](https://codecov.io/gh/apache/shardingsphere/pull/14864?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] codecov-commenter edited a comment on pull request #14864: validate whether the sharding rules of the binding tables are consistent

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


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/14864?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 [#14864](https://codecov.io/gh/apache/shardingsphere/pull/14864?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (7d13147) into [master](https://codecov.io/gh/apache/shardingsphere/commit/7ecac4fdd25f9854a8e2db76e6268c6593fc2459?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (7ecac4f) will **increase** coverage by `1.11%`.
   > The diff coverage is `32.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/14864/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/14864?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   #14864      +/-   ##
   ============================================
   + Coverage     59.08%   60.19%   +1.11%     
   - Complexity     1860     1937      +77     
   ============================================
     Files          3131     3187      +56     
     Lines         46696    47726    +1030     
     Branches       7912     8118     +206     
   ============================================
   + Hits          27589    28730    +1141     
   + Misses        16936    16671     -265     
   - Partials       2171     2325     +154     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/14864?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...phere/sharding/support/InlineExpressionParser.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9zaGFyZGluZy9zdXBwb3J0L0lubGluZUV4cHJlc3Npb25QYXJzZXIuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...shardingsphere/sharding/rule/BindingTableRule.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvcnVsZS9CaW5kaW5nVGFibGVSdWxlLmphdmE=) | `41.66% <0.00%> (-17.16%)` | :arrow_down: |
   | [...che/shardingsphere/sharding/rule/ShardingRule.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvcnVsZS9TaGFyZGluZ1J1bGUuamF2YQ==) | `74.31% <40.00%> (-5.41%)` | :arrow_down: |
   | [...s/domain/segment/impl/charset/ExpectedCollate.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtdGVzdC9zaGFyZGluZ3NwaGVyZS1wYXJzZXItdGVzdC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvdGVzdC9zcWwvcGFyc2VyL3BhcmFtZXRlcml6ZWQvamF4Yi9jYXNlcy9kb21haW4vc2VnbWVudC9pbXBsL2NoYXJzZXQvRXhwZWN0ZWRDb2xsYXRlLmphdmE=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...s/domain/statement/dml/TableStatementTestCase.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtdGVzdC9zaGFyZGluZ3NwaGVyZS1wYXJzZXItdGVzdC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvdGVzdC9zcWwvcGFyc2VyL3BhcmFtZXRlcml6ZWQvamF4Yi9jYXNlcy9kb21haW4vc3RhdGVtZW50L2RtbC9UYWJsZVN0YXRlbWVudFRlc3RDYXNlLmphdmE=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...query/extended/sync/PostgreSQLComSyncExecutor.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktZnJvbnRlbmQvc2hhcmRpbmdzcGhlcmUtcHJveHktZnJvbnRlbmQtcG9zdGdyZXNxbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvZnJvbnRlbmQvcG9zdGdyZXNxbC9jb21tYW5kL3F1ZXJ5L2V4dGVuZGVkL3N5bmMvUG9zdGdyZVNRTENvbVN5bmNFeGVjdXRvci5qYXZh) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...gsphere/infra/metadata/ShardingSphereMetaData.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9tZXRhZGF0YS9TaGFyZGluZ1NwaGVyZU1ldGFEYXRhLmphdmE=) | `7.14% <0.00%> (-42.86%)` | :arrow_down: |
   | [.../mode/metadata/persist/MetaDataPersistService.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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=) | `61.53% <0.00%> (-38.47%)` | :arrow_down: |
   | [...litting/rule/ReadwriteSplittingDataSourceRule.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtcmVhZHdyaXRlLXNwbGl0dGluZy9zaGFyZGluZ3NwaGVyZS1yZWFkd3JpdGUtc3BsaXR0aW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3JlYWR3cml0ZXNwbGl0dGluZy9ydWxlL1JlYWR3cml0ZVNwbGl0dGluZ0RhdGFTb3VyY2VSdWxlLmphdmE=) | `59.09% <0.00%> (-33.77%)` | :arrow_down: |
   | [...sharding/cosid/CosIdIntervalShardingAlgorithm.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvYWxnb3JpdGhtL3NoYXJkaW5nL2Nvc2lkL0Nvc0lkSW50ZXJ2YWxTaGFyZGluZ0FsZ29yaXRobS5qYXZh) | `60.00% <0.00%> (-27.50%)` | :arrow_down: |
   | ... and [440 more](https://codecov.io/gh/apache/shardingsphere/pull/14864/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/14864?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/14864?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 [7ecac4f...7d13147](https://codecov.io/gh/apache/shardingsphere/pull/14864?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] cheese8 commented on a change in pull request #14864: validate whether the sharding rules of the binding tables are consistent

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



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -216,6 +221,104 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        for (String each : bindingTableGroups) {
+            List<String> bindingTableList = Splitter.on(",").trimResults().splitToList(each.toLowerCase());
+            TableRule sampleTableRule = null;
+            for (String bindingTable : bindingTableList) {
+                TableRule tableRule = bindingTableRules.get(bindingTable).getTableRules().get(bindingTable);
+                if (null == sampleTableRule) {
+                    sampleTableRule = tableRule;
+                } else {
+                    checkSameActualDatasourceNamesAndActualTableIndex(sampleTableRule, tableRule, each);
+                }
+            }
+        }
+    }
+    
+    private void checkSameActualDatasourceNamesAndActualTableIndex(final TableRule sampleTableRule, final TableRule tableRule, final String bindingTableGroup) {
+        if (!CollectionUtils.isEqualCollection(sampleTableRule.getActualDatasourceNames(), tableRule.getActualDatasourceNames())) {
+            throw new ShardingSphereConfigurationException("The %s on bindingTableGroup `%s` are inconsistent", "actualDatasourceNames", bindingTableGroup);
+        }
+        checkSameAlgorithmOnDatabase(sampleTableRule, tableRule, sampleTableRule.getActualDatasourceNames().stream().findFirst().get(), bindingTableGroup);
+        for (String each : sampleTableRule.getActualDatasourceNames()) {
+            Collection<String> sampleActualTableNames = sampleTableRule.getActualTableNames(each).stream().map(optional -> substring(optional)[1])
+                    .filter(optional -> !optional.isEmpty()).collect(Collectors.toList());
+            Collection<String> actualTableNames = tableRule.getActualTableNames(each).stream().map(optional -> substring(optional)[1])
+                    .filter(optional -> !optional.isEmpty()).collect(Collectors.toList());
+            if (!CollectionUtils.isEqualCollection(sampleActualTableNames, actualTableNames)) {
+                throw new ShardingSphereConfigurationException("The %s on bindingTableGroup `%s` are inconsistent", "actualTableNames", bindingTableGroup);
+            }
+            checkSameAlgorithmOnTable(sampleTableRule, sampleTableRule.getActualTableNames(each).stream().findFirst().get(), tableRule,
+                    tableRule.getActualTableNames(each).stream().findFirst().get(), bindingTableGroup);
+        }
+    }
+    
+    private void checkSameAlgorithmOnDatabase(final TableRule sampleTableRule, final TableRule tableRule, final String dataSourceName,
+                                              final String bindingTableGroup) {
+        Collection<String[]> algorithmExpressions = new ArrayList<>();
+        String logicName = substring(dataSourceName)[0];
+        algorithmExpressions.add(new String[] {getAlgorithmExpression(sampleTableRule, true), logicName, getShardingColumn(sampleTableRule.getDatabaseShardingStrategyConfig())});
+        algorithmExpressions.add(new String[] {getAlgorithmExpression(tableRule, true), logicName, getShardingColumn(tableRule.getDatabaseShardingStrategyConfig())});
+        checkSameAlgorithmExpression(algorithmExpressions, "databaseShardingStrategyConfig", bindingTableGroup);
+    }
+    
+    private String getAlgorithmExpression(final TableRule tableRule, final boolean databaseOrTable) {
+        if (null == tableRule.getDatabaseShardingStrategyConfig() || null == tableRule.getTableShardingStrategyConfig()) {

Review comment:
       Yes, logic fixed




-- 
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] cheese8 commented on a change in pull request #14864: validate whether the sharding rules of the binding tables are consistent

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



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -216,6 +221,104 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        for (String each : bindingTableGroups) {
+            List<String> bindingTableList = Splitter.on(",").trimResults().splitToList(each.toLowerCase());
+            TableRule sampleTableRule = null;
+            for (String bindingTable : bindingTableList) {
+                TableRule tableRule = bindingTableRules.get(bindingTable).getTableRules().get(bindingTable);
+                if (null == sampleTableRule) {
+                    sampleTableRule = tableRule;
+                } else {
+                    checkSameActualDatasourceNamesAndActualTableIndex(sampleTableRule, tableRule, each);
+                }
+            }
+        }
+    }
+    
+    private void checkSameActualDatasourceNamesAndActualTableIndex(final TableRule sampleTableRule, final TableRule tableRule, final String bindingTableGroup) {
+        if (!CollectionUtils.isEqualCollection(sampleTableRule.getActualDatasourceNames(), tableRule.getActualDatasourceNames())) {
+            throw new ShardingSphereConfigurationException("The %s on bindingTableGroup `%s` are inconsistent", "actualDatasourceNames", bindingTableGroup);
+        }
+        checkSameAlgorithmOnDatabase(sampleTableRule, tableRule, sampleTableRule.getActualDatasourceNames().stream().findFirst().get(), bindingTableGroup);
+        for (String each : sampleTableRule.getActualDatasourceNames()) {
+            Collection<String> sampleActualTableNames = sampleTableRule.getActualTableNames(each).stream().map(optional -> substring(optional)[1])
+                    .filter(optional -> !optional.isEmpty()).collect(Collectors.toList());
+            Collection<String> actualTableNames = tableRule.getActualTableNames(each).stream().map(optional -> substring(optional)[1])
+                    .filter(optional -> !optional.isEmpty()).collect(Collectors.toList());
+            if (!CollectionUtils.isEqualCollection(sampleActualTableNames, actualTableNames)) {
+                throw new ShardingSphereConfigurationException("The %s on bindingTableGroup `%s` are inconsistent", "actualTableNames", bindingTableGroup);
+            }
+            checkSameAlgorithmOnTable(sampleTableRule, sampleTableRule.getActualTableNames(each).stream().findFirst().get(), tableRule,
+                    tableRule.getActualTableNames(each).stream().findFirst().get(), bindingTableGroup);
+        }
+    }
+    
+    private void checkSameAlgorithmOnDatabase(final TableRule sampleTableRule, final TableRule tableRule, final String dataSourceName,
+                                              final String bindingTableGroup) {
+        Collection<String[]> algorithmExpressions = new ArrayList<>();
+        String logicName = substring(dataSourceName)[0];
+        algorithmExpressions.add(new String[] {getAlgorithmExpression(sampleTableRule, true), logicName, getShardingColumn(sampleTableRule.getDatabaseShardingStrategyConfig())});
+        algorithmExpressions.add(new String[] {getAlgorithmExpression(tableRule, true), logicName, getShardingColumn(tableRule.getDatabaseShardingStrategyConfig())});
+        checkSameAlgorithmExpression(algorithmExpressions, "databaseShardingStrategyConfig", bindingTableGroup);
+    }
+    
+    private String getAlgorithmExpression(final TableRule tableRule, final boolean databaseOrTable) {
+        if (null == tableRule.getDatabaseShardingStrategyConfig() || null == tableRule.getTableShardingStrategyConfig()) {
+            return "";
+        }
+        String shardingAlgorithmName = databaseOrTable ? tableRule.getDatabaseShardingStrategyConfig().getShardingAlgorithmName()
+                : tableRule.getTableShardingStrategyConfig().getShardingAlgorithmName();
+        ShardingAlgorithm shardingAlgorithm = shardingAlgorithms.get(shardingAlgorithmName);
+        return null == shardingAlgorithm ? "" : checkWithDefaultValue(shardingAlgorithm.getProps().getProperty("algorithm-expression"), "");
+    }
+    
+    private String checkWithDefaultValue(final String str, final String defaultValue) {

Review comment:
       OK, it's better




-- 
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] strongduanmu commented on a change in pull request #14864: validate whether the sharding rules of the binding tables are consistent

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



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -192,11 +194,65 @@ private String getDefaultGenerateKeyColumn(final KeyGenerateStrategyConfiguratio
     private BindingTableRule createBindingTableRule(final String bindingTableGroup) {
         Map<String, TableRule> tableRules = Splitter.on(",").trimResults().splitToList(bindingTableGroup).stream()
                 .map(this::getTableRule).collect(Collectors.toMap(each -> each.getLogicTable().toLowerCase(), Function.identity(), (oldValue, currentValue) -> oldValue, LinkedHashMap::new));
+        checkTheSameActualDataSourceNames(tableRules, bindingTableGroup);

Review comment:
       @cheese8 Can you merge this three check method to checkBindingTableRule(tableRules)?

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -192,11 +194,65 @@ private String getDefaultGenerateKeyColumn(final KeyGenerateStrategyConfiguratio
     private BindingTableRule createBindingTableRule(final String bindingTableGroup) {
         Map<String, TableRule> tableRules = Splitter.on(",").trimResults().splitToList(bindingTableGroup).stream()
                 .map(this::getTableRule).collect(Collectors.toMap(each -> each.getLogicTable().toLowerCase(), Function.identity(), (oldValue, currentValue) -> oldValue, LinkedHashMap::new));
+        checkTheSameActualDataSourceNames(tableRules, bindingTableGroup);
+        checkTheSameShardingStrategyConfiguration(tableRules, bindingTableGroup, true);
+        checkTheSameShardingStrategyConfiguration(tableRules, bindingTableGroup, false);
         BindingTableRule result = new BindingTableRule();
         result.getTableRules().putAll(tableRules);
         return result;
     }
     
+    private void checkTheSameActualDataSourceNames(final Map<String, TableRule> tableRules, final String bindingTableGroup) {

Review comment:
       @cheese8 Can we choose the first tableRule as sample, and then judge whether other tableRules are same with sample?

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -192,11 +194,65 @@ private String getDefaultGenerateKeyColumn(final KeyGenerateStrategyConfiguratio
     private BindingTableRule createBindingTableRule(final String bindingTableGroup) {
         Map<String, TableRule> tableRules = Splitter.on(",").trimResults().splitToList(bindingTableGroup).stream()
                 .map(this::getTableRule).collect(Collectors.toMap(each -> each.getLogicTable().toLowerCase(), Function.identity(), (oldValue, currentValue) -> oldValue, LinkedHashMap::new));
+        checkTheSameActualDataSourceNames(tableRules, bindingTableGroup);
+        checkTheSameShardingStrategyConfiguration(tableRules, bindingTableGroup, true);
+        checkTheSameShardingStrategyConfiguration(tableRules, bindingTableGroup, false);
         BindingTableRule result = new BindingTableRule();
         result.getTableRules().putAll(tableRules);
         return result;
     }
     
+    private void checkTheSameActualDataSourceNames(final Map<String, TableRule> tableRules, final String bindingTableGroup) {
+        Collection<String> savedActualDataSourceNames = new HashSet<>();
+        int countSavedActualDataSourceNames = 0;
+        for (TableRule tableRule : tableRules.values()) {
+            if (savedActualDataSourceNames.isEmpty()) {
+                savedActualDataSourceNames.addAll(tableRule.getActualDatasourceNames());
+                countSavedActualDataSourceNames = savedActualDataSourceNames.size();
+            } else if (!savedActualDataSourceNames.isEmpty()) {
+                savedActualDataSourceNames.addAll(tableRule.getActualDatasourceNames());
+                if (countSavedActualDataSourceNames != savedActualDataSourceNames.size()) {
+                    throw new ShardingSphereConfigurationException("The actualDataSourceNames on bindingTableGroup `%s` are inconsistent", bindingTableGroup);
+                }
+            }
+        }
+    }
+    
+    private void checkTheSameShardingStrategyConfiguration(final Map<String, TableRule> tableRules, final String bindingTableGroup, final Boolean databaseOrTable) {
+        String savedShardingColumn = null;
+        String savedShardingAlgorithm = null;
+        for (TableRule tableRule : tableRules.values()) {
+            ShardingStrategyConfiguration shardingStrategyConfiguration = databaseOrTable ? tableRule.getDatabaseShardingStrategyConfig() : tableRule.getTableShardingStrategyConfig();
+            if (null == shardingStrategyConfiguration) {
+                continue;
+            }
+            String shardingColumn = getShardingColumn(shardingStrategyConfiguration);
+            if (null == savedShardingColumn) {
+                savedShardingColumn = shardingColumn;
+            } else if (null != savedShardingColumn && !savedShardingColumn.equalsIgnoreCase(shardingColumn)) {
+                log.warn("All the route computations will only use the sharding strategy of the primary table, but the databaseShardingStrategyConfig on bindTable `%s` are inconsistent.", 

Review comment:
       @cheese8 I think exception may be better.




-- 
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 #14864: validate whether the sharding rules of the binding tables are consistent

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


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/14864?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 [#14864](https://codecov.io/gh/apache/shardingsphere/pull/14864?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (c909fbd) into [master](https://codecov.io/gh/apache/shardingsphere/commit/7ecac4fdd25f9854a8e2db76e6268c6593fc2459?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (7ecac4f) will **increase** coverage by `0.01%`.
   > The diff coverage is `70.73%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/14864/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/14864?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   #14864      +/-   ##
   ============================================
   + Coverage     59.08%   59.10%   +0.01%     
   - Complexity     1860     1870      +10     
   ============================================
     Files          3131     3132       +1     
     Lines         46696    46776      +80     
     Branches       7912     7936      +24     
   ============================================
   + Hits          27589    27645      +56     
   - Misses        16936    16944       +8     
   - Partials       2171     2187      +16     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/14864?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...che/shardingsphere/sharding/rule/ShardingRule.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvcnVsZS9TaGFyZGluZ1J1bGUuamF2YQ==) | `78.29% <70.73%> (-1.43%)` | :arrow_down: |
   | [...s/domain/segment/impl/charset/ExpectedCollate.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtdGVzdC9zaGFyZGluZ3NwaGVyZS1wYXJzZXItdGVzdC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvdGVzdC9zcWwvcGFyc2VyL3BhcmFtZXRlcml6ZWQvamF4Yi9jYXNlcy9kb21haW4vc2VnbWVudC9pbXBsL2NoYXJzZXQvRXhwZWN0ZWRDb2xsYXRlLmphdmE=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...enerator/builder/DefaultTokenGeneratorBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtcmV3cml0ZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvaW5mcmEvcmV3cml0ZS9zcWwvdG9rZW4vZ2VuZXJhdG9yL2J1aWxkZXIvRGVmYXVsdFRva2VuR2VuZXJhdG9yQnVpbGRlci5qYXZh) | `66.66% <0.00%> (-33.34%)` | :arrow_down: |
   | [...re/infra/rewrite/engine/RouteSQLRewriteEngine.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtcmV3cml0ZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvaW5mcmEvcmV3cml0ZS9lbmdpbmUvUm91dGVTUUxSZXdyaXRlRW5naW5lLmphdmE=) | `75.80% <0.00%> (-11.30%)` | :arrow_down: |
   | [...write/token/pojo/ShardingTokenGenerateBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvcmV3cml0ZS90b2tlbi9wb2pvL1NoYXJkaW5nVG9rZW5HZW5lcmF0ZUJ1aWxkZXIuamF2YQ==) | `84.61% <0.00%> (-7.39%)` | :arrow_down: |
   | [...ewrite/sql/token/generator/SQLTokenGenerators.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtcmV3cml0ZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvaW5mcmEvcmV3cml0ZS9zcWwvdG9rZW4vZ2VuZXJhdG9yL1NRTFRva2VuR2VuZXJhdG9ycy5qYXZh) | `64.00% <0.00%> (-2.67%)` | :arrow_down: |
   | [...or/statement/impl/MySQLDDLStatementSQLVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWRpYWxlY3Qvc2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci1teXNxbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9teXNxbC92aXNpdG9yL3N0YXRlbWVudC9pbXBsL015U1FMRERMU3RhdGVtZW50U1FMVmlzaXRvci5qYXZh) | `53.39% <0.00%> (-0.15%)` | :arrow_down: |
   | [...dingsphere/spi/singleton/SingletonSPIRegistry.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9zcGkvc2luZ2xldG9uL1NpbmdsZXRvblNQSVJlZ2lzdHJ5LmphdmE=) | `100.00% <0.00%> (ø)` | |
   | [...d/asserts/segment/expression/ExpressionAssert.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtdGVzdC9zaGFyZGluZ3NwaGVyZS1wYXJzZXItdGVzdC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvdGVzdC9zcWwvcGFyc2VyL3BhcmFtZXRlcml6ZWQvYXNzZXJ0cy9zZWdtZW50L2V4cHJlc3Npb24vRXhwcmVzc2lvbkFzc2VydC5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...ypt/rewrite/token/EncryptTokenGenerateBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtZW5jcnlwdC9zaGFyZGluZ3NwaGVyZS1lbmNyeXB0LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2VuY3J5cHQvcmV3cml0ZS90b2tlbi9FbmNyeXB0VG9rZW5HZW5lcmF0ZUJ1aWxkZXIuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | ... and [16 more](https://codecov.io/gh/apache/shardingsphere/pull/14864/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/14864?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/14864?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 [7ecac4f...c909fbd](https://codecov.io/gh/apache/shardingsphere/pull/14864?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] cheese8 commented on a change in pull request #14864: validate whether the sharding rules of the binding tables are consistent

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



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -204,6 +208,105 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        if (null == bindingTableGroups || bindingTableGroups.isEmpty()) {

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] cheese8 commented on a change in pull request #14864: validate whether the sharding rules of the binding tables are consistent

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



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -192,11 +194,65 @@ private String getDefaultGenerateKeyColumn(final KeyGenerateStrategyConfiguratio
     private BindingTableRule createBindingTableRule(final String bindingTableGroup) {
         Map<String, TableRule> tableRules = Splitter.on(",").trimResults().splitToList(bindingTableGroup).stream()
                 .map(this::getTableRule).collect(Collectors.toMap(each -> each.getLogicTable().toLowerCase(), Function.identity(), (oldValue, currentValue) -> oldValue, LinkedHashMap::new));
+        checkTheSameActualDataSourceNames(tableRules, bindingTableGroup);

Review comment:
       ok

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -192,11 +194,65 @@ private String getDefaultGenerateKeyColumn(final KeyGenerateStrategyConfiguratio
     private BindingTableRule createBindingTableRule(final String bindingTableGroup) {
         Map<String, TableRule> tableRules = Splitter.on(",").trimResults().splitToList(bindingTableGroup).stream()
                 .map(this::getTableRule).collect(Collectors.toMap(each -> each.getLogicTable().toLowerCase(), Function.identity(), (oldValue, currentValue) -> oldValue, LinkedHashMap::new));
+        checkTheSameActualDataSourceNames(tableRules, bindingTableGroup);
+        checkTheSameShardingStrategyConfiguration(tableRules, bindingTableGroup, true);
+        checkTheSameShardingStrategyConfiguration(tableRules, bindingTableGroup, false);
         BindingTableRule result = new BindingTableRule();
         result.getTableRules().putAll(tableRules);
         return result;
     }
     
+    private void checkTheSameActualDataSourceNames(final Map<String, TableRule> tableRules, final String bindingTableGroup) {
+        Collection<String> savedActualDataSourceNames = new HashSet<>();
+        int countSavedActualDataSourceNames = 0;
+        for (TableRule tableRule : tableRules.values()) {
+            if (savedActualDataSourceNames.isEmpty()) {
+                savedActualDataSourceNames.addAll(tableRule.getActualDatasourceNames());
+                countSavedActualDataSourceNames = savedActualDataSourceNames.size();
+            } else if (!savedActualDataSourceNames.isEmpty()) {
+                savedActualDataSourceNames.addAll(tableRule.getActualDatasourceNames());
+                if (countSavedActualDataSourceNames != savedActualDataSourceNames.size()) {
+                    throw new ShardingSphereConfigurationException("The actualDataSourceNames on bindingTableGroup `%s` are inconsistent", bindingTableGroup);
+                }
+            }
+        }
+    }
+    
+    private void checkTheSameShardingStrategyConfiguration(final Map<String, TableRule> tableRules, final String bindingTableGroup, final Boolean databaseOrTable) {
+        String savedShardingColumn = null;
+        String savedShardingAlgorithm = null;
+        for (TableRule tableRule : tableRules.values()) {
+            ShardingStrategyConfiguration shardingStrategyConfiguration = databaseOrTable ? tableRule.getDatabaseShardingStrategyConfig() : tableRule.getTableShardingStrategyConfig();
+            if (null == shardingStrategyConfiguration) {
+                continue;
+            }
+            String shardingColumn = getShardingColumn(shardingStrategyConfiguration);
+            if (null == savedShardingColumn) {
+                savedShardingColumn = shardingColumn;
+            } else if (null != savedShardingColumn && !savedShardingColumn.equalsIgnoreCase(shardingColumn)) {
+                log.warn("All the route computations will only use the sharding strategy of the primary table, but the databaseShardingStrategyConfig on bindTable `%s` are inconsistent.", 

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] cheese8 commented on a change in pull request #14864: validate whether the sharding rules of the binding tables are consistent

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



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -192,11 +194,65 @@ private String getDefaultGenerateKeyColumn(final KeyGenerateStrategyConfiguratio
     private BindingTableRule createBindingTableRule(final String bindingTableGroup) {
         Map<String, TableRule> tableRules = Splitter.on(",").trimResults().splitToList(bindingTableGroup).stream()
                 .map(this::getTableRule).collect(Collectors.toMap(each -> each.getLogicTable().toLowerCase(), Function.identity(), (oldValue, currentValue) -> oldValue, LinkedHashMap::new));
+        checkTheSameActualDataSourceNames(tableRules, bindingTableGroup);
+        checkTheSameShardingStrategyConfiguration(tableRules, bindingTableGroup, true);
+        checkTheSameShardingStrategyConfiguration(tableRules, bindingTableGroup, false);
         BindingTableRule result = new BindingTableRule();
         result.getTableRules().putAll(tableRules);
         return result;
     }
     
+    private void checkTheSameActualDataSourceNames(final Map<String, TableRule> tableRules, final String bindingTableGroup) {

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] cheese8 commented on a change in pull request #14864: validate whether the sharding rules of the binding tables are consistent

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



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -203,6 +212,60 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         result.getTableRules().putAll(tableRules);
         return result;
     }
+
+    private void checkTheSameActualDataSourceNamesAndActualTableIndex(final Collection<String> bindingTableGroups, final Collection<ShardingTableRuleConfiguration> tables) {
+        if (null == bindingTableGroups || bindingTableGroups.size() <= 0) {

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] strongduanmu commented on a change in pull request #14864: validate whether the sharding rules of the binding tables are consistent

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



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -204,6 +208,105 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        if (null == bindingTableGroups || bindingTableGroups.isEmpty()) {
+            return;
+        }
+        for (String bindingTableGroup : bindingTableGroups) {

Review comment:
       Please rename bindingTableGroup with each.

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -204,6 +208,105 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        if (null == bindingTableGroups || bindingTableGroups.isEmpty()) {
+            return;
+        }
+        for (String bindingTableGroup : bindingTableGroups) {
+            List<String> bindingTableList = Splitter.on(",").trimResults().splitToList(bindingTableGroup.toLowerCase());
+            TableRule savedTableRule = null;
+            for (String bindingTable : bindingTableList) {
+                TableRule tableRule = bindingTableRules.get(bindingTable).getTableRules().get(bindingTable);
+                if (null == savedTableRule) {
+                    savedTableRule = tableRule;

Review comment:
       Do you think sampleTableRule is better?

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -204,6 +208,105 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        if (null == bindingTableGroups || bindingTableGroups.isEmpty()) {
+            return;
+        }
+        for (String bindingTableGroup : bindingTableGroups) {
+            List<String> bindingTableList = Splitter.on(",").trimResults().splitToList(bindingTableGroup.toLowerCase());
+            TableRule savedTableRule = null;
+            for (String bindingTable : bindingTableList) {
+                TableRule tableRule = bindingTableRules.get(bindingTable).getTableRules().get(bindingTable);
+                if (null == savedTableRule) {
+                    savedTableRule = tableRule;
+                } else {
+                    checkSameActualDatasourceNamesAndActualTableIndex(savedTableRule, tableRule, bindingTableGroup);
+                }
+            }
+        }
+    }
+    
+    private void checkSameActualDatasourceNamesAndActualTableIndex(final TableRule savedOne, final TableRule newOne, final String bindingTableGroup) {

Review comment:
       Please rename savedOne to sampleTableRule, rename newOne to tableRule.

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -204,6 +208,105 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        if (null == bindingTableGroups || bindingTableGroups.isEmpty()) {

Review comment:
       @cheese8 Please remove this useless judge logic.

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -204,6 +208,105 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        if (null == bindingTableGroups || bindingTableGroups.isEmpty()) {
+            return;
+        }
+        for (String bindingTableGroup : bindingTableGroups) {
+            List<String> bindingTableList = Splitter.on(",").trimResults().splitToList(bindingTableGroup.toLowerCase());
+            TableRule savedTableRule = null;
+            for (String bindingTable : bindingTableList) {
+                TableRule tableRule = bindingTableRules.get(bindingTable).getTableRules().get(bindingTable);
+                if (null == savedTableRule) {
+                    savedTableRule = tableRule;
+                } else {
+                    checkSameActualDatasourceNamesAndActualTableIndex(savedTableRule, tableRule, bindingTableGroup);
+                }
+            }
+        }
+    }
+    
+    private void checkSameActualDatasourceNamesAndActualTableIndex(final TableRule savedOne, final TableRule newOne, final String bindingTableGroup) {
+        if (!savedOne.getActualDatasourceNames().containsAll(newOne.getActualDatasourceNames())) {
+            throw new ShardingSphereConfigurationException("The actualDatasourceNames on bindingTableGroup `%s` are inconsistent", bindingTableGroup);
+        }
+        checkSameAlgorithmOnDatabase(savedOne, newOne, savedOne.getActualDatasourceNames().stream().findFirst().get(), bindingTableGroup);
+        for (String dataSourceName : savedOne.getActualDatasourceNames()) {
+            Collection<String> savedActualTableNames = savedOne.getActualTableNames(dataSourceName).stream().map(each -> substring(each)[1])
+                    .filter(each -> !each.isEmpty()).collect(Collectors.toList());
+            Collection<String> newOneActualTableNames = newOne.getActualTableNames(dataSourceName).stream().map(each -> substring(each)[1])
+                    .filter(each -> !each.isEmpty()).collect(Collectors.toList());
+            if (!savedActualTableNames.containsAll(newOneActualTableNames)) {
+                throw new ShardingSphereConfigurationException("The actualTableNames on bindingTableGroup `%s` are inconsistent", bindingTableGroup);
+            }
+            checkSameAlgorithmOnTable(savedOne, savedOne.getActualTableNames(dataSourceName).stream().findFirst().get(), newOne,
+                    newOne.getActualTableNames(dataSourceName).stream().findFirst().get(), bindingTableGroup);
+        }
+    }
+    
+    private void checkSameAlgorithmOnDatabase(final TableRule savedOne, final TableRule newOne, final String dataSourceName,
+                                              final String bindingTableGroup) {
+        Collection<String[]> args = new ArrayList<>();

Review comment:
       @cheese8 Please use more meaningful name for savedOne, newOne and args.

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -204,6 +208,105 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        if (null == bindingTableGroups || bindingTableGroups.isEmpty()) {
+            return;
+        }
+        for (String bindingTableGroup : bindingTableGroups) {
+            List<String> bindingTableList = Splitter.on(",").trimResults().splitToList(bindingTableGroup.toLowerCase());
+            TableRule savedTableRule = null;
+            for (String bindingTable : bindingTableList) {
+                TableRule tableRule = bindingTableRules.get(bindingTable).getTableRules().get(bindingTable);
+                if (null == savedTableRule) {
+                    savedTableRule = tableRule;
+                } else {
+                    checkSameActualDatasourceNamesAndActualTableIndex(savedTableRule, tableRule, bindingTableGroup);
+                }
+            }
+        }
+    }
+    
+    private void checkSameActualDatasourceNamesAndActualTableIndex(final TableRule savedOne, final TableRule newOne, final String bindingTableGroup) {
+        if (!savedOne.getActualDatasourceNames().containsAll(newOne.getActualDatasourceNames())) {
+            throw new ShardingSphereConfigurationException("The actualDatasourceNames on bindingTableGroup `%s` are inconsistent", bindingTableGroup);

Review comment:
       Please split word or exception message.

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -204,6 +208,105 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        if (null == bindingTableGroups || bindingTableGroups.isEmpty()) {
+            return;
+        }
+        for (String bindingTableGroup : bindingTableGroups) {
+            List<String> bindingTableList = Splitter.on(",").trimResults().splitToList(bindingTableGroup.toLowerCase());
+            TableRule savedTableRule = null;
+            for (String bindingTable : bindingTableList) {
+                TableRule tableRule = bindingTableRules.get(bindingTable).getTableRules().get(bindingTable);
+                if (null == savedTableRule) {
+                    savedTableRule = tableRule;
+                } else {
+                    checkSameActualDatasourceNamesAndActualTableIndex(savedTableRule, tableRule, bindingTableGroup);
+                }
+            }
+        }
+    }
+    
+    private void checkSameActualDatasourceNamesAndActualTableIndex(final TableRule savedOne, final TableRule newOne, final String bindingTableGroup) {
+        if (!savedOne.getActualDatasourceNames().containsAll(newOne.getActualDatasourceNames())) {
+            throw new ShardingSphereConfigurationException("The actualDatasourceNames on bindingTableGroup `%s` are inconsistent", bindingTableGroup);
+        }
+        checkSameAlgorithmOnDatabase(savedOne, newOne, savedOne.getActualDatasourceNames().stream().findFirst().get(), bindingTableGroup);
+        for (String dataSourceName : savedOne.getActualDatasourceNames()) {
+            Collection<String> savedActualTableNames = savedOne.getActualTableNames(dataSourceName).stream().map(each -> substring(each)[1])
+                    .filter(each -> !each.isEmpty()).collect(Collectors.toList());
+            Collection<String> newOneActualTableNames = newOne.getActualTableNames(dataSourceName).stream().map(each -> substring(each)[1])
+                    .filter(each -> !each.isEmpty()).collect(Collectors.toList());
+            if (!savedActualTableNames.containsAll(newOneActualTableNames)) {

Review comment:
       @cheese8 Is this logic correct? The real table corresponding to the binding table should be different.

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -204,6 +208,105 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        if (null == bindingTableGroups || bindingTableGroups.isEmpty()) {
+            return;
+        }
+        for (String bindingTableGroup : bindingTableGroups) {
+            List<String> bindingTableList = Splitter.on(",").trimResults().splitToList(bindingTableGroup.toLowerCase());
+            TableRule savedTableRule = null;
+            for (String bindingTable : bindingTableList) {
+                TableRule tableRule = bindingTableRules.get(bindingTable).getTableRules().get(bindingTable);
+                if (null == savedTableRule) {
+                    savedTableRule = tableRule;
+                } else {
+                    checkSameActualDatasourceNamesAndActualTableIndex(savedTableRule, tableRule, bindingTableGroup);
+                }
+            }
+        }
+    }
+    
+    private void checkSameActualDatasourceNamesAndActualTableIndex(final TableRule savedOne, final TableRule newOne, final String bindingTableGroup) {
+        if (!savedOne.getActualDatasourceNames().containsAll(newOne.getActualDatasourceNames())) {
+            throw new ShardingSphereConfigurationException("The actualDatasourceNames on bindingTableGroup `%s` are inconsistent", bindingTableGroup);
+        }
+        checkSameAlgorithmOnDatabase(savedOne, newOne, savedOne.getActualDatasourceNames().stream().findFirst().get(), bindingTableGroup);
+        for (String dataSourceName : savedOne.getActualDatasourceNames()) {

Review comment:
       Please rename dataSourceName to each.




-- 
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 #14864: validate whether the sharding rules of the binding tables are consistent

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


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/14864?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 [#14864](https://codecov.io/gh/apache/shardingsphere/pull/14864?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (95aaebf) into [master](https://codecov.io/gh/apache/shardingsphere/commit/d8ee21fb37f602512bafc4aa925450a52354658c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (d8ee21f) will **increase** coverage by `0.03%`.
   > The diff coverage is `72.85%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/14864/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/14864?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   #14864      +/-   ##
   ============================================
   + Coverage     60.49%   60.52%   +0.03%     
   - Complexity     1954     1976      +22     
   ============================================
     Files          3220     3220              
     Lines         48250    48328      +78     
     Branches       8233     8260      +27     
   ============================================
   + Hits          29188    29251      +63     
   + Misses        16692    16687       -5     
   - Partials       2370     2390      +20     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/14864?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...che/shardingsphere/sharding/rule/ShardingRule.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvcnVsZS9TaGFyZGluZ1J1bGUuamF2YQ==) | `78.74% <72.85%> (-1.90%)` | :arrow_down: |
   | [...ealtered/YamlOnRuleAlteredActionConfiguration.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS95YW1sL2NvbmZpZy9wb2pvL3J1bGVhbHRlcmVkL1lhbWxPblJ1bGVBbHRlcmVkQWN0aW9uQ29uZmlndXJhdGlvbi5qYXZh) | `11.11% <0.00%> (-88.89%)` | :arrow_down: |
   | [...persist/service/impl/DataSourcePersistService.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL21vZGUvbWV0YWRhdGEvcGVyc2lzdC9zZXJ2aWNlL2ltcGwvRGF0YVNvdXJjZVBlcnNpc3RTZXJ2aWNlLmphdmE=) | `70.00% <0.00%> (-6.93%)` | :arrow_down: |
   | [...ode/repository/standalone/file/FileRepository.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLXR5cGUvc2hhcmRpbmdzcGhlcmUtc3RhbmRhbG9uZS1tb2RlL3NoYXJkaW5nc3BoZXJlLXN0YW5kYWxvbmUtbW9kZS1yZXBvc2l0b3J5L3NoYXJkaW5nc3BoZXJlLXN0YW5kYWxvbmUtbW9kZS1yZXBvc2l0b3J5LXByb3ZpZGVyL3NoYXJkaW5nc3BoZXJlLXN0YW5kYWxvbmUtbW9kZS1yZXBvc2l0b3J5LWZpbGUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL21vZGUvcmVwb3NpdG9yeS9zdGFuZGFsb25lL2ZpbGUvRmlsZVJlcG9zaXRvcnkuamF2YQ==) | `51.21% <0.00%> (-4.05%)` | :arrow_down: |
   | [...istry/metadata/watcher/MetaDataChangedWatcher.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLXR5cGUvc2hhcmRpbmdzcGhlcmUtY2x1c3Rlci1tb2RlL3NoYXJkaW5nc3BoZXJlLWNsdXN0ZXItbW9kZS1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9tb2RlL21hbmFnZXIvY2x1c3Rlci9jb29yZGluYXRvci9yZWdpc3RyeS9tZXRhZGF0YS93YXRjaGVyL01ldGFEYXRhQ2hhbmdlZFdhdGNoZXIuamF2YQ==) | `79.54% <0.00%> (-2.28%)` | :arrow_down: |
   | [...driver/jdbc/core/connection/ConnectionManager.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtamRiYy9zaGFyZGluZ3NwaGVyZS1qZGJjLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RyaXZlci9qZGJjL2NvcmUvY29ubmVjdGlvbi9Db25uZWN0aW9uTWFuYWdlci5qYXZh) | `87.80% <0.00%> (-0.91%)` | :arrow_down: |
   | [...e/infra/config/props/ConfigurationPropertyKey.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9jb25maWcvcHJvcHMvQ29uZmlndXJhdGlvblByb3BlcnR5S2V5LmphdmE=) | `94.73% <0.00%> (-0.27%)` | :arrow_down: |
   | [.../apache/shardingsphere/shadow/rule/ShadowRule.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhZG93L3NoYXJkaW5nc3BoZXJlLXNoYWRvdy1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9zaGFkb3cvcnVsZS9TaGFkb3dSdWxlLmphdmE=) | `76.92% <0.00%> (ø)` | |
   | [...ite/context/EncryptSQLRewriteContextDecorator.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtZW5jcnlwdC9zaGFyZGluZ3NwaGVyZS1lbmNyeXB0LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2VuY3J5cHQvcmV3cml0ZS9jb250ZXh0L0VuY3J5cHRTUUxSZXdyaXRlQ29udGV4dERlY29yYXRvci5qYXZh) | `61.53% <0.00%> (ø)` | |
   | [...ql/handler/checker/ShadowRuleStatementChecker.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhZG93L3NoYXJkaW5nc3BoZXJlLXNoYWRvdy1kaXN0c3FsL3NoYXJkaW5nc3BoZXJlLXNoYWRvdy1kaXN0c3FsLWhhbmRsZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NoYWRvdy9kaXN0c3FsL2hhbmRsZXIvY2hlY2tlci9TaGFkb3dSdWxlU3RhdGVtZW50Q2hlY2tlci5qYXZh) | `92.30% <0.00%> (ø)` | |
   | ... and [11 more](https://codecov.io/gh/apache/shardingsphere/pull/14864/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/14864?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/14864?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 [d8ee21f...95aaebf](https://codecov.io/gh/apache/shardingsphere/pull/14864?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] codecov-commenter edited a comment on pull request #14864: validate whether the sharding rules of the binding tables are consistent

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


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/14864?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 [#14864](https://codecov.io/gh/apache/shardingsphere/pull/14864?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (00d38ac) into [master](https://codecov.io/gh/apache/shardingsphere/commit/d8ee21fb37f602512bafc4aa925450a52354658c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (d8ee21f) will **increase** coverage by `0.06%`.
   > The diff coverage is `73.52%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/14864/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/14864?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   #14864      +/-   ##
   ============================================
   + Coverage     60.49%   60.55%   +0.06%     
   - Complexity     1954     1979      +25     
   ============================================
     Files          3220     3223       +3     
     Lines         48250    48362     +112     
     Branches       8233     8267      +34     
   ============================================
   + Hits          29188    29287      +99     
   + Misses        16692    16669      -23     
   - Partials       2370     2406      +36     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/14864?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...che/shardingsphere/sharding/rule/ShardingRule.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvcnVsZS9TaGFyZGluZ1J1bGUuamF2YQ==) | `78.94% <73.52%> (-1.70%)` | :arrow_down: |
   | [...ealtered/YamlOnRuleAlteredActionConfiguration.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS95YW1sL2NvbmZpZy9wb2pvL3J1bGVhbHRlcmVkL1lhbWxPblJ1bGVBbHRlcmVkQWN0aW9uQ29uZmlndXJhdGlvbi5qYXZh) | `11.11% <0.00%> (-88.89%)` | :arrow_down: |
   | [...d/text/distsql/ral/common/hint/HintSourceType.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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: |
   | [...persist/service/impl/DataSourcePersistService.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL21vZGUvbWV0YWRhdGEvcGVyc2lzdC9zZXJ2aWNlL2ltcGwvRGF0YVNvdXJjZVBlcnNpc3RTZXJ2aWNlLmphdmE=) | `70.00% <0.00%> (-6.93%)` | :arrow_down: |
   | [...protocol/PostgreSQLNumericBinaryProtocolValue.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZGItcHJvdG9jb2wvc2hhcmRpbmdzcGhlcmUtZGItcHJvdG9jb2wtcG9zdGdyZXNxbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZGIvcHJvdG9jb2wvcG9zdGdyZXNxbC9wYWNrZXQvY29tbWFuZC9xdWVyeS9leHRlbmRlZC9iaW5kL3Byb3RvY29sL1Bvc3RncmVTUUxOdW1lcmljQmluYXJ5UHJvdG9jb2xWYWx1ZS5qYXZh) | `71.42% <0.00%> (-6.35%)` | :arrow_down: |
   | [...ode/repository/standalone/file/FileRepository.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLXR5cGUvc2hhcmRpbmdzcGhlcmUtc3RhbmRhbG9uZS1tb2RlL3NoYXJkaW5nc3BoZXJlLXN0YW5kYWxvbmUtbW9kZS1yZXBvc2l0b3J5L3NoYXJkaW5nc3BoZXJlLXN0YW5kYWxvbmUtbW9kZS1yZXBvc2l0b3J5LXByb3ZpZGVyL3NoYXJkaW5nc3BoZXJlLXN0YW5kYWxvbmUtbW9kZS1yZXBvc2l0b3J5LWZpbGUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL21vZGUvcmVwb3NpdG9yeS9zdGFuZGFsb25lL2ZpbGUvRmlsZVJlcG9zaXRvcnkuamF2YQ==) | `51.21% <0.00%> (-4.05%)` | :arrow_down: |
   | [...mode/metadata/persist/node/SchemaMetaDataNode.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL21vZGUvbWV0YWRhdGEvcGVyc2lzdC9ub2RlL1NjaGVtYU1ldGFEYXRhTm9kZS5qYXZh) | `78.26% <0.00%> (-2.99%)` | :arrow_down: |
   | [...ler/CreateShardingScalingRuleStatementUpdater.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctZGlzdHNxbC9zaGFyZGluZ3NwaGVyZS1zaGFyZGluZy1kaXN0c3FsLWhhbmRsZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvZGlzdHNxbC9oYW5kbGVyL0NyZWF0ZVNoYXJkaW5nU2NhbGluZ1J1bGVTdGF0ZW1lbnRVcGRhdGVyLmphdmE=) | `91.52% <0.00%> (-1.58%)` | :arrow_down: |
   | [...driver/jdbc/core/connection/ConnectionManager.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtamRiYy9zaGFyZGluZ3NwaGVyZS1qZGJjLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RyaXZlci9qZGJjL2NvcmUvY29ubmVjdGlvbi9Db25uZWN0aW9uTWFuYWdlci5qYXZh) | `87.80% <0.00%> (-0.91%)` | :arrow_down: |
   | [.../manager/cluster/ClusterContextManagerBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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=) | `72.91% <0.00%> (-0.56%)` | :arrow_down: |
   | ... and [27 more](https://codecov.io/gh/apache/shardingsphere/pull/14864/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/14864?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/14864?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 [d8ee21f...00d38ac](https://codecov.io/gh/apache/shardingsphere/pull/14864?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] codecov-commenter edited a comment on pull request #14864: validate whether the sharding rules of the binding tables are consistent

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


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/14864?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 [#14864](https://codecov.io/gh/apache/shardingsphere/pull/14864?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a0a5171) into [master](https://codecov.io/gh/apache/shardingsphere/commit/e3bad9f553c2432b31f54fe46252d613db5f716a?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (e3bad9f) will **increase** coverage by `0.02%`.
   > The diff coverage is `85.07%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/14864/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/14864?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   #14864      +/-   ##
   ============================================
   + Coverage     60.44%   60.47%   +0.02%     
   - Complexity     1960     1985      +25     
   ============================================
     Files          3230     3230              
     Lines         48614    48681      +67     
     Branches       8308     8321      +13     
   ============================================
   + Hits          29385    29439      +54     
   - Misses        16824    16830       +6     
   - Partials       2405     2412       +7     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/14864?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...che/shardingsphere/sharding/rule/ShardingRule.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvcnVsZS9TaGFyZGluZ1J1bGUuamF2YQ==) | `82.27% <85.07%> (+0.80%)` | :arrow_up: |
   | [...d/text/distsql/ral/common/hint/HintSourceType.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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/14864?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/14864?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 [e3bad9f...a0a5171](https://codecov.io/gh/apache/shardingsphere/pull/14864?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] cheese8 commented on a change in pull request #14864: validate whether the sharding rules of the binding tables are consistent

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



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -204,6 +208,105 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        if (null == bindingTableGroups || bindingTableGroups.isEmpty()) {
+            return;
+        }
+        for (String bindingTableGroup : bindingTableGroups) {
+            List<String> bindingTableList = Splitter.on(",").trimResults().splitToList(bindingTableGroup.toLowerCase());
+            TableRule savedTableRule = null;
+            for (String bindingTable : bindingTableList) {
+                TableRule tableRule = bindingTableRules.get(bindingTable).getTableRules().get(bindingTable);
+                if (null == savedTableRule) {
+                    savedTableRule = tableRule;
+                } else {
+                    checkSameActualDatasourceNamesAndActualTableIndex(savedTableRule, tableRule, bindingTableGroup);
+                }
+            }
+        }
+    }
+    
+    private void checkSameActualDatasourceNamesAndActualTableIndex(final TableRule savedOne, final TableRule newOne, final String bindingTableGroup) {
+        if (!savedOne.getActualDatasourceNames().containsAll(newOne.getActualDatasourceNames())) {
+            throw new ShardingSphereConfigurationException("The actualDatasourceNames on bindingTableGroup `%s` are inconsistent", bindingTableGroup);
+        }
+        checkSameAlgorithmOnDatabase(savedOne, newOne, savedOne.getActualDatasourceNames().stream().findFirst().get(), bindingTableGroup);
+        for (String dataSourceName : savedOne.getActualDatasourceNames()) {
+            Collection<String> savedActualTableNames = savedOne.getActualTableNames(dataSourceName).stream().map(each -> substring(each)[1])
+                    .filter(each -> !each.isEmpty()).collect(Collectors.toList());
+            Collection<String> newOneActualTableNames = newOne.getActualTableNames(dataSourceName).stream().map(each -> substring(each)[1])
+                    .filter(each -> !each.isEmpty()).collect(Collectors.toList());
+            if (!savedActualTableNames.containsAll(newOneActualTableNames)) {

Review comment:
       Yes, the code `stream().map(each -> substring(each)[1]).filter(each -> !each.isEmpty())`  the index substring out of the bindingTable, and then only compare the index collections.

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -204,6 +208,105 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        if (null == bindingTableGroups || bindingTableGroups.isEmpty()) {
+            return;
+        }
+        for (String bindingTableGroup : bindingTableGroups) {
+            List<String> bindingTableList = Splitter.on(",").trimResults().splitToList(bindingTableGroup.toLowerCase());
+            TableRule savedTableRule = null;
+            for (String bindingTable : bindingTableList) {
+                TableRule tableRule = bindingTableRules.get(bindingTable).getTableRules().get(bindingTable);
+                if (null == savedTableRule) {
+                    savedTableRule = tableRule;
+                } else {
+                    checkSameActualDatasourceNamesAndActualTableIndex(savedTableRule, tableRule, bindingTableGroup);
+                }
+            }
+        }
+    }
+    
+    private void checkSameActualDatasourceNamesAndActualTableIndex(final TableRule savedOne, final TableRule newOne, final String bindingTableGroup) {
+        if (!savedOne.getActualDatasourceNames().containsAll(newOne.getActualDatasourceNames())) {
+            throw new ShardingSphereConfigurationException("The actualDatasourceNames on bindingTableGroup `%s` are inconsistent", bindingTableGroup);
+        }
+        checkSameAlgorithmOnDatabase(savedOne, newOne, savedOne.getActualDatasourceNames().stream().findFirst().get(), bindingTableGroup);
+        for (String dataSourceName : savedOne.getActualDatasourceNames()) {
+            Collection<String> savedActualTableNames = savedOne.getActualTableNames(dataSourceName).stream().map(each -> substring(each)[1])
+                    .filter(each -> !each.isEmpty()).collect(Collectors.toList());
+            Collection<String> newOneActualTableNames = newOne.getActualTableNames(dataSourceName).stream().map(each -> substring(each)[1])
+                    .filter(each -> !each.isEmpty()).collect(Collectors.toList());
+            if (!savedActualTableNames.containsAll(newOneActualTableNames)) {
+                throw new ShardingSphereConfigurationException("The actualTableNames on bindingTableGroup `%s` are inconsistent", bindingTableGroup);
+            }
+            checkSameAlgorithmOnTable(savedOne, savedOne.getActualTableNames(dataSourceName).stream().findFirst().get(), newOne,
+                    newOne.getActualTableNames(dataSourceName).stream().findFirst().get(), bindingTableGroup);
+        }
+    }
+    
+    private void checkSameAlgorithmOnDatabase(final TableRule savedOne, final TableRule newOne, final String dataSourceName,
+                                              final String bindingTableGroup) {
+        Collection<String[]> args = new ArrayList<>();

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] cheese8 commented on a change in pull request #14864: validate whether the sharding rules of the binding tables are consistent

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



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -204,6 +208,105 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        if (null == bindingTableGroups || bindingTableGroups.isEmpty()) {
+            return;
+        }
+        for (String bindingTableGroup : bindingTableGroups) {
+            List<String> bindingTableList = Splitter.on(",").trimResults().splitToList(bindingTableGroup.toLowerCase());
+            TableRule savedTableRule = null;
+            for (String bindingTable : bindingTableList) {
+                TableRule tableRule = bindingTableRules.get(bindingTable).getTableRules().get(bindingTable);
+                if (null == savedTableRule) {
+                    savedTableRule = tableRule;
+                } else {
+                    checkSameActualDatasourceNamesAndActualTableIndex(savedTableRule, tableRule, bindingTableGroup);
+                }
+            }
+        }
+    }
+    
+    private void checkSameActualDatasourceNamesAndActualTableIndex(final TableRule savedOne, final TableRule newOne, final String bindingTableGroup) {
+        if (!savedOne.getActualDatasourceNames().containsAll(newOne.getActualDatasourceNames())) {
+            throw new ShardingSphereConfigurationException("The actualDatasourceNames on bindingTableGroup `%s` are inconsistent", bindingTableGroup);

Review comment:
       ok

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -204,6 +208,105 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        if (null == bindingTableGroups || bindingTableGroups.isEmpty()) {
+            return;
+        }
+        for (String bindingTableGroup : bindingTableGroups) {
+            List<String> bindingTableList = Splitter.on(",").trimResults().splitToList(bindingTableGroup.toLowerCase());
+            TableRule savedTableRule = null;
+            for (String bindingTable : bindingTableList) {
+                TableRule tableRule = bindingTableRules.get(bindingTable).getTableRules().get(bindingTable);
+                if (null == savedTableRule) {
+                    savedTableRule = tableRule;
+                } else {
+                    checkSameActualDatasourceNamesAndActualTableIndex(savedTableRule, tableRule, bindingTableGroup);
+                }
+            }
+        }
+    }
+    
+    private void checkSameActualDatasourceNamesAndActualTableIndex(final TableRule savedOne, final TableRule newOne, final String bindingTableGroup) {
+        if (!savedOne.getActualDatasourceNames().containsAll(newOne.getActualDatasourceNames())) {
+            throw new ShardingSphereConfigurationException("The actualDatasourceNames on bindingTableGroup `%s` are inconsistent", bindingTableGroup);
+        }
+        checkSameAlgorithmOnDatabase(savedOne, newOne, savedOne.getActualDatasourceNames().stream().findFirst().get(), bindingTableGroup);
+        for (String dataSourceName : savedOne.getActualDatasourceNames()) {

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] strongduanmu merged pull request #14864: validate whether the sharding rules of the binding tables are consistent

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


   


-- 
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] strongduanmu commented on a change in pull request #14864: validate whether the sharding rules of the binding tables are consistent

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



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -203,6 +212,60 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         result.getTableRules().putAll(tableRules);
         return result;
     }
+
+    private void checkTheSameActualDataSourceNamesAndActualTableIndex(final Collection<String> bindingTableGroups, final Collection<ShardingTableRuleConfiguration> tables) {
+        if (null == bindingTableGroups || bindingTableGroups.size() <= 0) {

Review comment:
       @cheese8 Do you think `bindingTableGroups.isEmpty()` is better?

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -203,6 +212,60 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         result.getTableRules().putAll(tableRules);
         return result;
     }
+
+    private void checkTheSameActualDataSourceNamesAndActualTableIndex(final Collection<String> bindingTableGroups, final Collection<ShardingTableRuleConfiguration> tables) {
+        if (null == bindingTableGroups || bindingTableGroups.size() <= 0) {
+            return;
+        }
+        Iterator<String> itBindingTableGroups = bindingTableGroups.iterator();
+        Map<String, ShardingTableRuleConfiguration> shardingTableRuleConfigurationMap = tables.stream().collect(Collectors.toMap(ShardingTableRuleConfiguration::getLogicTable, Function.identity()));
+        while (itBindingTableGroups.hasNext()) {

Review comment:
       Can we use foreach here?

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -203,6 +212,60 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         result.getTableRules().putAll(tableRules);
         return result;
     }
+
+    private void checkTheSameActualDataSourceNamesAndActualTableIndex(final Collection<String> bindingTableGroups, final Collection<ShardingTableRuleConfiguration> tables) {
+        if (null == bindingTableGroups || bindingTableGroups.size() <= 0) {
+            return;
+        }
+        Iterator<String> itBindingTableGroups = bindingTableGroups.iterator();
+        Map<String, ShardingTableRuleConfiguration> shardingTableRuleConfigurationMap = tables.stream().collect(Collectors.toMap(ShardingTableRuleConfiguration::getLogicTable, Function.identity()));
+        while (itBindingTableGroups.hasNext()) {
+            String bindingTableGroup = itBindingTableGroups.next();
+            List<String> bindingTableList = Splitter.on(",").trimResults().splitToList(bindingTableGroup);
+            List<Object> savedActualDataNodesList = null;
+            for (String bindingTable : bindingTableList) {
+                ShardingTableRuleConfiguration shardingTableRuleConfiguration = shardingTableRuleConfigurationMap.get(bindingTable);
+                if (null == shardingTableRuleConfiguration) {
+                    continue;
+                }
+                String actualDataNodes = shardingTableRuleConfiguration.getActualDataNodes();
+                if (null == actualDataNodes) {
+                    continue;
+                }
+                if (null == savedActualDataNodesList || savedActualDataNodesList.size() == 0) {
+                    savedActualDataNodesList = new InlineExpressionParser(actualDataNodes).splitAndEvaluateNotFlatten();

Review comment:
       @cheese8 Why not use bindingTableRules for judgement?

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -132,6 +140,7 @@ public ShardingRule(final AlgorithmProvidedShardingRuleConfiguration config, fin
         defaultKeyGenerateAlgorithm = null == config.getDefaultKeyGenerateStrategy()
                 ? RequiredSPIRegistry.getRegisteredService(KeyGenerateAlgorithm.class) : keyGenerators.get(config.getDefaultKeyGenerateStrategy().getKeyGeneratorName());
         defaultShardingColumn = config.getDefaultShardingColumn();
+        checkTheSameActualDataSourceNamesAndActualTableIndex(config.getBindingTableGroups(), config.getTables());

Review comment:
       Do you think `checkSameBindingTables` is better?




-- 
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] cheese8 commented on a change in pull request #14864: validate whether the sharding rules of the binding tables are consistent

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



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -204,6 +208,105 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        if (null == bindingTableGroups || bindingTableGroups.isEmpty()) {
+            return;
+        }
+        for (String bindingTableGroup : bindingTableGroups) {
+            List<String> bindingTableList = Splitter.on(",").trimResults().splitToList(bindingTableGroup.toLowerCase());
+            TableRule savedTableRule = null;
+            for (String bindingTable : bindingTableList) {
+                TableRule tableRule = bindingTableRules.get(bindingTable).getTableRules().get(bindingTable);
+                if (null == savedTableRule) {
+                    savedTableRule = tableRule;
+                } else {
+                    checkSameActualDatasourceNamesAndActualTableIndex(savedTableRule, tableRule, bindingTableGroup);
+                }
+            }
+        }
+    }
+    
+    private void checkSameActualDatasourceNamesAndActualTableIndex(final TableRule savedOne, final TableRule newOne, final String bindingTableGroup) {

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] cheese8 commented on a change in pull request #14864: validate whether the sharding rules of the binding tables are consistent

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



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -204,6 +208,105 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        if (null == bindingTableGroups || bindingTableGroups.isEmpty()) {
+            return;
+        }
+        for (String bindingTableGroup : bindingTableGroups) {

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 pull request #14864: validate whether the sharding rules of the binding tables are consistent

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on pull request #14864:
URL: https://github.com/apache/shardingsphere/pull/14864#issuecomment-1015472805


   The problem of CI failure has been fixed in #14847, please merge the master branch and push again, thank you!


-- 
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] cheese8 commented on a change in pull request #14864: validate whether the sharding rules of the binding tables are consistent

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



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -216,6 +221,104 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        for (String each : bindingTableGroups) {
+            List<String> bindingTableList = Splitter.on(",").trimResults().splitToList(each.toLowerCase());
+            TableRule sampleTableRule = null;
+            for (String bindingTable : bindingTableList) {
+                TableRule tableRule = bindingTableRules.get(bindingTable).getTableRules().get(bindingTable);
+                if (null == sampleTableRule) {
+                    sampleTableRule = tableRule;
+                } else {
+                    checkSameActualDatasourceNamesAndActualTableIndex(sampleTableRule, tableRule, each);
+                }
+            }
+        }
+    }
+    
+    private void checkSameActualDatasourceNamesAndActualTableIndex(final TableRule sampleTableRule, final TableRule tableRule, final String bindingTableGroup) {
+        if (!CollectionUtils.isEqualCollection(sampleTableRule.getActualDatasourceNames(), tableRule.getActualDatasourceNames())) {
+            throw new ShardingSphereConfigurationException("The %s on bindingTableGroup `%s` are inconsistent", "actualDatasourceNames", bindingTableGroup);
+        }
+        checkSameAlgorithmOnDatabase(sampleTableRule, tableRule, sampleTableRule.getActualDatasourceNames().stream().findFirst().get(), bindingTableGroup);
+        for (String each : sampleTableRule.getActualDatasourceNames()) {
+            Collection<String> sampleActualTableNames = sampleTableRule.getActualTableNames(each).stream().map(optional -> substring(optional)[1])
+                    .filter(optional -> !optional.isEmpty()).collect(Collectors.toList());
+            Collection<String> actualTableNames = tableRule.getActualTableNames(each).stream().map(optional -> substring(optional)[1])
+                    .filter(optional -> !optional.isEmpty()).collect(Collectors.toList());
+            if (!CollectionUtils.isEqualCollection(sampleActualTableNames, actualTableNames)) {
+                throw new ShardingSphereConfigurationException("The %s on bindingTableGroup `%s` are inconsistent", "actualTableNames", bindingTableGroup);
+            }
+            checkSameAlgorithmOnTable(sampleTableRule, sampleTableRule.getActualTableNames(each).stream().findFirst().get(), tableRule,
+                    tableRule.getActualTableNames(each).stream().findFirst().get(), bindingTableGroup);
+        }
+    }
+    
+    private void checkSameAlgorithmOnDatabase(final TableRule sampleTableRule, final TableRule tableRule, final String dataSourceName,
+                                              final String bindingTableGroup) {
+        Collection<String[]> algorithmExpressions = new ArrayList<>();

Review comment:
       OK

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -216,6 +221,104 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        for (String each : bindingTableGroups) {
+            List<String> bindingTableList = Splitter.on(",").trimResults().splitToList(each.toLowerCase());
+            TableRule sampleTableRule = null;
+            for (String bindingTable : bindingTableList) {
+                TableRule tableRule = bindingTableRules.get(bindingTable).getTableRules().get(bindingTable);
+                if (null == sampleTableRule) {
+                    sampleTableRule = tableRule;
+                } else {
+                    checkSameActualDatasourceNamesAndActualTableIndex(sampleTableRule, tableRule, each);
+                }
+            }
+        }
+    }
+    
+    private void checkSameActualDatasourceNamesAndActualTableIndex(final TableRule sampleTableRule, final TableRule tableRule, final String bindingTableGroup) {
+        if (!CollectionUtils.isEqualCollection(sampleTableRule.getActualDatasourceNames(), tableRule.getActualDatasourceNames())) {

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] strongduanmu commented on a change in pull request #14864: validate whether the sharding rules of the binding tables are consistent

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



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -216,6 +221,104 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        for (String each : bindingTableGroups) {
+            List<String> bindingTableList = Splitter.on(",").trimResults().splitToList(each.toLowerCase());
+            TableRule sampleTableRule = null;
+            for (String bindingTable : bindingTableList) {
+                TableRule tableRule = bindingTableRules.get(bindingTable).getTableRules().get(bindingTable);
+                if (null == sampleTableRule) {
+                    sampleTableRule = tableRule;
+                } else {
+                    checkSameActualDatasourceNamesAndActualTableIndex(sampleTableRule, tableRule, each);
+                }
+            }
+        }
+    }
+    
+    private void checkSameActualDatasourceNamesAndActualTableIndex(final TableRule sampleTableRule, final TableRule tableRule, final String bindingTableGroup) {
+        if (!CollectionUtils.isEqualCollection(sampleTableRule.getActualDatasourceNames(), tableRule.getActualDatasourceNames())) {

Review comment:
       @cheese8 Can we remove this util class? Replace it with `sampleTableRule.getActualDatasourceNames().equals( tableRule.getActualDatasourceNames()))`

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -216,6 +221,104 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        for (String each : bindingTableGroups) {
+            List<String> bindingTableList = Splitter.on(",").trimResults().splitToList(each.toLowerCase());
+            TableRule sampleTableRule = null;
+            for (String bindingTable : bindingTableList) {
+                TableRule tableRule = bindingTableRules.get(bindingTable).getTableRules().get(bindingTable);
+                if (null == sampleTableRule) {
+                    sampleTableRule = tableRule;
+                } else {
+                    checkSameActualDatasourceNamesAndActualTableIndex(sampleTableRule, tableRule, each);
+                }
+            }
+        }
+    }
+    
+    private void checkSameActualDatasourceNamesAndActualTableIndex(final TableRule sampleTableRule, final TableRule tableRule, final String bindingTableGroup) {
+        if (!CollectionUtils.isEqualCollection(sampleTableRule.getActualDatasourceNames(), tableRule.getActualDatasourceNames())) {
+            throw new ShardingSphereConfigurationException("The %s on bindingTableGroup `%s` are inconsistent", "actualDatasourceNames", bindingTableGroup);
+        }
+        checkSameAlgorithmOnDatabase(sampleTableRule, tableRule, sampleTableRule.getActualDatasourceNames().stream().findFirst().get(), bindingTableGroup);
+        for (String each : sampleTableRule.getActualDatasourceNames()) {
+            Collection<String> sampleActualTableNames = sampleTableRule.getActualTableNames(each).stream().map(optional -> substring(optional)[1])
+                    .filter(optional -> !optional.isEmpty()).collect(Collectors.toList());
+            Collection<String> actualTableNames = tableRule.getActualTableNames(each).stream().map(optional -> substring(optional)[1])
+                    .filter(optional -> !optional.isEmpty()).collect(Collectors.toList());
+            if (!CollectionUtils.isEqualCollection(sampleActualTableNames, actualTableNames)) {
+                throw new ShardingSphereConfigurationException("The %s on bindingTableGroup `%s` are inconsistent", "actualTableNames", bindingTableGroup);
+            }
+            checkSameAlgorithmOnTable(sampleTableRule, sampleTableRule.getActualTableNames(each).stream().findFirst().get(), tableRule,
+                    tableRule.getActualTableNames(each).stream().findFirst().get(), bindingTableGroup);
+        }
+    }
+    
+    private void checkSameAlgorithmOnDatabase(final TableRule sampleTableRule, final TableRule tableRule, final String dataSourceName,
+                                              final String bindingTableGroup) {
+        Collection<String[]> algorithmExpressions = new ArrayList<>();
+        String logicName = substring(dataSourceName)[0];
+        algorithmExpressions.add(new String[] {getAlgorithmExpression(sampleTableRule, true), logicName, getShardingColumn(sampleTableRule.getDatabaseShardingStrategyConfig())});
+        algorithmExpressions.add(new String[] {getAlgorithmExpression(tableRule, true), logicName, getShardingColumn(tableRule.getDatabaseShardingStrategyConfig())});
+        checkSameAlgorithmExpression(algorithmExpressions, "databaseShardingStrategyConfig", bindingTableGroup);
+    }
+    
+    private String getAlgorithmExpression(final TableRule tableRule, final boolean databaseOrTable) {
+        if (null == tableRule.getDatabaseShardingStrategyConfig() || null == tableRule.getTableShardingStrategyConfig()) {

Review comment:
       Is this logic wrong when check table sharding?

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -216,6 +221,104 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        for (String each : bindingTableGroups) {
+            List<String> bindingTableList = Splitter.on(",").trimResults().splitToList(each.toLowerCase());
+            TableRule sampleTableRule = null;
+            for (String bindingTable : bindingTableList) {
+                TableRule tableRule = bindingTableRules.get(bindingTable).getTableRules().get(bindingTable);
+                if (null == sampleTableRule) {
+                    sampleTableRule = tableRule;
+                } else {
+                    checkSameActualDatasourceNamesAndActualTableIndex(sampleTableRule, tableRule, each);
+                }
+            }
+        }
+    }
+    
+    private void checkSameActualDatasourceNamesAndActualTableIndex(final TableRule sampleTableRule, final TableRule tableRule, final String bindingTableGroup) {
+        if (!CollectionUtils.isEqualCollection(sampleTableRule.getActualDatasourceNames(), tableRule.getActualDatasourceNames())) {
+            throw new ShardingSphereConfigurationException("The %s on bindingTableGroup `%s` are inconsistent", "actualDatasourceNames", bindingTableGroup);
+        }
+        checkSameAlgorithmOnDatabase(sampleTableRule, tableRule, sampleTableRule.getActualDatasourceNames().stream().findFirst().get(), bindingTableGroup);
+        for (String each : sampleTableRule.getActualDatasourceNames()) {
+            Collection<String> sampleActualTableNames = sampleTableRule.getActualTableNames(each).stream().map(optional -> substring(optional)[1])
+                    .filter(optional -> !optional.isEmpty()).collect(Collectors.toList());
+            Collection<String> actualTableNames = tableRule.getActualTableNames(each).stream().map(optional -> substring(optional)[1])
+                    .filter(optional -> !optional.isEmpty()).collect(Collectors.toList());
+            if (!CollectionUtils.isEqualCollection(sampleActualTableNames, actualTableNames)) {
+                throw new ShardingSphereConfigurationException("The %s on bindingTableGroup `%s` are inconsistent", "actualTableNames", bindingTableGroup);
+            }
+            checkSameAlgorithmOnTable(sampleTableRule, sampleTableRule.getActualTableNames(each).stream().findFirst().get(), tableRule,
+                    tableRule.getActualTableNames(each).stream().findFirst().get(), bindingTableGroup);
+        }
+    }
+    
+    private void checkSameAlgorithmOnDatabase(final TableRule sampleTableRule, final TableRule tableRule, final String dataSourceName,
+                                              final String bindingTableGroup) {
+        Collection<String[]> algorithmExpressions = new ArrayList<>();
+        String logicName = substring(dataSourceName)[0];
+        algorithmExpressions.add(new String[] {getAlgorithmExpression(sampleTableRule, true), logicName, getShardingColumn(sampleTableRule.getDatabaseShardingStrategyConfig())});
+        algorithmExpressions.add(new String[] {getAlgorithmExpression(tableRule, true), logicName, getShardingColumn(tableRule.getDatabaseShardingStrategyConfig())});
+        checkSameAlgorithmExpression(algorithmExpressions, "databaseShardingStrategyConfig", bindingTableGroup);
+    }
+    
+    private String getAlgorithmExpression(final TableRule tableRule, final boolean databaseOrTable) {
+        if (null == tableRule.getDatabaseShardingStrategyConfig() || null == tableRule.getTableShardingStrategyConfig()) {
+            return "";
+        }
+        String shardingAlgorithmName = databaseOrTable ? tableRule.getDatabaseShardingStrategyConfig().getShardingAlgorithmName()
+                : tableRule.getTableShardingStrategyConfig().getShardingAlgorithmName();
+        ShardingAlgorithm shardingAlgorithm = shardingAlgorithms.get(shardingAlgorithmName);
+        return null == shardingAlgorithm ? "" : checkWithDefaultValue(shardingAlgorithm.getProps().getProperty("algorithm-expression"), "");
+    }
+    
+    private String checkWithDefaultValue(final String str, final String defaultValue) {

Review comment:
       @cheese8 Can we remove this method with `StringUtils.defaultString()`?

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
##########
@@ -216,6 +221,104 @@ private BindingTableRule createBindingTableRule(final String bindingTableGroup)
         return result;
     }
     
+    private void checkSameBindingTables(final Collection<String> bindingTableGroups, final Map<String, BindingTableRule> bindingTableRules) {
+        for (String each : bindingTableGroups) {
+            List<String> bindingTableList = Splitter.on(",").trimResults().splitToList(each.toLowerCase());
+            TableRule sampleTableRule = null;
+            for (String bindingTable : bindingTableList) {
+                TableRule tableRule = bindingTableRules.get(bindingTable).getTableRules().get(bindingTable);
+                if (null == sampleTableRule) {
+                    sampleTableRule = tableRule;
+                } else {
+                    checkSameActualDatasourceNamesAndActualTableIndex(sampleTableRule, tableRule, each);
+                }
+            }
+        }
+    }
+    
+    private void checkSameActualDatasourceNamesAndActualTableIndex(final TableRule sampleTableRule, final TableRule tableRule, final String bindingTableGroup) {
+        if (!CollectionUtils.isEqualCollection(sampleTableRule.getActualDatasourceNames(), tableRule.getActualDatasourceNames())) {
+            throw new ShardingSphereConfigurationException("The %s on bindingTableGroup `%s` are inconsistent", "actualDatasourceNames", bindingTableGroup);
+        }
+        checkSameAlgorithmOnDatabase(sampleTableRule, tableRule, sampleTableRule.getActualDatasourceNames().stream().findFirst().get(), bindingTableGroup);
+        for (String each : sampleTableRule.getActualDatasourceNames()) {
+            Collection<String> sampleActualTableNames = sampleTableRule.getActualTableNames(each).stream().map(optional -> substring(optional)[1])
+                    .filter(optional -> !optional.isEmpty()).collect(Collectors.toList());
+            Collection<String> actualTableNames = tableRule.getActualTableNames(each).stream().map(optional -> substring(optional)[1])
+                    .filter(optional -> !optional.isEmpty()).collect(Collectors.toList());
+            if (!CollectionUtils.isEqualCollection(sampleActualTableNames, actualTableNames)) {
+                throw new ShardingSphereConfigurationException("The %s on bindingTableGroup `%s` are inconsistent", "actualTableNames", bindingTableGroup);
+            }
+            checkSameAlgorithmOnTable(sampleTableRule, sampleTableRule.getActualTableNames(each).stream().findFirst().get(), tableRule,
+                    tableRule.getActualTableNames(each).stream().findFirst().get(), bindingTableGroup);
+        }
+    }
+    
+    private void checkSameAlgorithmOnDatabase(final TableRule sampleTableRule, final TableRule tableRule, final String dataSourceName,
+                                              final String bindingTableGroup) {
+        Collection<String[]> algorithmExpressions = new ArrayList<>();

Review comment:
       @cheese8 LinkedList may be better.




-- 
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 #14864: validate whether the sharding rules of the binding tables are consistent

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


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/14864?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 [#14864](https://codecov.io/gh/apache/shardingsphere/pull/14864?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (8a25566) into [master](https://codecov.io/gh/apache/shardingsphere/commit/204f8005d46764c720d737e04a5b4b89134506bb?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (204f800) will **increase** coverage by `0.14%`.
   > The diff coverage is `82.35%`.
   
   > :exclamation: Current head 8a25566 differs from pull request most recent head ff9fef4. Consider uploading reports for the commit ff9fef4 to get more accurate results
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/14864/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/14864?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   #14864      +/-   ##
   ============================================
   + Coverage     60.38%   60.52%   +0.14%     
   - Complexity     1996     2038      +42     
   ============================================
     Files          3247     3264      +17     
     Lines         48887    49213     +326     
     Branches       8356     8431      +75     
   ============================================
   + Hits          29521    29788     +267     
   - Misses        16927    16961      +34     
   - Partials       2439     2464      +25     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/14864?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...che/shardingsphere/sharding/rule/ShardingRule.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvcnVsZS9TaGFyZGluZ1J1bGUuamF2YQ==) | `81.60% <82.35%> (+0.22%)` | :arrow_up: |
   | [...here/infra/binder/segment/table/TablesContext.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtYmluZGVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9iaW5kZXIvc2VnbWVudC90YWJsZS9UYWJsZXNDb250ZXh0LmphdmE=) | `56.42% <0.00%> (-14.75%)` | :arrow_down: |
   | [...ken/generator/EncryptProjectionTokenGenerator.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtZW5jcnlwdC9zaGFyZGluZ3NwaGVyZS1lbmNyeXB0LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2VuY3J5cHQvcmV3cml0ZS90b2tlbi9nZW5lcmF0b3IvRW5jcnlwdFByb2plY3Rpb25Ub2tlbkdlbmVyYXRvci5qYXZh) | `32.65% <0.00%> (-5.59%)` | :arrow_down: |
   | [...ase/metadata/dialect/OracleDataSourceMetaData.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kYXRhYmFzZS9tZXRhZGF0YS9kaWFsZWN0L09yYWNsZURhdGFTb3VyY2VNZXRhRGF0YS5qYXZh) | `85.00% <0.00%> (-5.48%)` | :arrow_down: |
   | [...distsql/rdl/rule/RuleDefinitionBackendHandler.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC90ZXh0L2Rpc3RzcWwvcmRsL3J1bGUvUnVsZURlZmluaXRpb25CYWNrZW5kSGFuZGxlci5qYXZh) | `53.52% <0.00%> (-2.82%)` | :arrow_down: |
   | [...datasource/pool/creator/DataSourcePoolCreator.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kYXRhc291cmNlL3Bvb2wvY3JlYXRvci9EYXRhU291cmNlUG9vbENyZWF0b3IuamF2YQ==) | `72.97% <0.00%> (-2.03%)` | :arrow_down: |
   | [.../parser/sql/common/util/ExpressionExtractUtil.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLXN0YXRlbWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9zcWwvY29tbW9uL3V0aWwvRXhwcmVzc2lvbkV4dHJhY3RVdGlsLmphdmE=) | `90.47% <0.00%> (-1.63%)` | :arrow_down: |
   | [...ken/pojo/generic/SubstitutableColumnNameToken.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtcmV3cml0ZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvaW5mcmEvcmV3cml0ZS9zcWwvdG9rZW4vcG9qby9nZW5lcmljL1N1YnN0aXR1dGFibGVDb2x1bW5OYW1lVG9rZW4uamF2YQ==) | `67.56% <0.00%> (-0.86%)` | :arrow_down: |
   | [...ana/config/NarayanaConfigurationFileGenerator.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLXRyYW5zYWN0aW9uL3NoYXJkaW5nc3BoZXJlLXRyYW5zYWN0aW9uLXR5cGUvc2hhcmRpbmdzcGhlcmUtdHJhbnNhY3Rpb24teGEvc2hhcmRpbmdzcGhlcmUtdHJhbnNhY3Rpb24teGEtcHJvdmlkZXIvc2hhcmRpbmdzcGhlcmUtdHJhbnNhY3Rpb24teGEtbmFyYXlhbmEvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3RyYW5zYWN0aW9uL3hhL25hcmF5YW5hL2NvbmZpZy9OYXJheWFuYUNvbmZpZ3VyYXRpb25GaWxlR2VuZXJhdG9yLmphdmE=) | `60.00% <0.00%> (-0.61%)` | :arrow_down: |
   | [...re/infra/rewrite/engine/RouteSQLRewriteEngine.java](https://codecov.io/gh/apache/shardingsphere/pull/14864/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtcmV3cml0ZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvaW5mcmEvcmV3cml0ZS9lbmdpbmUvUm91dGVTUUxSZXdyaXRlRW5naW5lLmphdmE=) | `74.57% <0.00%> (-0.43%)` | :arrow_down: |
   | ... and [85 more](https://codecov.io/gh/apache/shardingsphere/pull/14864/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/14864?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/14864?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 [204f800...ff9fef4](https://codecov.io/gh/apache/shardingsphere/pull/14864?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