Repository navigation
Description
Is your feature request related to a problem or challenge?
Who this is for: people who ship physical plans between processes (for example, distributed engines built on datafusion-proto) and who have their own DataSource, FileSource or DataSink types. Users of only the built-in Parquet/CSV/JSON/Avro/Arrow sources are not affected.
Example: a distributed engine scans a file format that is not part of DataFusion. VortexSource implements FileSource. The coordinator must send the scan to the workers.
VortexSource has one piece of its own state (a pushed-down predicate). Today its hook must still produce the whole plan node, including everything that FileScanConfig owns:
impl FileSource for VortexSource {
fn try_to_proto(&self, base: &FileScanConfig, ctx: &ExecutionPlanEncodeCtx<'_>)
-> Result<Option<PhysicalPlanNode>>
{
// Must carry the shared config (files, projection, statistics, limit) itself
let my_msg = MyVortexScan {
base_conf: Some(base.try_to_proto(ctx)?),
predicate: self.encode_predicate(ctx)?,
};
// ...and wrap it in a plan-level extension node
Ok(Some(PhysicalPlanNode { /* extension { node: my_msg bytes } */ }))
}
}On the worker, a PhysicalExtensionCodec must recognize those bytes among every other extension plan, rebuild the FileScanConfig, and wrap it in a DataSourceExec.
| Problem | Effect |
|---|---|
| The source writes state that it does not own | Each custom source copies the FileScanConfig and DataSourceExec wire logic, and breaks when that logic changes |
The wire format has no slot for "a FileSource" or "a DataSink" |
A custom type can only appear as a whole-plan extension node |
Decode goes through one PhysicalExtensionCodec |
An application that combines sources from several libraries must compose their codecs (#24331) |
Describe the solution you'd like
The source describes only itself, and DataFusion writes the wrappers:
impl FileSource for VortexSource {
fn try_to_proto_file_source(&self, ctx: &ExecutionPlanEncodeCtx<'_>)
-> Result<Option<FileSourceNode>>
{
Ok(Some(FileSourceNode {
file_source_type: Some(FileSourceType::Extension(ExtensionFileSourceNode {
name: "vortex".into(),
payload: self.encode_predicate(ctx)?, // only its own state
})),
}))
}
}On the worker, VortexSource registers a decoder under the name "vortex". The decoder receives only the payload. No PhysicalExtensionCodec is needed. The same applies to a custom DataSource and a custom DataSink.
Work items:
- Wire format with one message per trait level, and the encode hooks: #26824
- Decode an extension
DataSource/FileSourcethrough a per-type registry: #27968 (replaces #26555) - Decode an extension
DataSinkthrough a per-type registry: #27969 (replaces #26807) - An example in
datafusion-examplesthat serializes and deserializes a custom source: #28004 - Link that example from the 57.0.0 upgrade guide: #28004
Follow-up, not part of this issue: functions that carry state still need a codec. See #28006.
Describe alternatives you've considered
Keep the whole-plan hooks and give custom sources public helpers that build the wrapper node. This keeps two ways to serialize a source, and a source can still return any plan variant.
Additional context
This continues the per-type registry work for extension ExecutionPlans (#24625) and extension PhysicalExprs (#24626).
Activity
proto: layered DataSource / FileSource / DataSink nodes (precursor to a…
proto: layered DataSource / FileSource / DataSink nodes (precursor to a…
feat: allow extension DataSources and FileSources to decode via a per…
feat: allow extension DataSinks to decode via a per-type registry (ap…
adriangb commentedon Dec 3, 2026
Example PR is up! We're almost done here 🚀 #28004