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/07/11 11:12:12 UTC

[GitHub] [shardingsphere] runqi-zhao opened a new pull request, #19033: Add more unit test for ShardingCopyStatementValidator

runqi-zhao opened a new pull request, #19033:
URL: https://github.com/apache/shardingsphere/pull/19033

   Fixes #16617.
   
   Changes proposed in this pull request:
   - Add more unit test for ShardingCopyStatementValidator
   


-- 
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 diff in pull request #19033: Add more unit test for ShardingCopyStatementValidator

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on code in PR #19033:
URL: https://github.com/apache/shardingsphere/pull/19033#discussion_r917840966


##########
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingCopyStatementValidatorTest.java:
##########
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sharding.route.engine.validator.dml;
+
+import org.apache.shardingsphere.infra.binder.statement.dml.CopyStatementContext;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.sharding.route.engine.validator.dml.impl.ShardingCopyStatementValidator;
+import org.apache.shardingsphere.sharding.rule.ShardingRule;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.TableNameSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.dml.OpenGaussCopyStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.dml.PostgreSQLCopyStatement;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import java.util.Collections;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ShardingCopyStatementValidatorTest {
+    
+    @Mock
+    private ShardingRule shardingRule;
+    
+    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+    private ShardingSphereDatabase database;
+    
+    @Test
+    public void assertPreValidateWhenTableSegmentForPostgreSQL() {
+        PostgreSQLCopyStatement sqlStatement = new PostgreSQLCopyStatement();
+        sqlStatement.setTableSegment(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order"))));
+        new ShardingCopyStatementValidator().preValidate(shardingRule, new CopyStatementContext(sqlStatement), Collections.emptyList(), database);

Review Comment:
   @runqi-zhao Can you add one more test case for sharding table? 



-- 
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] runqi-zhao commented on pull request #19033: Add more unit test for ShardingCopyStatementValidator

Posted by GitBox <gi...@apache.org>.
runqi-zhao commented on PR #19033:
URL: https://github.com/apache/shardingsphere/pull/19033#issuecomment-1180524980

   @strongduanmu  This is my assumption, there may be imperfect place, if there is something wrong, please correct


-- 
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] runqi-zhao commented on pull request #19033: Add more unit test for ShardingCopyStatementValidator

Posted by GitBox <gi...@apache.org>.
runqi-zhao commented on PR #19033:
URL: https://github.com/apache/shardingsphere/pull/19033#issuecomment-1180525746

   @strongduanmu This is my assumption, there may be imperfect place, if there is something wrong, please correct


-- 
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 #19033: Add more unit test for ShardingCopyStatementValidator

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

   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/19033?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 [#19033](https://codecov.io/gh/apache/shardingsphere/pull/19033?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (ccae312) into [master](https://codecov.io/gh/apache/shardingsphere/commit/8288ed33f59f40f9c1ddd3398d91ac680a66f5bd?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (8288ed3) will **increase** coverage by `0.00%`.
   > The diff coverage is `57.05%`.
   
   > :exclamation: Current head ccae312 differs from pull request most recent head 768720d. Consider uploading reports for the commit 768720d to get more accurate results
   
   ```diff
   @@            Coverage Diff            @@
   ##             master   #19033   +/-   ##
   =========================================
     Coverage     59.44%   59.45%           
   - Complexity     2318     2320    +2     
   =========================================
     Files          3800     3803    +3     
     Lines         54659    54691   +32     
     Branches       9238     9234    -4     
   =========================================
   + Hits          32492    32515   +23     
   - Misses        19437    19451   +14     
   + Partials       2730     2725    -5     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/19033?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...dingsphere/dbdiscovery/heartbeat/HeartbeatJob.java](https://codecov.io/gh/apache/shardingsphere/pull/19033/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtZGItZGlzY292ZXJ5L3NoYXJkaW5nc3BoZXJlLWRiLWRpc2NvdmVyeS1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9kYmRpc2NvdmVyeS9oZWFydGJlYXQvSGVhcnRiZWF0Sm9iLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...sharding/ComplexShardingStrategyConfiguration.java](https://codecov.io/gh/apache/shardingsphere/pull/19033/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9zaGFyZGluZy9hcGkvY29uZmlnL3N0cmF0ZWd5L3NoYXJkaW5nL0NvbXBsZXhTaGFyZGluZ1N0cmF0ZWd5Q29uZmlndXJhdGlvbi5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...gy/sharding/HintShardingStrategyConfiguration.java](https://codecov.io/gh/apache/shardingsphere/pull/19033/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9zaGFyZGluZy9hcGkvY29uZmlnL3N0cmF0ZWd5L3NoYXJkaW5nL0hpbnRTaGFyZGluZ1N0cmF0ZWd5Q29uZmlndXJhdGlvbi5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...gy/sharding/NoneShardingStrategyConfiguration.java](https://codecov.io/gh/apache/shardingsphere/pull/19033/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9zaGFyZGluZy9hcGkvY29uZmlnL3N0cmF0ZWd5L3NoYXJkaW5nL05vbmVTaGFyZGluZ1N0cmF0ZWd5Q29uZmlndXJhdGlvbi5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...harding/StandardShardingStrategyConfiguration.java](https://codecov.io/gh/apache/shardingsphere/pull/19033/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9zaGFyZGluZy9hcGkvY29uZmlnL3N0cmF0ZWd5L3NoYXJkaW5nL1N0YW5kYXJkU2hhcmRpbmdTdHJhdGVneUNvbmZpZ3VyYXRpb24uamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...ecute/engine/driver/jdbc/JDBCExecutorCallback.java](https://codecov.io/gh/apache/shardingsphere/pull/19033/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtZXhlY3V0b3Ivc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2luZnJhL2V4ZWN1dG9yL3NxbC9leGVjdXRlL2VuZ2luZS9kcml2ZXIvamRiYy9KREJDRXhlY3V0b3JDYWxsYmFjay5qYXZh) | `65.71% <0.00%> (ø)` | |
   | [...a/executor/sql/execute/engine/raw/RawExecutor.java](https://codecov.io/gh/apache/shardingsphere/pull/19033/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtZXhlY3V0b3Ivc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2luZnJhL2V4ZWN1dG9yL3NxbC9leGVjdXRlL2VuZ2luZS9yYXcvUmF3RXhlY3V0b3IuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...te/engine/raw/callback/RawSQLExecutorCallback.java](https://codecov.io/gh/apache/shardingsphere/pull/19033/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtZXhlY3V0b3Ivc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2luZnJhL2V4ZWN1dG9yL3NxbC9leGVjdXRlL2VuZ2luZS9yYXcvY2FsbGJhY2svUmF3U1FMRXhlY3V0b3JDYWxsYmFjay5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...federation/executor/FederationExecutorFactory.java](https://codecov.io/gh/apache/shardingsphere/pull/19033/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtZmVkZXJhdGlvbi9zaGFyZGluZ3NwaGVyZS1pbmZyYS1mZWRlcmF0aW9uLWV4ZWN1dG9yL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9mZWRlcmF0aW9uL2V4ZWN1dG9yL0ZlZGVyYXRpb25FeGVjdXRvckZhY3RvcnkuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [.../executor/original/OriginalFederationExecutor.java](https://codecov.io/gh/apache/shardingsphere/pull/19033/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtZmVkZXJhdGlvbi9zaGFyZGluZ3NwaGVyZS1pbmZyYS1mZWRlcmF0aW9uLWV4ZWN1dG9yL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9mZWRlcmF0aW9uL2V4ZWN1dG9yL29yaWdpbmFsL09yaWdpbmFsRmVkZXJhdGlvbkV4ZWN1dG9yLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | ... and [58 more](https://codecov.io/gh/apache/shardingsphere/pull/19033/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/19033?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/19033?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 [8288ed3...768720d](https://codecov.io/gh/apache/shardingsphere/pull/19033?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] strongduanmu merged pull request #19033: Add more unit test for ShardingCopyStatementValidator

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


-- 
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