yihua opened a new pull request, #20815: URL: https://github.com/apache/hudi/pull/20815
### Describe the issue this Pull Request addresses closes #20814 `KeyBasedFileGroupRecordBuffer#hasNextBaseRecord` removes the log record of a key when it merges it with the first base record of that key, so a delete applies to only one of the rows that share the key in a file group. Inserts do not enforce key uniqueness, so after an `INSERT INTO` that writes duplicate keys, a `DELETE` leaves the other copies on both copy-on-write and merge-on-read tables. ### Summary and Changelog A key-based delete now applies to every base record with its key. - `KeyBasedFileGroupRecordBuffer` keeps the deletes it has applied (key, ordering value and operation, without the row) and merges them with later base records of the same key. Updates still replace only the first base record with the key, as before. - `TestKeyBasedFileGroupRecordBuffer` covers duplicate keys under commit-time and event-time ordering, including a copy ordered after the delete that event-time ordering keeps. - `TestDeleteTable` deletes a key with duplicate rows in one base file and across file groups on COW and MOR tables. Without the fix both fail, e.g. `Expected Array([0,a0,p1], [2,a2,p2]), but got Array([0,a0,p1], [1,b1,p1], [1,d1,p1], [1,e1,p2], [2,a2,p2])`. ### Impact DELETE removes every row with a deleted key. No API or config change. ### Risk Level low. A base record without a log record now costs one extra hash lookup, and the retained deletes carry no row. ### 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]
