yihua opened a new pull request, #20897: URL: https://github.com/apache/hudi/pull/20897
### Describe the issue this Pull Request addresses closes #20896 On a table with a record key and no ordering field, a MERGE INTO without an update clause runs as an insert, so a delete-only statement deletes nothing and an insert-only statement inserts matched source records a second time. ### Summary and Changelog `MergeIntoHoodieTableCommand#getOperationType` (Spark 3 and Spark 4 copies) now writes an upsert whenever the table has a record key, so the index separates matched from unmatched source records, as it already does for statements with an update clause or tables with an ordering field. A table without a record key keeps the insert. A new test in `TestMergeIntoTable2` runs delete-only (with and without a condition), insert-only (with and without a condition) and delete plus insert statements on COW and MOR tables with a record key and no ordering field. ### Impact Delete-only and insert-only MERGE INTO statements on keyed tables without an ordering field now apply their matched clauses and no longer duplicate keys. Source records sharing a record key may now collapse into one record, as they already do for statements with an update clause. ### Risk Level low. Only keyed tables without an ordering field and statements without an update clause change, and they move to the path every other keyed MERGE INTO already takes. ### Documentation Update none ### Contributor's checklist - [ ] Read through [contributor's guide](https://hudi.apache.org/contribute/how-to-contribute) - [ ] Enough context is provided in the sections above - [ ] Adequate tests were added if applicable -- 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]
