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 2020/10/21 10:42:56 UTC

[GitHub] [shardingsphere] jingshanglu opened a new pull request #7872: add table UT

jingshanglu opened a new pull request #7872:
URL: https://github.com/apache/shardingsphere/pull/7872


   ### What is the purpose of the change
   add table UT.
   
   ### Changes in this pull request:
   - change expected sql parser test result
   - add assert code for 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.

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



[GitHub] [shardingsphere] tristaZero merged pull request #7872: add table UT

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


   


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

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



[GitHub] [shardingsphere] codecov-io commented on pull request #7872: add table UT

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


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/7872?src=pr&el=h1) Report
   > Merging [#7872](https://codecov.io/gh/apache/shardingsphere/pull/7872?src=pr&el=desc) into [master](https://codecov.io/gh/apache/shardingsphere/commit/3b9942a9292cbc0e06ac5e87e80fed99c1b02981?el=desc) will **decrease** coverage by `0.13%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/7872/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so)](https://codecov.io/gh/apache/shardingsphere/pull/7872?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #7872      +/-   ##
   ============================================
   - Coverage     75.01%   74.87%   -0.14%     
     Complexity      532      532              
   ============================================
     Files          1425     1431       +6     
     Lines         22578    22668      +90     
     Branches       4045     4057      +12     
   ============================================
   + Hits          16937    16973      +36     
   - Misses         4548     4599      +51     
   - Partials       1093     1096       +3     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/7872?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | [...ext/transaction/GovernanceTransactionContexts.java](https://codecov.io/gh/apache/shardingsphere/pull/7872/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtZ292ZXJuYW5jZS9zaGFyZGluZ3NwaGVyZS1nb3Zlcm5hbmNlLWNvcmUvc2hhcmRpbmdzcGhlcmUtZ292ZXJuYW5jZS1jb3JlLWNvbnRleHQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2dvdmVybmFuY2UvY29udGV4dC90cmFuc2FjdGlvbi9Hb3Zlcm5hbmNlVHJhbnNhY3Rpb25Db250ZXh0cy5qYXZh) | `93.33% <0.00%> (-6.67%)` | `0.00% <0.00%> (ø%)` | |
   | [.../route/engine/type/ShardingRouteEngineFactory.java](https://codecov.io/gh/apache/shardingsphere/pull/7872/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctcm91dGUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NoYXJkaW5nL3JvdXRlL2VuZ2luZS90eXBlL1NoYXJkaW5nUm91dGVFbmdpbmVGYWN0b3J5LmphdmE=) | `71.42% <0.00%> (-3.04%)` | `0.00% <0.00%> (ø%)` | |
   | [...gsphere/sql/parser/mysql/visitor/MySQLVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/7872/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWRpYWxlY3Qvc2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci1teXNxbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9teXNxbC92aXNpdG9yL015U1FMVmlzaXRvci5qYXZh) | `79.29% <0.00%> (-1.36%)` | `1.00% <0.00%> (ø%)` | |
   | [...sql/parser/mysql/visitor/impl/MySQLDDLVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/7872/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWRpYWxlY3Qvc2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci1teXNxbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9teXNxbC92aXNpdG9yL2ltcGwvTXlTUUxERExWaXNpdG9yLmphdmE=) | `47.14% <0.00%> (-0.69%)` | `0.00% <0.00%> (ø%)` | |
   | [...phere/infra/binder/SQLStatementContextFactory.java](https://codecov.io/gh/apache/shardingsphere/pull/7872/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtYmluZGVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9iaW5kZXIvU1FMU3RhdGVtZW50Q29udGV4dEZhY3RvcnkuamF2YQ==) | `9.83% <0.00%> (-0.34%)` | `0.00% <0.00%> (ø%)` | |
   | [.../postgresql/visitor/impl/PostgreSQLDMLVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/7872/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWRpYWxlY3Qvc2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci1wb3N0Z3Jlc3FsL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9zcWwvcGFyc2VyL3Bvc3RncmVzcWwvdmlzaXRvci9pbXBsL1Bvc3RncmVTUUxETUxWaXNpdG9yLmphdmE=) | `81.39% <0.00%> (-0.07%)` | `0.00% <0.00%> (ø%)` | |
   | [...inder/statement/ddl/AlterViewStatementContext.java](https://codecov.io/gh/apache/shardingsphere/pull/7872/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtYmluZGVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9iaW5kZXIvc3RhdGVtZW50L2RkbC9BbHRlclZpZXdTdGF0ZW1lbnRDb250ZXh0LmphdmE=) | `0.00% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | [...tadata/refresh/MetaDataRefreshStrategyFactory.java](https://codecov.io/gh/apache/shardingsphere/pull/7872/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9tZXRhZGF0YS9yZWZyZXNoL01ldGFEYXRhUmVmcmVzaFN0cmF0ZWd5RmFjdG9yeS5qYXZh) | `100.00% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | [...e/rdl/parser/engine/engine/RDLSQLParserEngine.java](https://codecov.io/gh/apache/shardingsphere/pull/7872/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtcmRsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1yZGwtcGFyc2VyLWVuZ2luZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcmRsL3BhcnNlci9lbmdpbmUvZW5naW5lL1JETFNRTFBhcnNlckVuZ2luZS5qYXZh) | `0.00% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | [...l/parser/engine/ShardingSphereSQLParserEngine.java](https://codecov.io/gh/apache/shardingsphere/pull/7872/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtcmRsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1yZGwtcGFyc2VyLWVuZ2luZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcmRsL3BhcnNlci9lbmdpbmUvU2hhcmRpbmdTcGhlcmVTUUxQYXJzZXJFbmdpbmUuamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | ... and [20 more](https://codecov.io/gh/apache/shardingsphere/pull/7872/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/7872?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/7872?src=pr&el=footer). Last update [3b9942a...7716b86](https://codecov.io/gh/apache/shardingsphere/pull/7872?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


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

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



[GitHub] [shardingsphere] tristaZero commented on a change in pull request #7872: add table UT

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



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/segment/table/TableAssert.java
##########
@@ -54,28 +57,24 @@
      * @param actual actual tables
      * @param expected expected tables
      */
-    public static void assertIs(final SQLCaseAssertContext assertContext, final Collection<TableSegment> actual, final ExpectedTables expected) {
-        assertThat(assertContext.getText("Tables size assertion error: "), actual.size(), is(expected.getSimpleTables().size() + expected.getSubqueryTables().size()));
-        assertSimpleTableSegment(assertContext, actual, expected);
-        assertSubqueryTableSegment(assertContext, actual, expected);
-    }
-    
-    /**
-     * Assert actual table segments is correct with expected tables.
-     * 
-     * @param assertContext assert context
-     * @param actual actual tables
-     * @param expected expected tables
-     */
-    public static void assertIs(final SQLCaseAssertContext assertContext, final Collection<SimpleTableSegment> actual, final List<ExpectedSimpleTable> expected) {
-        assertThat(assertContext.getText("Tables size assertion error: "), actual.size(), is(expected.size()));
-        int count = 0;
-        for (SimpleTableSegment each : actual) {
-            assertIs(assertContext, each, expected.get(count));
-            count++;
+    public static void assertIs(final SQLCaseAssertContext assertContext, final TableSegment actual, final ExpectedTable expected) {
+        if (actual instanceof JoinTableSegment) {
+            assertIs(assertContext, (JoinTableSegment) actual, expected.getJoinTable());
+
+        } else if (actual instanceof SimpleTableSegment) {
+            assertIs(assertContext, (SimpleTableSegment) actual, expected.getSimpleTable());
+
+        } else if (actual instanceof SubqueryTableSegment) {
+            assertIs(assertContext, (SubqueryTableSegment) actual, expected.getSubqueryTable());
+
+        } else if (actual instanceof DeleteMultiTableSegment) {
+            return;

Review comment:
       redundant blank line

##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/segment/table/TableAssert.java
##########
@@ -54,28 +57,24 @@
      * @param actual actual tables
      * @param expected expected tables
      */
-    public static void assertIs(final SQLCaseAssertContext assertContext, final Collection<TableSegment> actual, final ExpectedTables expected) {
-        assertThat(assertContext.getText("Tables size assertion error: "), actual.size(), is(expected.getSimpleTables().size() + expected.getSubqueryTables().size()));
-        assertSimpleTableSegment(assertContext, actual, expected);
-        assertSubqueryTableSegment(assertContext, actual, expected);
-    }
-    
-    /**
-     * Assert actual table segments is correct with expected tables.
-     * 
-     * @param assertContext assert context
-     * @param actual actual tables
-     * @param expected expected tables
-     */
-    public static void assertIs(final SQLCaseAssertContext assertContext, final Collection<SimpleTableSegment> actual, final List<ExpectedSimpleTable> expected) {
-        assertThat(assertContext.getText("Tables size assertion error: "), actual.size(), is(expected.size()));
-        int count = 0;
-        for (SimpleTableSegment each : actual) {
-            assertIs(assertContext, each, expected.get(count));
-            count++;
+    public static void assertIs(final SQLCaseAssertContext assertContext, final TableSegment actual, final ExpectedTable expected) {
+        if (actual instanceof JoinTableSegment) {
+            assertIs(assertContext, (JoinTableSegment) actual, expected.getJoinTable());
+
+        } else if (actual instanceof SimpleTableSegment) {
+            assertIs(assertContext, (SimpleTableSegment) actual, expected.getSimpleTable());
+

Review comment:
       redundant blank line




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

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