yihua commented on code in PR #20897:
URL: https://github.com/apache/hudi/pull/20897#discussion_r4722744862


##########
hudi-spark-datasource/hudi-spark3-common/src/main/scala/org/apache/spark/sql/hudi/command/MergeIntoHoodieTableCommand.scala:
##########
@@ -600,8 +603,14 @@ case class MergeIntoHoodieTableCommand(mergeInto: 
MergeIntoTable) extends Hoodie
       && getPartialUpdateMode(parameters).isEmpty)
   }
 
+  /**
+   * A table with record key(s) is upserted when the statement has a matched 
clause, since only the index
+   * lookup finds the target record the clause applies to.
+   */
   private def getOperationType(parameters: Map[String, String]) = {
-    if 
(StringUtils.isNullOrEmpty(ConfigUtils.getOrderingFieldsStrDuringWrite(parameters.asJava))
 && updatingActions.isEmpty) {
+    val hasMatchedClauseToApply = if (hasPrimaryKey()) 
mergeInto.matchedActions.nonEmpty else updatingActions.nonEmpty

Review Comment:
   Fixed: a delete plus insert statement on a merge-on-read table now reads the 
rows it matches before the write (the target read of #20857, which this is now 
stacked on), so a key deleted in a log file takes the insert clause. The 
deleted-key test now also runs a delete plus insert statement, which also 
caught a deleted copy of a re-inserted key taking the insert clause a second 
time; the target read now leaves such a copy out when another file group holds 
the key live. The limitation in the description now names only what stays as on 
master: statements with an update clause and tables with an ordering field.
   



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