vldpyatkov commented on code in PR #13366:
URL: https://github.com/apache/ignite/pull/13366#discussion_r3720334570


##########
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/schema/CacheTableDescriptorImpl.java:
##########
@@ -442,14 +464,18 @@ private <Row> ModifyTuple mergeTuple(Row row, 
List<String> updateColList, Execut
 
         int rowColumnsCnt = hnd.columnCount(row);
 
-        if (rowColumnsCnt == descriptors.length)
+        // An empty update column list unambiguously means there is no WHEN 
MATCHED clause at all (a MERGE
+        // statement always has at least one WHEN clause), so the row can only 
originate from the INSERT
+        // section. Note: the row width alone can't be used to detect this 
case, since, depending on the
+        // number of updated columns, it may coincide with the width of a WHEN 
MATCHED-only row.
+        if (updateColList.isEmpty())
             return insertTuple(row, ectx); // Only WHEN NOT MATCHED clause in 
MERGE.
         else if (rowColumnsCnt == descriptors.length + updateColList.size())
             return 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;
+            assert rowColumnsCnt == 2 * descriptors.length + 
updateColList.size() : "Unexpected columns count: "

Review Comment:
   Yes, I changed it many times and finally returned to the origin.



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