wirybeaver opened a new issue, #20746:
URL: https://github.com/apache/datafusion/issues/20746

   ### Is your feature request related to a problem or challenge?
   
   The goal is to support MERGE INTO SQL statements in DataFusion so that 
downstream table providers (specifically Iceberg via iceberg-rust) can 
implement merge logic. The iceberg-rust repo (feature/merge-into branch) 
already has a merge_into function on its DataFusion table provider that expects 
DataFusion to parse MERGE INTO SQL and invoke a merge_into hook on 
TableProvider.
   
   Example SQL:
   ```
   MERGE INTO target_table t
   USING source_table s
   ON t.id = s.id
   WHEN MATCHED THEN UPDATE SET t.value = s.value
   WHEN NOT MATCHED THEN INSERT (id, value) VALUES (s.id, s.value)
   
   ### Describe the solution you'd like
   
   The implementation follows the same pattern as UPDATE/DELETE DML hooks 
(PR#19142). Reuse the existing DmlStatement logical plan node with a new 
WriteOp::MergeInto(MergeIntoOp) variant. The merge-specific data (ON condition, 
WHEN clauses) is carried in MergeIntoOp. The DmlStatement.input field holds the 
source plan (USING clause), and DmlStatement.target holds the target table.
   
   sqlparser v0.61.0 already parses Statement::Merge — no parser work needed.
   
   Planned Tasks:
   [] Add types to datafusion-expr (MergeIntoOp, MergeIntoClause, 
MergeIntoAction, MergeIntoClauseKind, WriteOp::MergeInto)
   [] Add merge_into hook to TableProvider trait
   [] Add SQL planner (merge_to_plan) + physical planner dispatch
   
   ### Describe alternatives you've considered
   
   _No response_
   
   ### Additional context
   
   _No response_


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to