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

   ### Describe the issue this Pull Request addresses
   
   Closes #20839.
   
   A Spark SQL UPDATE or MERGE INTO action that assigns a field of a struct 
column (`UPDATE t SET s.c1 = 1 WHERE id = 1`) fails on a Hudi table, with a 
`MatchError` in `UpdateHoodieTableCommand` or "Only assignments of the form 
t.field = ... are supported" in MERGE INTO.
   
   ### Summary and Changelog
   
   `ResolveImplementations` now aligns the assignments of UPDATE and of MERGE 
INTO actions through Spark's `AssignmentUtils` (Spark 3.5 and later, with the 
4.1 signature handled in the Spark 4 adapters), the way Spark does for tables 
supporting row-level operations: an assignment of a nested field becomes an 
assignment of the rebuilt top-level struct, and repeated or conflicting 
assignments fail at analysis. Statements that assign only top-level columns are 
left as they are.
   
   Tests: new cases in `TestUpdateTable` (COW, MOR, keyless) and 
`TestMergeIntoTable2` (COW keyed and keyless, MOR) cover nested assignments at 
several depths, null structs, and the refused cases below. They fail on master 
with the errors above.
   
   Limitations:
   - Before Spark 3.5 a nested assignment fails with a message saying it needs 
Spark 3.5 (never supported).
   - MERGE INTO with a nested assignment on a MOR table still fails, because 
the rebuilt struct reads the other fields from the target record (never 
supported).
   - An UPDATE that assigns a struct holding a record key or partition field, 
or any field of it, is refused. Assigning the whole struct used to be accepted 
and could change the key without changing `_hoodie_record_key` (regression for 
that statement).
   
   ### Impact
   
   Spark SQL UPDATE and MERGE INTO can assign nested fields on Spark 3.5 and 
later.
   
   ### Risk Level
   
   low
   
   Statements without a nested assignment take the same path as before.
   
   ### Documentation Update
   
   none
   
   ### Contributor's checklist
   
   - [x] Read through [contributor's 
guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [x] Enough context is provided in the sections above
   - [x] 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