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

   ### Describe the issue this Pull Request addresses
   
   closes #20894
   
   A MERGE INTO with an always-false merge condition (`ON 1 != 1`, `ON false`) 
fails on a table with a record key with "Currently only equality predicates are 
supported in MERGE INTO statement on record key table", while the same 
statement works on a table without one.
   
   ### Summary and Changelog
   
   When the table has a record key, the merge condition folds to false, and the 
index can tell whether the table holds a key, `MergeIntoHoodieTableCommand` now 
runs the statement as an INSERT INTO of the source rows: each row takes the 
first not-matched clause whose condition accepts it (one `CASE WHEN` per column 
over the aligned clause values), rows no clause accepts are filtered out, and 
the matched clauses apply to nothing. The insert fails with 
`HoodieDuplicateKeyException` on a key the table already holds, whatever 
`hoodie.datasource.insert.dup.policy` says, since a MERGE INTO never writes a 
second record for one key. The index can tell for a record-level index or a 
non-bucket index of a copy-on-write table; elsewhere (for example a 
merge-on-read table with a simple, bloom or bucket index) the statement stays 
refused as before. The insert clauses go through the same checks as any MERGE 
INTO (record key and, under event time ordering, the ordering field must be 
assigned). Any ot
 her non-equality condition is still refused. Both the Spark 3 and Spark 4 
copies change the same way; a new test in `TestMergeIntoTable2` covers tables 
with and without a record key across COW/MOR and SIMPLE, BLOOM, BUCKET and 
record-level indexes.
   
   ### Impact
   
   MERGE INTO with an always-false condition now works on keyed copy-on-write 
tables and on tables with a record-level index, and fails on a key the table 
already holds. Other keyed tables keep the refusal.
   
   ### Risk Level
   
   low. Only statements whose merge condition is a constant false take the new 
path, and those failed before on tables with a record key.
   
   ### 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