@@ -49,7 +49,7 @@ use datafusion_datasource_parquet::source::ParquetSource;
4949#[ cfg( feature = "parquet" ) ]
5050use datafusion_execution:: object_store:: ObjectStoreUrl ;
5151use datafusion_execution:: { FunctionRegistry , TaskContext } ;
52- use datafusion_expr:: physical_planning_context:: { ScalarSubqueryResults , SubqueryIndex } ;
52+ use datafusion_expr:: physical_planning_context:: ScalarSubqueryResults ;
5353use datafusion_expr:: { AggregateUDF , HigherOrderUDF , ScalarUDF , WindowUDF } ;
5454use datafusion_functions_table:: generate_series:: {
5555 Empty , GenSeriesArgs , GenerateSeriesTable , GenericSeriesState , TimestampValue ,
@@ -85,7 +85,7 @@ use datafusion_physical_plan::proto::{
8585 ExecutionPlanEncodeCtx ,
8686} ;
8787use datafusion_physical_plan:: repartition:: RepartitionExec ;
88- use datafusion_physical_plan:: scalar_subquery:: { ScalarSubqueryExec , ScalarSubqueryLink } ;
88+ use datafusion_physical_plan:: scalar_subquery:: ScalarSubqueryExec ;
8989use datafusion_physical_plan:: sorts:: sort:: SortExec ;
9090use datafusion_physical_plan:: sorts:: sort_preserving_merge:: SortPreservingMergeExec ;
9191use datafusion_physical_plan:: union:: { InterleaveExec , UnionExec } ;
@@ -811,8 +811,8 @@ pub trait PhysicalPlanNodeExt: Sized {
811811 PhysicalPlanType :: Buffer ( _) => {
812812 BufferExec :: try_from_proto ( self . node ( ) , & decode_ctx)
813813 }
814- PhysicalPlanType :: ScalarSubquery ( sq ) => {
815- self . try_into_scalar_subquery_physical_plan ( sq , ctx , proto_converter )
814+ PhysicalPlanType :: ScalarSubquery ( _ ) => {
815+ ScalarSubqueryExec :: try_from_proto ( self . node ( ) , & decode_ctx )
816816 }
817817 }
818818 }
@@ -872,14 +872,6 @@ pub trait PhysicalPlanNodeExt: Sized {
872872 return Ok ( node) ;
873873 }
874874
875- if let Some ( exec) = plan. downcast_ref :: < ScalarSubqueryExec > ( ) {
876- return protobuf:: PhysicalPlanNode :: try_from_scalar_subquery_exec (
877- exec,
878- codec,
879- proto_converter,
880- ) ;
881- }
882-
883875 let mut buf: Vec < u8 > = vec ! [ ] ;
884876 match codec. try_encode ( Arc :: clone ( & plan_clone) , & mut buf, proto_converter) {
885877 Ok ( _) => {
@@ -1950,38 +1942,27 @@ pub trait PhysicalPlanNodeExt: Sized {
19501942 BufferExec :: try_from_proto ( & node, & decode_ctx)
19511943 }
19521944
1945+ #[ deprecated(
1946+ since = "55.0.0" ,
1947+ note = "unused by DataFusion; `ScalarSubqueryExec` deserializes itself via `ScalarSubqueryExec::try_from_proto`"
1948+ ) ]
19531949 fn try_into_scalar_subquery_physical_plan (
19541950 & self ,
19551951 sq : & protobuf:: ScalarSubqueryExecNode ,
19561952 ctx : & PhysicalPlanDecodeContext < ' _ > ,
19571953 proto_converter : & dyn PhysicalProtoConverterExtension ,
19581954 ) -> Result < Arc < dyn ExecutionPlan > > {
1959- // First, deserialize the main input plan. We set up the subquery results
1960- // container first, so that ScalarSubqueryExpr nodes can reference it.
1961- let subquery_results = ScalarSubqueryResults :: new ( sq. subqueries . len ( ) ) ;
1962- let input_ctx = ctx. with_scalar_subquery_results ( subquery_results. clone ( ) ) ;
1963- let input = into_physical_plan ( & sq. input , & input_ctx, proto_converter) ?;
1964-
1965- // Now deserialize the subquery children.
1966- let subqueries: Vec < ScalarSubqueryLink > = sq
1967- . subqueries
1968- . iter ( )
1969- . enumerate ( )
1970- . map ( |( index, sq_plan) | {
1971- let plan =
1972- sq_plan. try_into_physical_plan_with_context ( ctx, proto_converter) ?;
1973- Ok ( ScalarSubqueryLink {
1974- plan,
1975- index : SubqueryIndex :: new ( index) ,
1976- } )
1977- } )
1978- . collect :: < Result < Vec < _ > > > ( ) ?;
1979-
1980- Ok ( Arc :: new ( ScalarSubqueryExec :: new (
1981- input,
1982- subqueries,
1983- subquery_results,
1984- ) ) )
1955+ let node = protobuf:: PhysicalPlanNode {
1956+ physical_plan_type : Some ( PhysicalPlanType :: ScalarSubquery ( Box :: new (
1957+ sq. clone ( ) ,
1958+ ) ) ) ,
1959+ } ;
1960+ let decoder = ConverterPlanDecoder {
1961+ ctx,
1962+ proto_converter,
1963+ } ;
1964+ let decode_ctx = ExecutionPlanDecodeCtx :: new ( & decoder) ;
1965+ ScalarSubqueryExec :: try_from_proto ( & node, & decode_ctx)
19851966 }
19861967
19871968 #[ deprecated(
@@ -2866,35 +2847,22 @@ pub trait PhysicalPlanNodeExt: Sized {
28662847 . ok_or_else ( || internal_datafusion_err ! ( "BufferExec is not serializable" ) )
28672848 }
28682849
2850+ #[ deprecated(
2851+ since = "55.0.0" ,
2852+ note = "unused by DataFusion; `ScalarSubqueryExec` serializes itself via `ExecutionPlan::try_to_proto`"
2853+ ) ]
28692854 fn try_from_scalar_subquery_exec (
28702855 exec : & ScalarSubqueryExec ,
28712856 codec : & dyn PhysicalExtensionCodec ,
28722857 proto_converter : & dyn PhysicalProtoConverterExtension ,
28732858 ) -> Result < protobuf:: PhysicalPlanNode > {
2874- let input = protobuf:: PhysicalPlanNode :: try_from_physical_plan_with_converter (
2875- Arc :: clone ( exec. input ( ) ) ,
2859+ let encoder = ConverterPlanEncoder {
28762860 codec,
28772861 proto_converter,
2878- ) ?;
2879- let subqueries = exec
2880- . subqueries ( )
2881- . iter ( )
2882- . map ( |sq| {
2883- protobuf:: PhysicalPlanNode :: try_from_physical_plan_with_converter (
2884- Arc :: clone ( & sq. plan ) ,
2885- codec,
2886- proto_converter,
2887- )
2888- } )
2889- . collect :: < Result < Vec < _ > > > ( ) ?;
2890-
2891- Ok ( protobuf:: PhysicalPlanNode {
2892- physical_plan_type : Some ( PhysicalPlanType :: ScalarSubquery ( Box :: new (
2893- protobuf:: ScalarSubqueryExecNode {
2894- input : Some ( Box :: new ( input) ) ,
2895- subqueries,
2896- } ,
2897- ) ) ) ,
2862+ } ;
2863+ let encode_ctx = ExecutionPlanEncodeCtx :: new ( & encoder) ;
2864+ exec. try_to_proto ( & encode_ctx) ?. ok_or_else ( || {
2865+ internal_datafusion_err ! ( "ScalarSubqueryExec is not serializable" )
28982866 } )
28992867 }
29002868}
@@ -3485,6 +3453,16 @@ impl ExecutionPlanDecode for ConverterPlanDecoder<'_, '_> {
34853453 self . proto_converter . proto_to_execution_plan ( node, self . ctx )
34863454 }
34873455
3456+ fn decode_plan_with_scalar_subquery_results (
3457+ & self ,
3458+ node : & protobuf:: PhysicalPlanNode ,
3459+ results : ScalarSubqueryResults ,
3460+ ) -> Result < Arc < dyn ExecutionPlan > > {
3461+ let scoped_ctx = self . ctx . with_scalar_subquery_results ( results) ;
3462+ self . proto_converter
3463+ . proto_to_execution_plan ( node, & scoped_ctx)
3464+ }
3465+
34883466 fn decode_expr (
34893467 & self ,
34903468 node : & protobuf:: PhysicalExprNode ,
0 commit comments