ethan-tyler opened a new pull request, #19142:
URL: https://github.com/apache/datafusion/pull/19142

   Add infrastructure for row-level DML operations (DELETE/UPDATE) to the 
TableProvider trait, enabling storage engines to implement SQL-based mutations.
   
   Changes:
   - Add `DmlCapabilities` struct to declare DELETE/UPDATE support
   - Add `TableProvider::dml_capabilities()` method (defaults to NONE)
   - Add `TableProvider::delete_from()` method for DELETE operations
   - Add `TableProvider::update()` method for UPDATE operations
   - Wire physical planner to route DML operations to TableProvider
   - Add helper functions for extracting filters and assignments
   
   This provides the API surface for downstream projects (iceberg-rust, 
delta-rs) to implement DML without custom query planners. A reference MemTable 
implementation follows in a subsequent PR.
   
   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and 
enhancements and this helps us generate change logs for our releases. You can 
link an issue to this PR using the GitHub syntax. For example `Closes #123` 
indicates that this PR will close issue #123.
   -->
   
   - Closes #16959
   - Related to #12406
   
   ## Rationale for this change
   
   DataFusion parses DELETE/UPDATE but returns NotImplemented("Unsupported 
logical plan: Dml(Delete)") at physical planning. Downstream projects 
(iceberg-rust, delta-rs) must implement custom planners to work around this.
   
   <!--
    Why are you proposing this change? If this is already explained clearly in 
the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your 
changes and offer better suggestions for fixes.  
   -->
   
   ## What changes are included in this PR?
   
   Adds TableProvider hooks for row-level DML:
   - DmlCapabilities struct with NONE, ALL, DELETE_ONLY, UPDATE_ONLY constants
   - dml_capabilities() returns supported operations (default: NONE)
   - delete_from(state, filters) deletes matching rows
   - update(state, assignments, filters) updates matching rows
   
   Physical planner routes WriteOp::Delete and WriteOp::Update to these 
methods. Return type matches insert_into(): Arc<dyn ExecutionPlan> producing 
{count: UInt64}.
   
   <!--
   There is no need to duplicate the description in the issue here but it is 
sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   ## Are these changes tested?
   
   Yes. Unit tests for DmlCapabilities:
   
   `cargo test -p datafusion-expr -- dml_capabilities
   `
   
   A follow-up PR provides MemTable implementation with comprehensive 
sqllogictest coverage (812 lines).
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are 
they covered by existing tests)?
   -->
   
   ## Are there any user-facing changes?
   
   New trait methods on TableProvider:
   
   ```
   fn dml_capabilities(&self) -> DmlCapabilities;
   async fn delete_from(&self, state: &dyn Session, filters: Vec<Expr>) -> 
Result<Arc<dyn ExecutionPlan>>;
   async fn update(&self, state: &dyn Session, assignments: Vec<(String, 
Expr)>, filters: Vec<Expr>) -> Result<Arc<dyn ExecutionPlan>>;
   ```
   
   Fully backward compatible. Defaults return NONE or NotImplemented.
   
   <!--
   If there are user-facing changes then we may require documentation to be 
updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api 
change` label.
   -->
   


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