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

[GitHub] [shardingsphere] ThanoshanMV opened a new pull request #9692: Oracle merge statement test cases for merge update clause

ThanoshanMV opened a new pull request #9692:
URL: https://github.com/apache/shardingsphere/pull/9692


   #9129 
   
   Here's the `MERGE` statement [documentation](https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/MERGE.html#GUID-5692CCB7-24D9-4C0E-81A7-A22436DC968F). 
   
   @tristaZero, @wgy8283335  I've added test cases for `merge_update_clause`
   
   Changes proposed in this pull request:
   - Added test cases for `mergeUpdateClause`.
   - I modified `MERGE` antlr definition for `mergeUpdateClause`: added two new rules `mergeSetAssignmentsClause`, `deleteWhereClause` and removed parenthesis for `hint` and `mergeAssignmentValue`.
   - I tried to visit `mergeUpdateClause` in the `OracleDMLStatementSQLVisitor`.
   - I chose `SetAssignmentSegment` and `ExpectedSetClause` for the  `mergeSetAssignmentsClause` similar to `setAssignmentsClause` in the `UPDATE` statement. 
   - Since `mergeAssignmentValue` contains columns as values, to expect them, I added `ExpectedColumn` in the `ExpectedAssignmentValue.java` and to assert columns, I added `ColumnAssert` in the `AssignmentValueAssert.java`. 
   
   I'll change them according to your feedback. 
   
   
   


