Repository navigation
feat: add ComposedLogicalExtensionCodec - #27931
Open
NoahKusaba wants to merge 1 commit into
Open
NoahKusaba wants to merge 1 commit into
NoahKusaba wants to merge 1 commit into
Conversation
Add the logical counterpart of ComposedPhysicalExtensionCodec, sharing its DataEncoderTuple payload layout, so a logical plan can be serialized with codecs from several independent crates. The trait's default encoders for functions and file formats succeed without writing anything, so for these the first codec that writes something wins. A function no codec writes a payload for goes by name; a file format no codec writes stays with the first codec that succeeded.
NoahKusaba
marked this pull request as ready for review
December 1, 2026 22:21
Author
|
cc @milenkovicm |
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?
ComposedLogicalExtensionCodec, the logical counterpart ofComposedPhysicalExtensionCodec#27930.Rationale for this change
datafusion-protocan compose physical codecs withComposedPhysicalExtensionCodecbut not logical ones, so a logical plan whosetable providers come from two independent crates can't be serialized without a
hand-written composing codec. Ballista carries its own for its Iceberg
integration (apache/datafusion-ballista#2752).
This PR is based on Ballista's codec, but changes how it handles functions,
file formats and errors, as described below. The payload layout is the same,
and Ballista's own composition (its codec, then the Iceberg codec) encodes byte
for byte the same.
What changes are included in this PR?
datafusion_proto::logical_plan::ComposedLogicalExtensionCodec, which routesevery
LogicalExtensionCodecmethod through the composed codecs. It writes thesame
DataEncoderTupleasComposedPhysicalExtensionCodec(nowpub(crate)),so both share one payload layout.
Plan nodes and table providers work as in the physical codec: the first codec
that succeeds claims the node, even with a zero-byte encoding, and only that
codec decodes it.
The trait's default encoders for functions and file formats succeed without
writing anything, so for these the first codec that writes something wins:
payload, the function goes by name: it is resolved from the registry, or else
by the first codec that can decode it.
claims the format. Without this rule, composing
[MyTableCodec, DefaultLogicalExtensionCodec]breaksCOPY ... TO:MyTableCodecclaims the CSV format with zero bytes and can't decode it.Errors:
NotImplemented), its error is returned unchanged;NotImplementedwhen every codecdeclined, so a composed codec nested in another still declines. The wording
matches fix: delegate the remaining codec methods in ComposedPhysicalExtensionCodec #24973's ("None of the N composed codecs could decode 'name' by
name");
configuration error saying both sides must compose the same codecs in the
same order.
ComposedPhysicalExtensionCodecis unchanged apart from sharing the wirestruct, to avoid conflicting with #24973. Once that lands, both codecs can share
one implementation.
What is the testing strategy for this PR?
Unit tests in
datafusion/proto/src/logical_plan/composed.rscover each ruleabove: position recording and position-only decoding (with codecs that would
decode any bytes), discarding a failed codec's partial write, zero-byte nodes at
position 0 and above, mismatched payloads, each error case, every kind of
function by name, and both file format cases. A
COPY (SELECT upper(...)) ... STORED AS CSVplan round trips with the table, file format and function eachhandled differently.
The doctest round-trips a
COPYplan with a custom codec listed before thedefault one.
Are there any user-facing changes?
One new public type,
datafusion_proto::logical_plan::ComposedLogicalExtensionCodec.No breaking changes.