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

   A Spark SQL `MERGE INTO` whose source reads the target table, such as
   
   ```sql
   merge into t using t s on t.id = s.id
   when matched and s.id = 1 then update set id = s.id, v = 'x'
   when not matched then insert *
   ```
   
   does not work on a Hudi table. Hudi's `ResolveReferences` rule resolves the 
target and source plans separately, so both resolve to the same relation with 
the same attribute ids, and `t.id = s.id` 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`, since neither side of the condition is a source column.
   
   Spark's own resolution of `MERGE INTO` runs `DeduplicateRelations` to give 
the source its own attribute ids; I'd propose doing the same in Hudi's rule.
   


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