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

   ### Describe the issue this Pull Request addresses
   
   closes #20836
   
   Spark SQL MERGE INTO on a table with a record key accepts an ON condition 
that leaves out a record key column, and then keys the write on the source 
column of the same name, unless `hoodie.spark.sql.optimized.writes.enable` is 
explicitly set to `true`. The existing check read that config with a default of 
`false`, while the config defaults to `true`.
   
   ### Summary and Changelog
   
   The check that every record key column is matched in the ON condition now 
always runs for tables with a record key, whatever the optimized writes 
setting. Statements that match on all record key columns are unaffected. A 
record key field nested in a struct is still taken from the source, since the 
ON condition cannot name it. The new case in 
`TestMergeIntoTableWithNonRecordKeyField` runs a MERGE matching only on a 
non-key column with the config unset, `true` and `false`, and fails on master 
because no error is raised. The existing case that expected the composite-key 
statement to succeed with optimized writes disabled now expects the error, and 
the ordering coverage case in `TestMergeIntoTable2`, which matched on `price` 
by accident, now matches on `id` with the same expected rows.
   
   ### Impact
   
   MERGE INTO statements on tables with a record key whose ON condition misses 
a record key column now fail with `Hudi tables with record key are required to 
match on all record key columns` instead of writing to rows the ON condition 
did not match. Such statements were already rejected when optimized writes were 
set explicitly.
   
   ### Risk Level
   
   low. Statements that relied on the lenient behavior now fail at analysis 
instead of writing.
   
   ### 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