voonhous commented on code in PR #20888:
URL: https://github.com/apache/hudi/pull/20888#discussion_r4696354372


##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieCreateRecordUtils.scala:
##########
@@ -156,8 +157,11 @@ object HoodieCreateRecordUtils {
             val hoodieRecord = if (shouldCombine && !orderingFields.isEmpty) {
               val orderingVal = getOrderingValue(orderingFields, avroRec, 
hoodieKey.getRecordKey,
                 consistentLogicalTimestampEnabled, requiresOrderingValue)
+              // The clauses of a Spark SQL MERGE INTO decide on write whether 
a record that is not flagged as a
+              // delete deletes the record it matches
+              val knownDelete: java.lang.Boolean = if (isDelete || 
!sqlMergeIntoWrites) isDelete else null

Review Comment:
   **blocker:** This fixes the keyless case, but the root cause is one layer 
down.
   
   `HoodieRecord.isDelete` caches its first answer, and ExpressionPayload only 
reports a clause delete when `PAYLOAD_IS_UPDATE_RECORD_FOR_MOR` is set, which 
only HoodieAppendHandle does. Global and record-level index tagging 
(HoodieIndexUtils:609 and :388) evaluate it first and cache `false`.
   
   So on a keyed MOR table with GLOBAL_SIMPLE, GLOBAL_BLOOM or RECORD_INDEX and 
an ordering field, identically with and without this PR:
   - `when matched then delete` keeps the row and the statement succeeds 
(NoSuchElementException logged at HoodieNativeLogAppendHandle:130)
   - update + delete clauses fail the command
   
   Could the fix move to the cache instead, e.g. not caching `isDelete` for 
payloads that can produce a sentinel, with a keyed MOR GLOBAL_SIMPLE delete 
case added next to this test?



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