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

   A Spark SQL `MERGE INTO` update clause can assign a partition column (as 
`UPDATE SET *` does), 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 whose update gives a 
partition column a new value stays in its old partition holding the new value. 
The column value no longer agrees with the partition path, and readers that 
take the value from the path keep showing the old one.
   - On a table with a record key and a non-global index, the record is looked 
up under the partition the source names, so an update clause that assigns the 
partition column anything else writes the same inconsistent record.
   
   ```sql
   -- table without a record key, partitioned by dep
   merge into t using (select 1 as id, 'd9' as dep) s on t.id = s.id
   when matched then update set *
   ```
   
   leaves the row in `dep=d1` with `dep = 'd9'` in the data file.
   
   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, I'd propose refusing these 
statements with a clear message, as Spark SQL `UPDATE` already refuses an 
assignment to a partition field.
   


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