yihua opened a new issue, #20827:
URL: https://github.com/apache/hudi/issues/20827

   Spark SQL MERGE INTO on a Hudi table does not apply the first matched clause 
that holds. With
   
   ```sql
   MERGE INTO t USING s ON t.id = s.id
   WHEN MATCHED AND s.flag IN ('both', 'delete') THEN DELETE
   WHEN MATCHED AND s.flag IN ('both', 'update') THEN UPDATE SET id = s.id, 
name = s.name, price = s.price, ts = s.ts
   ```
   
   a row with `flag = 'both'` is updated instead of deleted. 
`ExpressionPayload#processMatchedRecord` checks every UPDATE clause before the 
DELETE clause, whatever order they are written in.
   
   The order between UPDATE clauses (and between INSERT clauses) is not 
reliable either: `MergeIntoHoodieTableCommand#serializeConditionalAssignments` 
passes the clauses to the payload as an immutable `Map` keyed by condition, 
which drops the written order once there are more than four clauses, and keeps 
the last of two clauses with the same condition instead of the first.
   
   Proposal: pass the clauses to the payload in the order written, keeping the 
first clause for a repeated condition, and make an UPDATE clause written after 
the DELETE clause also require the delete condition not to hold.
   


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