fix(ffi): use the session's LogicalExtensionCodec in create_physical_plan - #24690
Merged
timsaucer merged 1 commit intoAug 26, 2026
Merged
Conversation
…plan `Session::create_physical_plan` was the one method on `FFI_SessionRef` that never consulted the session's `logical_codec`. Both sides of the boundary serialized the logical plan with the codec-less helpers: `ForeignSession::create_physical_plan` called `logical_plan_to_bytes` and `create_physical_plan_fn_wrapper` called `logical_plan_from_bytes`. As a result, a foreign library holding an `FFI_SessionRef` could not call `create_physical_plan` for any plan referencing a custom table provider or other extension node. Serialization failed with "This feature is not implemented: LogicalExtensionCodec is not provided", even though the neighboring `optimize` path already used the codec-aware helpers. Both sides now use `logical_plan_to_bytes_with_extension_codec` and `logical_plan_from_bytes_with_extension_codec`. In the wrapper the codec is extracted before `session.inner()` shadows the binding. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
alamb
approved these changes
Aug 26, 2026
timsaucer
enabled auto-merge
August 26, 2026 12:09
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #24690 +/- ##
==========================================
- Coverage 81.45% 81.45% -0.01%
==========================================
Files 1119 1119
Lines 400045 400069 +24
Branches 400045 400069 +24
==========================================
+ Hits 325859 325874 +15
- Misses 55146 55148 +2
- Partials 19040 19047 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Session::create_physical_planover FFI ignores the session'sLogicalExtensionCodec#24688.Rationale for this change
A foreign library that holds an FFI session reference cannot call
Session::create_physical_planfor any plan that references a custom table provider or other extension node. Planning fails with:What changes are included in this PR?
In
datafusion/ffi/src/session/mod.rs, we now serialize and deserialize logical plans using codecs. This matches whatoptimize_fn_wrapperandForeignSession::optimizealready do.Are these changes tested?
Yes. A new unit test,
session::tests::test_create_physical_plan_uses_logical_codec, registers aMemTablethat can only be serialized by a custom codec, wraps the session in anFFI_SessionRefcarrying that codec, and plans a scan of it throughForeignSession::create_physical_plan.The test was verified to reproduce the bug: with either half of the fix reverted it fails.
Are there any user-facing changes?
No API changes.
Session::create_physical_planover FFI now works for plans that require the session'sLogicalExtensionCodecinstead of returning a not-implemented error. No breaking changes.