1616// under the License.
1717
1818use datafusion:: physical_plan:: { displayable, ExecutionPlan , ExecutionPlanProperties } ;
19- use datafusion_proto:: physical_plan:: { AsExecutionPlan , DefaultPhysicalExtensionCodec } ;
19+ use datafusion_proto:: physical_plan:: { AsExecutionPlan , PhysicalExtensionCodec } ;
2020use prost:: Message ;
2121use std:: sync:: Arc ;
22-
22+ use deltalake :: delta_datafusion :: DeltaPhysicalCodec ;
2323use pyo3:: { exceptions:: PyRuntimeError , prelude:: * , types:: PyBytes } ;
2424
2525use crate :: { context:: PySessionContext , errors:: PyDataFusionResult } ;
@@ -59,10 +59,9 @@ impl PyExecutionPlan {
5959 }
6060
6161 pub fn to_proto < ' py > ( & ' py self , py : Python < ' py > ) -> PyDataFusionResult < Bound < ' py , PyBytes > > {
62- let codec = DefaultPhysicalExtensionCodec { } ;
6362 let proto = datafusion_proto:: protobuf:: PhysicalPlanNode :: try_from_physical_plan (
6463 self . plan . clone ( ) ,
65- & codec,
64+ codec ( ) ,
6665 ) ?;
6766
6867 let bytes = proto. encode_to_vec ( ) ;
@@ -82,8 +81,7 @@ impl PyExecutionPlan {
8281 ) )
8382 } ) ?;
8483
85- let codec = DefaultPhysicalExtensionCodec { } ;
86- let plan = proto_plan. try_into_physical_plan ( & ctx. ctx , & ctx. ctx . runtime_env ( ) , & codec) ?;
84+ let plan = proto_plan. try_into_physical_plan ( & ctx. ctx , & ctx. ctx . runtime_env ( ) , codec ( ) ) ?;
8785 Ok ( Self :: new ( plan) )
8886 }
8987
@@ -97,6 +95,11 @@ impl PyExecutionPlan {
9795 }
9896}
9997
98+ pub ( crate ) fn codec ( ) -> & ' static dyn PhysicalExtensionCodec {
99+ static CODEC : DeltaPhysicalCodec = DeltaPhysicalCodec { } ;
100+ & CODEC
101+ }
102+
100103impl From < PyExecutionPlan > for Arc < dyn ExecutionPlan > {
101104 fn from ( plan : PyExecutionPlan ) -> Arc < dyn ExecutionPlan > {
102105 plan. plan . clone ( )
0 commit comments