slfan1989 opened a new issue, #1262:
URL: https://github.com/apache/paimon-rust/issues/1262

   ### Search before asking
   
   - [x] I searched in the 
[issues](https://github.com/apache/paimon-rust/issues) and found nothing 
similar.
   
   
   ### Please describe the bug 🐞
   
   MERGE does not preserve predicate grouping when combining clause conditions 
with exclusions for earlier clauses.
   
   For example:
   
   ```sql
   WHEN NOT MATCHED AND s.flag = 1
     THEN INSERT VALUES (s.id, 'first')
   WHEN NOT MATCHED AND s.flag = 0 OR s.flag = 1
     THEN INSERT VALUES (s.id, 'second')
   ```
   
   For a source row with `flag = 1`:
   
   - Expected: only the first clause inserts the row.
   - Actual: both clauses insert the row, producing duplicate data.
   
   The same issue affects WHEN MATCHED clauses, where it can trigger a 
duplicate UPDATE error.
   
   ### Solution
   
   Wrap each clause predicate in parentheses before combining it with 
earlier-clause exclusions using AND.
   
   Add regression tests for matched UPDATE/DELETE clauses and unmatched INSERT 
clauses on ordinary and Data Evolution tables.
   
   ### Are you willing to submit a PR?
   
   - [x] I'm willing to submit a PR!


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