Zhangshunyu commented on a change in pull request #4032:
URL: https://github.com/apache/carbondata/pull/4032#discussion_r554774043
##########
File path: docs/scd-and-cdc-guide.md
##########
@@ -55,8 +55,42 @@ Below is the detailed description of the `merge` API
operation.
* `whenNotMatched` clause can have only the `insertExpr` action. The new
row is generated based on the specified column and corresponding expressions.
Users do not need to specify all the columns in the target table. For
unspecified target columns, NULL is inserted.
* `whenNotMatchedAndExistsOnlyOnTarget` clause is executed when row does not
match source and exists only in target. This clause can have only delete action.
-**NOTE:** SQL syntax for merge is not yet supported.
+#### MERGE SQL
+
+Below sql merges a set of updates, insertions, and deletions based on a source
table
+into a target carbondata table.
+
+```
+ MERGE INTO target_table_identifier
+ USING source_table_identifier
+ ON <merge_condition>
+ [ WHEN MATCHED [ AND <condition> ] THEN <matched_action> ]
+ [ WHEN MATCHED [ AND <condition> ] THEN <matched_action> ]
+ [ WHEN NOT MATCHED [ AND <condition> ] THEN <not_matched_action> ]
+```
+
+#### MERGE SQL Operation Semantics
+Below is the detailed description of the `merge` SQL operation.
+* `table_identifier` a table name, optionally qualified with a database name
+* `merge_condition` how the rows from one relation are combined with the rows
of another relation. An expression with a return type of Boolean.
+* `WHEN MATCHED` clauses are executed when a source row matches a target table
row based on the match condition,
+clauses can have at most one UPDATE and one DELETE action, These clauses have
the following semantics.
+ * The UPDATE action in merge only updates the specified columns of the
matched target row.
+ * The DELETE action will delete the matched row.
+ * WHEN MATCHED clauses can have at most one UPDATE and one DELETE action.
The UPDATE action in merge only updates the specified columns of the matched
target row. The DELETE action will delete the matched row.
+ * Each WHEN MATCHED clause can have an optional condition. If this clause
condition exists, the UPDATE or DELETE action is executed for any matching
source-target row pair row only when when the clause condition is true.
+ * If there are multiple WHEN MATCHED clauses, then they are evaluated in
order they are specified (that is, the order of the clauses matter). All WHEN
MATCHED clauses, except the last one, must have conditions.
+ * If both WHEN MATCHED clauses have conditions and neither of the
conditions are true for a matching source-target row pair, then the matched
target row is left unchanged.
+ * To update all the columns of the target carbondata table with the
corresponding columns of the source dataset, use UPDATE SET *. This is
equivalent to UPDATE SET col1 = source.col1 [, col2 = source.col2 ...] for all
the columns of the target carbondata table. Therefore, this action assumes that
the source table has the same columns as those in the target table, otherwise
the query will throw an analysis error.
+* `matched_action` can be DELETE | UPDATE SET * |UPDATE SET column1 = value1
[, column2 = value2 ...]
+* `WHEN NOT MATCHED` clause is executed when a source row does not match any
target row based on the match condition, , these clauses have the following
semantics.
Review comment:
@QiangCai handled
----------------------------------------------------------------
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:
[email protected]