yihua opened a new pull request, #20838:
URL: https://github.com/apache/hudi/pull/20838

   ### Describe the issue this Pull Request addresses
   
   closes #20833
   
   A `MERGE INTO` update can assign a partition column, but the command writes 
a matched record back to the file group it was found in. On a table without a 
record key, a matched record that takes a new partition value stays in its old 
partition holding the new value. On a table with a record key and a non-global 
index, an update clause that assigns the partition column anything other than 
the value the record is looked up under does the same.
   
   ### Summary and Changelog
   
   Moving the record needs a delete in the old partition and an insert in the 
new one, which a `MERGE INTO` does only with a global index that updates 
partition paths. Until a move is supported, `MergeIntoHoodieTableCommand` 
refuses these updates, as `UPDATE` already refuses an assignment to a partition 
field:
   
   - With a record key and a non-global index, the analysis fails when an 
update clause assigns a partition column anything other than the source value 
the record is looked up under. `UPDATE SET *` stays allowed.
   - Without a record key, the write fails when a matched record takes an 
update clause that gives a partition column another value. The update clauses 
are tried in the order `ExpressionPayload` tries them, so a statement that 
moves no record still runs. The failure is raised in a task of the write, and 
the command rethrows it with the refusal message so the user sees it rather 
than "Failed to upsert for commit time ...".
   
   The new tests check both refusals on COW and MOR tables, that the table is 
unchanged after the refusal, and that the same statement runs when no matched 
record changes partition. On master both refused statements succeed. The 
keyless test checks the top-level message, which without the rethrow is "Failed 
to upsert for commit time ...".
   
   ### Impact
   
   A `MERGE INTO` that would leave a record in a partition it no longer belongs 
to now fails instead of writing it. Tables with a global index or a custom 
index class are not checked.
   
   ### Risk Level
   
   low. The check on a table without a record key compares partition column 
values, so where the key generator derives the partition path from a column 
value (for example a timestamp-based key generator), an update that changes the 
value but not the path is refused as well.
   
   ### 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]

Reply via email to