yihua opened a new pull request, #20821: URL: https://github.com/apache/hudi/pull/20821
### Describe the issue this Pull Request addresses closes #20819 In a `MERGE INTO` with only `WHEN NOT MATCHED ... THEN INSERT` clauses on a table with a record key, a source row that fails the insert condition can take the place of a same-key row that passes it, because the upsert combines source rows by key before `ExpressionPayload` evaluates the conditions. The insert for that key is then lost. ### Summary and Changelog For a statement with only not-matched clauses on a table with a record key, `MergeIntoHoodieTableCommand` now filters the source by the OR of the insert conditions before the write. A row that no clause accepts writes nothing whether or not it matches the table, so the filter changes nothing else. It applies only when every insert clause has a deterministic condition, and not to a statement with a matched clause, where such a row may still match. The same change is made in the `hudi-spark3-common` and `hudi-spark4-common` copies. The insert-only test of a table with an ordering field gets two source rows with one key, of which the one with the larger ordering value fails the condition. On master nothing is inserted for that key. ### Impact None beyond the fix. With #20820 (upsert for an insert-only statement on a table without an ordering field), the same displacement can happen in the merge handle, and this filter covers that case as well; the two PRs do not depend on each other. ### Risk Level low. The insert conditions are now evaluated on every source row, including rows that match the table, so a condition that throws on such a row (for example an invalid cast under ANSI mode) now fails the statement. ### 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]
