alex-plekhanov commented on a change in pull request #9581:
URL: https://github.com/apache/ignite/pull/9581#discussion_r761782205



##########
File path: 
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/schema/TableDescriptorImpl.java
##########
@@ -470,6 +470,31 @@ private IgniteCheckedException 
instantiationException(String typeName, Reflectiv
         return F.t(key, val);
     }
 
+    /** */
+    private <Row> IgniteBiTuple mergeTuple(Row row, List<String> 
updateColList, ExecutionContext<Row> ectx)
+        throws IgniteCheckedException {
+        RowHandler<Row> hnd = ectx.rowHandler();
+
+        int rowColumnsCnt = hnd.columnCount(row);
+
+        if (rowColumnsCnt == descriptors.length)
+            return F.t(insertTuple(row, ectx), null); // Only WHEN NOT MATCHED 
clause in MERGE.
+        else if (rowColumnsCnt == descriptors.length + updateColList.size())
+            return F.t(null, updateTuple(row, updateColList, 0, ectx)); // 
Only WHEN MATCHED clause in MERGE.
+        else {
+            // Both WHEN MATCHED and WHEN NOT MATCHED clauses in MERGE.
+            assert rowColumnsCnt == descriptors.length * 2 + 
updateColList.size() : "Unexpected columns count: " +
+                rowColumnsCnt;
+
+            int updateOffset = descriptors.length; // Offset of fields for 
update statement.
+
+            if (hnd.get(updateOffset + QueryUtils.KEY_COL, row) != null)
+                return F.t(null, updateTuple(row, updateColList, updateOffset, 
ectx));

Review comment:
       Ok, I will change T2 to T3 with the operation type as the third field.
   BTW, what standard supports merge delete? In 2003 standard only merge update 
is supported. Currently, Calcite also supports only merge update.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to