yihua opened a new pull request, #20832: URL: https://github.com/apache/hudi/pull/20832
### Describe the issue this Pull Request addresses closes #20831 In `MERGE INTO t USING t s ON t.id = s.id`, Hudi's `ResolveReferences` resolves the target and the source plans separately, so both get the same attribute ids and the condition compares each target column with itself. On a table without a record key the update is not applied; on a table with a record key the statement fails with "Invalid MERGE INTO matching condition". ### Summary and Changelog The rule now runs Spark's `DeduplicateRelations` on the `MergeIntoTable` before resolving the condition and the clauses, which gives the source its own attribute ids, as Spark's own resolution of `MERGE INTO` does. A statement whose source does not read the target is unchanged. The new test merges a table into itself, with and without the table cached, on COW and MOR tables with and without a record key. It fails on master for every case. ### Impact None beyond the fix. ### Risk Level low ### 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]
