Skip to content

fix(ffi): preserve TableProvider DML overrides - #23906

Merged
kosiew merged 5 commits into
apache:mainfrom
Amogh-2404:fix/issue-22328-ffi-table-provider-defaults
Aug 13, 2026
Merged

kosiew merged 5 commits into
apache:mainfrom
Amogh-2404:fix/issue-22328-ffi-table-provider-defaults

Conversation

@Amogh-2404

@Amogh-2404 Amogh-2404 commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Part of #22328.

Rationale for this change

ForeignTableProvider inherits the default DML methods, so producer overrides are lost across the FFI boundary and writable tables appear read-only.

What changes are included in this PR?

  • Forward delete_from, update, and truncate through FFI_TableProvider.
  • Preserve ordered filters and assignments across the boundary.
  • Move expression-list byte encoding and decoding into reusable datafusion-proto helpers.
  • Cover forced-foreign and dynamic-library paths, including empty filters and malformed update payloads.

Are these changes tested?

  • cargo test -p datafusion-ffi --features integration-tests
  • cargo clippy --all-targets --all-features -- -D warnings

Are there any user-facing changes?

The FFI ABI changes. Foreign libraries must rebuild against the new DataFusion version.

@github-actions github-actions Bot added ffi Changes to the ffi crate auto detected api change Auto detected API change labels Jul 26, 2026
@Amogh-2404
Amogh-2404 force-pushed the fix/issue-22328-ffi-table-provider-defaults branch from ca8af01 to 5568899 Compare July 26, 2026 13:41
@github-actions github-actions Bot removed the auto detected api change Auto detected API change label Jul 26, 2026
@codecov-commenter

codecov-commenter commented Jul 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.08824% with 46 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.29%. Comparing base (9b3b518) to head (8c72608).

Files with missing lines Patch % Lines
datafusion/ffi/src/table_provider.rs 86.07% 10 Missing and 23 partials ⚠️
datafusion/ffi/src/udtf.rs 38.46% 6 Missing and 2 partials ⚠️
datafusion/proto/src/bytes/mod.rs 77.27% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main   #23906    +/-   ##
========================================
  Coverage   81.29%   81.29%            
========================================
  Files        1110     1110            
  Lines      385336   385553   +217     
  Branches   385336   385553   +217     
========================================
+ Hits       313261   313449   +188     
  Misses      53594    53594            
- Partials    18481    18510    +29     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kosiew
kosiew requested a review from timsaucer August 3, 2026 09:26

@kosiew kosiew left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Amogh-2404
Thanks for working on this!

This looks good to me overall. I just have one small suggestion that could help strengthen the test coverage.

Comment thread datafusion/ffi/tests/ffi_integration.rs Resolved
@timsaucer
timsaucer requested a review from Copilot August 3, 2026 12:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Preserves TableProvider DML overrides (delete/update/truncate) across the FFI boundary so foreign table providers remain writable rather than falling back to default read-only behavior.

Changes:

  • Adds FFI forwarding for delete_from, update, and truncate and ensures ordered filters/assignments survive serialization.
  • Refactors expression (de)serialization into helpers used by scan/pushdown/DML.
  • Adds integration + round-trip tests, including malformed update assignment payload coverage.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
datafusion/ffi/tests/ffi_integration.rs Adds cross-library integration test verifying DML plans are produced via FFI provider.
datafusion/ffi/src/tests/mod.rs Extends test provider to implement DML overrides and validate received filters/assignments.
datafusion/ffi/src/table_provider.rs Extends FFI ABI to include DML function pointers; adds wrappers, serialization helpers, and unit tests.
Suppressed comments (1)

datafusion/ffi/src/table_provider.rs:1

  • This changes the FFI_TableProvider ABI/layout by adding new function pointers. If an older foreign library is loaded at runtime, reading/calling these new fields can become UB (crash) rather than a clean error. Recommendation (mandatory): bump/extend the FFI ABI versioning and enforce it before constructing/using ForeignTableProvider DML methods (e.g., reject older providers early with a clear error), or gate calls behind an explicit version/feature check with safe fallbacks.
// Licensed to the Apache Software Foundation (ASF) under one

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread datafusion/ffi/src/table_provider.rs Resolved
Comment thread datafusion/ffi/src/table_provider.rs Resolved
Comment thread datafusion/ffi/src/table_provider.rs Resolved
Comment thread datafusion/ffi/src/table_provider.rs Resolved
Comment thread datafusion/ffi/src/table_provider.rs Resolved

@timsaucer timsaucer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR!

Overall this looks very nice. I have a couple of organizational comments, but the general flow looks good to me.

Comment thread datafusion/ffi/src/table_provider.rs Resolved
Comment thread datafusion/ffi/src/table_provider.rs Resolved
Comment thread datafusion/ffi/src/table_provider.rs Resolved
Comment thread datafusion/ffi/src/table_provider.rs Resolved
@Amogh-2404
Amogh-2404 force-pushed the fix/issue-22328-ffi-table-provider-defaults branch from 64923e2 to 8c72608 Compare August 12, 2026 11:58
@github-actions github-actions Bot added the proto Related to proto crate label Aug 12, 2026
@kosiew kosiew added the api change Changes the API exposed to users of the crate label Aug 13, 2026
@kosiew
kosiew added this pull request to the merge queue Aug 13, 2026
@kosiew

kosiew commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

thanks @Amogh-2404

Merged via the queue into apache:main with commit ab12f5e Aug 13, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api change Changes the API exposed to users of the crate ffi Changes to the ffi crate proto Related to proto crate v56.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants