@@ -36,14 +36,16 @@ use datafusion::datasource::listing::{
3636} ;
3737use datafusion:: datasource:: { MemTable , TableProvider } ;
3838use datafusion:: error:: { DataFusionError , Result } ;
39- use datafusion:: execution:: SessionStateBuilder ;
39+ use datafusion:: execution:: { SessionState , SessionStateBuilder } ;
4040use datafusion:: physical_plan:: display:: DisplayableExecutionPlan ;
4141use datafusion:: physical_plan:: { collect, displayable} ;
4242use datafusion:: prelude:: * ;
4343
4444use crate :: util:: { print_memory_stats, BenchmarkRun , CommonOpt , QueryResult } ;
4545use datafusion_distributed:: test_utils:: localhost:: start_localhost_context;
46- use datafusion_distributed:: { DistributedPhysicalOptimizerRule , SessionBuilder } ;
46+ use datafusion_distributed:: {
47+ DistributedPhysicalOptimizerRule , DistributedSessionBuilder , DistributedSessionBuilderContext ,
48+ } ;
4749use log:: info;
4850use structopt:: StructOpt ;
4951
@@ -110,31 +112,19 @@ pub struct RunOpt {
110112}
111113
112114#[ async_trait]
113- impl SessionBuilder for RunOpt {
114- fn session_state_builder (
115+ impl DistributedSessionBuilder for RunOpt {
116+ async fn build_session_state (
115117 & self ,
116- mut builder : SessionStateBuilder ,
117- ) -> Result < SessionStateBuilder , DataFusionError > {
118- let mut config = self
118+ _ctx : DistributedSessionBuilderContext ,
119+ ) -> Result < SessionState , DataFusionError > {
120+ let mut builder = SessionStateBuilder :: new ( ) . with_default_features ( ) ;
121+
122+ let config = self
119123 . common
120124 . config ( ) ?
121125 . with_collect_statistics ( !self . disable_statistics )
122126 . with_target_partitions ( self . partitions ( ) ) ;
123127
124- // // FIXME: these three options are critical for the correct function of the library
125- // // but we are not enforcing that the user sets them. They are here at the moment
126- // // but we should figure out a way to do this better.
127- // config
128- // .options_mut()
129- // .optimizer
130- // .hash_join_single_partition_threshold = 0;
131- // config
132- // .options_mut()
133- // .optimizer
134- // .hash_join_single_partition_threshold_rows = 0;
135- //
136- // config.options_mut().optimizer.prefer_hash_join = self.prefer_hash_join;
137- // end critical options section
138128 let rt_builder = self . common . runtime_env_builder ( ) ?;
139129
140130 if self . distributed {
@@ -145,17 +135,14 @@ impl SessionBuilder for RunOpt {
145135 builder = builder. with_physical_optimizer_rule ( Arc :: new ( rule) ) ;
146136 }
147137
148- Ok ( builder
138+ let state = builder
149139 . with_config ( config)
150- . with_runtime_env ( rt_builder. build_arc ( ) ?) )
151- }
140+ . with_runtime_env ( rt_builder. build_arc ( ) ?)
141+ . build ( ) ;
152142
153- async fn session_context (
154- & self ,
155- ctx : SessionContext ,
156- ) -> std:: result:: Result < SessionContext , DataFusionError > {
143+ let ctx = SessionContext :: from ( state) ;
157144 self . register_tables ( & ctx) . await ?;
158- Ok ( ctx)
145+ Ok ( ctx. state ( ) )
159146 }
160147}
161148
0 commit comments