@@ -2,7 +2,7 @@ use crate::execution_plans::{ExecutionTask, StageExec};
22use datafusion:: {
33 common:: internal_datafusion_err,
44 error:: { DataFusionError , Result } ,
5- execution:: { SessionState , context :: SessionContext , runtime_env :: RuntimeEnv } ,
5+ execution:: { runtime_env :: RuntimeEnv , context :: SessionContext } ,
66 physical_plan:: ExecutionPlan ,
77} ;
88use datafusion_proto:: {
@@ -100,22 +100,21 @@ pub fn proto_from_stage(
100100
101101pub fn stage_from_proto (
102102 msg : StageExecProto ,
103- session_state : & SessionState ,
103+ ctx : & SessionContext ,
104104 runtime : & RuntimeEnv ,
105105 codec : & dyn PhysicalExtensionCodec ,
106106) -> Result < StageExec > {
107107 let plan_node = msg. plan . ok_or ( internal_datafusion_err ! (
108108 "ExecutionStageMsg is missing the plan"
109109 ) ) ?;
110110
111- let session_ctx = SessionContext :: new_with_state ( session_state. clone ( ) ) ;
112- let plan = plan_node. try_into_physical_plan ( & session_ctx, runtime, codec) ?;
111+ let plan = plan_node. try_into_physical_plan ( & ctx, runtime, codec) ?;
113112
114113 let inputs = msg
115114 . inputs
116115 . into_iter ( )
117116 . map ( |s| {
118- stage_from_proto ( s, session_state , runtime, codec)
117+ stage_from_proto ( s, ctx , runtime, codec)
119118 . map ( |s| Arc :: new ( s) as Arc < dyn ExecutionPlan > )
120119 } )
121120 . collect :: < Result < Vec < _ > > > ( ) ?;
@@ -153,9 +152,9 @@ pub fn stage_from_proto(
153152mod tests {
154153 use std:: sync:: Arc ;
155154
156- use crate :: StageExec ;
157155 use crate :: protobuf:: stage_proto:: StageExecProto ;
158156 use crate :: protobuf:: { proto_from_stage, stage_from_proto} ;
157+ use crate :: StageExec ;
159158 use datafusion:: {
160159 arrow:: {
161160 array:: { RecordBatch , StringArray , UInt8Array } ,
@@ -230,7 +229,7 @@ mod tests {
230229 // Convert back to ExecutionStage
231230 let round_trip_stage = stage_from_proto (
232231 decoded_msg,
233- & ctx. state ( ) ,
232+ & ctx,
234233 ctx. runtime_env ( ) . as_ref ( ) ,
235234 & DefaultPhysicalExtensionCodec { } ,
236235 ) ?;
0 commit comments