Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
//! trait's interception methods (`execution_plan_to_proto` and
//! `proto_to_execution_plan`) to implement custom serialization logic.
//!
//! The key insight is that `FileScanConfig::expr_adapter_factory` is NOT serialized by
//! default. This example shows how to:
//! The key insight is that a non-default `FileScanConfig::expr_adapter_factory`
//! cannot be serialized by the default protobuf path. This example shows how to:
//! 1. Detect plans with custom adapters during serialization
//! 2. Wrap them as Extension nodes with JSON-serialized adapter metadata
//! 3. Store the inner DataSourceExec (without adapter) as a child in the extension's inputs field
//! 3. Explicitly remove the captured adapter from the inner `DataSourceExec`
//! 4. Unwrap and restore the adapter during deserialization
//!
//! This demonstrates nested serialization (protobuf outer, JSON inner) and the
Expand Down Expand Up @@ -333,10 +333,14 @@ impl PhysicalProtoConverterExtension for AdapterPreservingCodec {
// 1. Create adapter metadata
let adapter_metadata = AdapterMetadata { tag };

// 2. Serialize the inner plan to protobuf
// Note that this will drop the custom adapter since the default serialization cannot handle it
// 2. The metadata is captured above, so explicitly remove the custom
// adapter before using the guarded default serializer for the child.
let mut inner_config = config.clone();
inner_config.expr_adapter_factory = None;
let inner_plan: Arc<dyn ExecutionPlan> =
DataSourceExec::from_data_source(inner_config);
let inner_proto = PhysicalPlanNode::try_from_physical_plan_with_converter(
Arc::clone(plan),
inner_plan,
extension_codec,
self,
)?;
Expand Down
Loading