NoahKusaba opened a new issue, #27930:
URL: https://github.com/apache/datafusion/issues/27930
### Is your feature request related to a problem or challenge?
`datafusion-proto` has `ComposedPhysicalExtensionCodec` to combine several
`PhysicalExtensionCodec`s, but nothing equivalent for
`LogicalExtensionCodec`.
A logical plan is serialized with a single codec, so an application whose
table
providers come from two independent crates (for example one codec per table
format) has to write its own composing codec.
Ballista hit this with its Iceberg integration: logical plans carry table
providers from the client to the scheduler, so Ballista's codec and the
Iceberg
codec have to be combined. Ballista now ships its own
`ComposedLogicalExtensionCodec` (apache/datafusion-ballista#2752), which
other
users would have to copy.
### Describe the solution you'd like
Add `datafusion_proto::logical_plan::ComposedLogicalExtensionCodec`, with the
same wire layout as `ComposedPhysicalExtensionCodec` (the position of the
encoding codec plus its bytes), routing every `LogicalExtensionCodec` method.
The trait's default encoders for functions and file formats succeed without
writing anything, so with "first codec that succeeds wins" the first codec
would claim every function and file format. For these, the first codec that
writes something should win instead:
- functions follow the approach discussed on #24973: if no codec writes a
payload, the function goes by name, and decoding by name tries each codec;
- file formats need the same rule, or composing
`[MyTableCodec, DefaultLogicalExtensionCodec]` breaks `COPY ... TO`.
Being a new type, it can also report errors more helpfully than the physical
codec does today:
- when exactly one codec recognised the node (returned something other than
`NotImplemented`), return its error unchanged, keeping its kind and source
chain;
- otherwise list every codec's error, not only the last one;
- report a payload that doesn't match the composed codecs as a configuration
error saying both sides must compose the same codecs in the same order.
### Describe alternatives you've considered
- Keep the codec in Ballista. Nothing in it is Ballista-specific, and any
`datafusion-proto` user with more than one logical codec needs it.
- A per-type decoder registry, like the ones added for physical plans and
expressions in #24631 and #24628. There is no logical equivalent yet, and
composing codecs stays useful alongside a registry, as it does for physical
plans.
### Additional context
#24973 (for #24829) routes the remaining methods of
`ComposedPhysicalExtensionCodec` and changes how functions sent by name are
encoded. This doesn't touch the physical codec, but follows the same function
handling, so the two can share one implementation once #24973 lands.
### Willingness to contribute
Yes, I have a branch ready.
--
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]