----------------------------------------------------------------
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] ThanoshanMV commented on a change in pull request #9692: Oracle merge statement test cases for merge update clause

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



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleDMLStatementSQLVisitor.java
##########
@@ -487,6 +492,15 @@ public ASTNode visitMerge(final MergeContext ctx) {
         result.setTarget((SimpleTableSegment) visit(ctx.intoClause()));
         result.setSource((TableSegment) visit(ctx.usingClause()));
         result.setExpr((ExpressionSegment) (visit(ctx.usingClause().expr())));
+        if (null != ctx.mergeUpdateClause()) {
+            result.getUpdate().setSetAssignment((SetAssignmentSegment) visit(ctx.mergeUpdateClause().mergeSetAssignmentsClause()));
+            if (null != ctx.mergeUpdateClause().whereClause()) {
+                result.getUpdate().setWhere((WhereSegment) visit(ctx.mergeUpdateClause().whereClause()));
+            }
+            if (null != ctx.mergeUpdateClause().deleteWhereClause()) {
+                result.getUpdate().setWhere((WhereSegment) visit(ctx.mergeUpdateClause().deleteWhereClause()));

Review comment:
       @wgy8283335 I added `DeleteStatement` as a member in the `MergeStatement` and modified the `MergeStatementTestCase` like above. 
   
   I asserted both `WhereSegements` inside `assertWhereClause` method in `MergeStatementAssert`.
   
   




-- 
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] wgy8283335 commented on a change in pull request #9692: Oracle merge statement test cases for merge update clause

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



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleDMLStatementSQLVisitor.java
##########
@@ -487,6 +492,15 @@ public ASTNode visitMerge(final MergeContext ctx) {
         result.setTarget((SimpleTableSegment) visit(ctx.intoClause()));
         result.setSource((TableSegment) visit(ctx.usingClause()));
         result.setExpr((ExpressionSegment) (visit(ctx.usingClause().expr())));
+        if (null != ctx.mergeUpdateClause()) {
+            result.getUpdate().setSetAssignment((SetAssignmentSegment) visit(ctx.mergeUpdateClause().mergeSetAssignmentsClause()));
+            if (null != ctx.mergeUpdateClause().whereClause()) {
+                result.getUpdate().setWhere((WhereSegment) visit(ctx.mergeUpdateClause().whereClause()));
+            }
+            if (null != ctx.mergeUpdateClause().deleteWhereClause()) {
+                result.getUpdate().setWhere((WhereSegment) visit(ctx.mergeUpdateClause().deleteWhereClause()));

Review comment:
       Yes, I think so.




-- 
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 pull request #9692: Oracle merge statement test cases for merge update clause

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


   Hi @Baoanh217 , thanks for your attention, please have my welcome.
   @wgy8283335 Thanks for your approval moving this PR forward.


-- 
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] wgy8283335 commented on a change in pull request #9692: Oracle merge statement test cases for merge update clause

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



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleDMLStatementSQLVisitor.java
##########
@@ -487,6 +492,15 @@ public ASTNode visitMerge(final MergeContext ctx) {
         result.setTarget((SimpleTableSegment) visit(ctx.intoClause()));
         result.setSource((TableSegment) visit(ctx.usingClause()));
         result.setExpr((ExpressionSegment) (visit(ctx.usingClause().expr())));
+        if (null != ctx.mergeUpdateClause()) {
+            result.getUpdate().setSetAssignment((SetAssignmentSegment) visit(ctx.mergeUpdateClause().mergeSetAssignmentsClause()));
+            if (null != ctx.mergeUpdateClause().whereClause()) {
+                result.getUpdate().setWhere((WhereSegment) visit(ctx.mergeUpdateClause().whereClause()));
+            }
+            if (null != ctx.mergeUpdateClause().deleteWhereClause()) {
+                result.getUpdate().setWhere((WhereSegment) visit(ctx.mergeUpdateClause().deleteWhereClause()));

Review comment:
       @tristaZero @ThanoshanMV  Delete Where is not suitable in the update statement. Maybe should put in a delete statement.




-- 
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] wgy8283335 commented on a change in pull request #9692: Oracle merge statement test cases for merge update clause

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



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleDMLStatementSQLVisitor.java
##########
@@ -487,6 +492,15 @@ public ASTNode visitMerge(final MergeContext ctx) {
         result.setTarget((SimpleTableSegment) visit(ctx.intoClause()));
         result.setSource((TableSegment) visit(ctx.usingClause()));
         result.setExpr((ExpressionSegment) (visit(ctx.usingClause().expr())));
+        if (null != ctx.mergeUpdateClause()) {
+            result.getUpdate().setSetAssignment((SetAssignmentSegment) visit(ctx.mergeUpdateClause().mergeSetAssignmentsClause()));
+            if (null != ctx.mergeUpdateClause().whereClause()) {
+                result.getUpdate().setWhere((WhereSegment) visit(ctx.mergeUpdateClause().whereClause()));
+            }
+            if (null != ctx.mergeUpdateClause().deleteWhereClause()) {
+                result.getUpdate().setWhere((WhereSegment) visit(ctx.mergeUpdateClause().deleteWhereClause()));

Review comment:
       Yes, I think so. @ThanoshanMV 




-- 
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] ThanoshanMV commented on pull request #9692: Oracle merge statement test cases for merge update clause

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


   Yes @tristaZero, `UpdateStatement` is more fitting member in the `MergeStatement` as it contains both `setAssignment` and `where`. I'll try to do in that way. 


-- 
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 #9692: Oracle merge statement test cases for merge update clause

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



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/dml/MergeStatement.java
##########
@@ -37,4 +41,17 @@
     private TableSegment source;
     
     private ExpressionSegment expr;
+    

Review comment:
       Hi,
   
   First, `mergeSetAssignmentsClause` is OK for me, since it is like a definition with a group of `mergeSetAssignment`. Therefore a `merge` main definition will contain some of the keywords and some of the child group definitions, and each group definition is made up of its child definitions. 
   On the other hand, you can still put all specific definitions in the main clause, which does not have any group definitions.
   
   Which one is our best choice? I suppose we need to add another factor, i.e., `SQLStatement`. Suppose we want to visit out some specific `statement`, it is necessary to estimate which type of SQL definition of `g4` file is more reasonable and straightforward for visitors.
   
   That's my opinion and hope it can give you some hints for the following issues.
   
   Second, actually, a more fitting member putting into `MergeStatement`, I guess, is the `UpdateStatement` containing `setAssignment` and `where`. The reason is that `OracleUpdateStatement` has existed and owned the entire and complete definition about `update set where`. 
   But that will make it more challenging to do unit tests. I suggest you can have a try, and if that frustrates you too much, you can put it aside. Yep, it is optional. :)
   
   @ThanoshanMV 
   Hope you can succeed in GSoC 2021 and learn more from this community.  Also @wgy8283335 and I will provide our mentoring as much as we can.




----------------------------------------------------------------
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] ThanoshanMV commented on a change in pull request #9692: Oracle merge statement test cases for merge update clause

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



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleDMLStatementSQLVisitor.java
##########
@@ -487,6 +492,15 @@ public ASTNode visitMerge(final MergeContext ctx) {
         result.setTarget((SimpleTableSegment) visit(ctx.intoClause()));
         result.setSource((TableSegment) visit(ctx.usingClause()));
         result.setExpr((ExpressionSegment) (visit(ctx.usingClause().expr())));
+        if (null != ctx.mergeUpdateClause()) {
+            result.getUpdate().setSetAssignment((SetAssignmentSegment) visit(ctx.mergeUpdateClause().mergeSetAssignmentsClause()));
+            if (null != ctx.mergeUpdateClause().whereClause()) {
+                result.getUpdate().setWhere((WhereSegment) visit(ctx.mergeUpdateClause().whereClause()));
+            }
+            if (null != ctx.mergeUpdateClause().deleteWhereClause()) {
+                result.getUpdate().setWhere((WhereSegment) visit(ctx.mergeUpdateClause().deleteWhereClause()));

Review comment:
       Okay @wgy8283335, I'll put `DeleteStatement` as a member in the `MergeStatement`. So that we can visit `deleteWhereClause` and put it inside `DeleteStatement`'s `WhereSegment`.




-- 
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 pull request #9692: Oracle merge statement test cases for merge update clause

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


   @wgy8283335 @ThanoshanMV Can we merge this one to master branch?


-- 
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 pull request #9692: Oracle merge statement test cases for merge update clause

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


   Hi,
   
   First, `mergeSetAssignmentsClause` is OK for me, since it is like a definition with a group of `mergeSetAssignment`. Therefore a `merge` main definition will contain some of the keywords and some of the child group definitions, and each group definition is made up of its child definitions. 
   On the other hand, you can still put all specific definitions in the main clause, which does not have any group definitions.
   
   Which one is our best choice? I suppose we need to add another factor, i.e., `SQLStatement`. Suppose we want to visit out some specific `statement`, it is necessary to estimate which type of SQL definition of `g4` file is more reasonable and straightforward for visitors.
   
   That's my opinion and hope it can give you some hints for the following issues.
   
   Second, actually, a more fitting member putting into `MergeStatement`, I guess, is the `UpdateStatement` containing `setAssignment` and `where`. The reason is that `OracleUpdateStatement` has existed and owned the entire and complete definition about `update set where`. 
   But that will make it more challenging to do unit tests. I suggest you can have a try, and if that frustrates you too much, you can put it aside. Yep, it is optional. :)
   
   @ThanoshanMV 
   Hope you can succeed in GSoC 2021 and learn more from this community.  Also @wgy8283335 and I will provide our mentoring as much as we can.


----------------------------------------------------------------
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] Baoanh217 commented on a change in pull request #9692: Oracle merge statement test cases for merge update clause

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



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DMLStatement.g4
##########
@@ -176,7 +176,7 @@ havingClause
 subquery
     : LP_ unionClause RP_

Review comment:
       .




-- 
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] ThanoshanMV commented on pull request #9692: Oracle merge statement test cases for merge update clause

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


   Hi @tristaZero, the new changes need to be reviewed. 


-- 
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] ThanoshanMV commented on a change in pull request #9692: Oracle merge statement test cases for merge update clause

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



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DMLStatement.g4
##########
@@ -198,15 +198,23 @@ usingClause
     ;
 
 mergeUpdateClause
-    : WHEN MATCHED THEN UPDATE SET mergeAssignment (COMMA_ mergeAssignment)* whereClause? (DELETE whereClause)?
+    : WHEN MATCHED THEN UPDATE mergeSetAssignmentsClause whereClause? deleteWhereClause?

Review comment:
       Hi @wgy8283335, I've updated `mergeSetAssignmentsClause`.




-- 
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] wgy8283335 commented on a change in pull request #9692: Oracle merge statement test cases for merge update clause

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



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DMLStatement.g4
##########
@@ -176,7 +176,7 @@ havingClause
 subquery
     : LP_ unionClause RP_

Review comment:
       @tristaZero I've finished the review, shall we merge the pull request?
   @Baoanh217 leave a '.' in the comment. Shall we ignore the comment, as the below code is not changed in this submit
   ```
   subquery
       : LP_ unionClause RP_
   ```




-- 
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 pull request #9692: Oracle merge statement test cases for merge update clause

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


   Hi @ThanoshanMV ,
   Looks better. Let us wait for @wgy8283335 's feedback.
   


-- 
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] ThanoshanMV commented on a change in pull request #9692: Oracle merge statement test cases for merge update clause

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



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DMLStatement.g4
##########
@@ -198,15 +198,23 @@ usingClause
     ;
 
 mergeUpdateClause
-    : WHEN MATCHED THEN UPDATE SET mergeAssignment (COMMA_ mergeAssignment)* whereClause? (DELETE whereClause)?
+    : WHEN MATCHED THEN UPDATE mergeSetAssignmentsClause whereClause? deleteWhereClause?

Review comment:
       Yes @wgy8283335, `WHEN MATCHED THEN UPDATE SET`  is better. I put `SET` separately in the `mergeSetAssignmentsClause`  because of its rule name only. Since the rule name specifies `SetAssignments` in its name, I just put keyword `SET` inside that rule. 
   
   I'll change that one as: 
   ```
   mergeUpdateClause
       : WHEN MATCHED THEN UPDATE SET mergeSetAssignmentsClause whereClause? deleteWhereClause?
       ;
   
   mergeSetAssignmentsClause 
       : mergeAssignment (COMMA_ mergeAssignment)*
   ```
   
   
   
   




----------------------------------------------------------------
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] ThanoshanMV commented on pull request #9692: Oracle merge statement test cases for merge update clause

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


   Hi @tristaZero, I've added `UpdateStatement` as a member of the `MergeStatement`. I've modified other files to pass test cases. I'll change them according to your feedback.  


-- 
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] ThanoshanMV commented on a change in pull request #9692: Oracle merge statement test cases for merge update clause

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



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleDMLStatementSQLVisitor.java
##########
@@ -487,6 +492,15 @@ public ASTNode visitMerge(final MergeContext ctx) {
         result.setTarget((SimpleTableSegment) visit(ctx.intoClause()));
         result.setSource((TableSegment) visit(ctx.usingClause()));
         result.setExpr((ExpressionSegment) (visit(ctx.usingClause().expr())));
+        if (null != ctx.mergeUpdateClause()) {
+            result.getUpdate().setSetAssignment((SetAssignmentSegment) visit(ctx.mergeUpdateClause().mergeSetAssignmentsClause()));
+            if (null != ctx.mergeUpdateClause().whereClause()) {
+                result.getUpdate().setWhere((WhereSegment) visit(ctx.mergeUpdateClause().whereClause()));
+            }
+            if (null != ctx.mergeUpdateClause().deleteWhereClause()) {
+                result.getUpdate().setWhere((WhereSegment) visit(ctx.mergeUpdateClause().deleteWhereClause()));

Review comment:
       @wgy8283335 since we get `WhereSegement` actual values from two statements: `UpdateStatement` and `DeleteStatement`, to expect and assert those `WhereSegement` values, we should have two different `ExpectedWhereClause` right? 
   
   Can we have something like below in the `MergeStatementTestCase`? :
   
   ![MergeStatementTestCase](https://user-images.githubusercontent.com/48581379/112149565-247f9c00-8c05-11eb-87cc-8669016a0e5a.png)
   




-- 
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] wgy8283335 commented on a change in pull request #9692: Oracle merge statement test cases for merge update clause

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



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DMLStatement.g4
##########
@@ -198,15 +198,23 @@ usingClause
     ;
 
 mergeUpdateClause
-    : WHEN MATCHED THEN UPDATE SET mergeAssignment (COMMA_ mergeAssignment)* whereClause? (DELETE whereClause)?
+    : WHEN MATCHED THEN UPDATE mergeSetAssignmentsClause whereClause? deleteWhereClause?

Review comment:
       Why put SET in the mergeSetAssignmentsClause? 

##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DMLStatement.g4
##########
@@ -198,15 +198,23 @@ usingClause
     ;
 
 mergeUpdateClause
-    : WHEN MATCHED THEN UPDATE SET mergeAssignment (COMMA_ mergeAssignment)* whereClause? (DELETE whereClause)?
+    : WHEN MATCHED THEN UPDATE mergeSetAssignmentsClause whereClause? deleteWhereClause?

Review comment:
       ![image](https://user-images.githubusercontent.com/22066046/111424008-1f65ad00-872c-11eb-8c5f-8ad2caa859a0.png)
   Do you think `WHEN MATCHED THEN UPDATE SET` is better?

##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/dml/MergeStatement.java
##########
@@ -37,4 +41,17 @@
     private TableSegment source;
     
     private ExpressionSegment expr;
+    

Review comment:
       @tristaZero Hi, do you think it is necessary to add the 'setAssignment' and 'where' in MergeStatement?
   Related rule as below:
   ```
   mergeSetAssignmentsClause
       : SET mergeAssignment (COMMA_ mergeAssignment)*
       ;
   
   whereClause
       : WHERE expr
       ;
   ```
   




----------------------------------------------------------------
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 #9692: Oracle merge statement test cases for merge update clause

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


   


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