@@ -20,18 +20,15 @@ use color_eyre::Result;
2020use datafusion_app:: local:: ExecutionContext ;
2121use datafusion_app:: { config:: merge_configs, extensions:: DftSessionStateBuilder } ;
2222use datafusion_dft:: args:: Command ;
23+ use datafusion_dft:: tui:: state:: AppState ;
2324use datafusion_dft:: {
24- args:: DftArgs ,
25- cli:: CliApp ,
26- execution:: AppExecution ,
27- telemetry,
28- tui:: { state, App } ,
25+ args:: DftArgs , cli:: CliApp , config:: create_config, execution:: AppExecution , telemetry, tui:: App ,
2926} ;
3027#[ cfg( feature = "flightsql" ) ]
3128use {
3229 datafusion_app:: config:: { AuthConfig , FlightSQLConfig } ,
3330 datafusion_app:: flightsql:: FlightSQLContext ,
34- datafusion_dft:: server :: FlightSqlApp ,
31+ datafusion_dft:: flightsql_server :: FlightSqlApp ,
3532 log:: info,
3633} ;
3734
@@ -66,44 +63,37 @@ async fn app_entry_point(cli: DftArgs) -> Result<()> {
6663 if should_init_env_logger ( & cli) {
6764 env_logger:: init ( ) ;
6865 }
69- let state = state :: initialize ( cli. config_path ( ) ) ;
66+ let cfg = create_config ( cli. config_path ( ) ) ;
7067 #[ cfg( feature = "flightsql" ) ]
7168 if let Some ( Command :: ServeFlightSql { .. } ) = cli. command {
72- let merged_exec_config = merge_configs (
73- state. config . shared . clone ( ) ,
74- state. config . flightsql_server . execution . clone ( ) ,
75- ) ;
69+ let merged_exec_config =
70+ merge_configs ( cfg. shared . clone ( ) , cfg. flightsql_server . execution . clone ( ) ) ;
7671 let session_state_builder =
7772 DftSessionStateBuilder :: try_new ( Some ( merged_exec_config. clone ( ) ) ) ?
7873 . with_extensions ( )
7974 . await ?;
8075 // FlightSQL Server mode: start a FlightSQL server
8176 const DEFAULT_SERVER_ADDRESS : & str = "127.0.0.1:50051" ;
8277 info ! ( "Starting FlightSQL server on {}" , DEFAULT_SERVER_ADDRESS ) ;
83- let session_state = session_state_builder
84- // .with_app_type(AppType::FlightSQLServer)
85- . build ( ) ?;
78+ let session_state = session_state_builder. build ( ) ?;
8679 let execution_ctx = ExecutionContext :: try_new ( & merged_exec_config, session_state) ?;
8780 if cli. run_ddl {
8881 execution_ctx. execute_ddl ( ) . await ;
8982 }
9083 let app_execution = AppExecution :: new ( execution_ctx) ;
9184 let app = FlightSqlApp :: try_new (
9285 app_execution,
93- & state . config ,
86+ & cfg ,
9487 & cli. flightsql_host
9588 . unwrap_or ( DEFAULT_SERVER_ADDRESS . to_string ( ) ) ,
96- & state . config . flightsql_server . server_metrics_port ,
89+ & cfg . flightsql_server . server_metrics_port ,
9790 )
9891 . await ?;
9992 app. run_app ( ) . await ;
10093 return Ok ( ( ) ) ;
10194 }
10295 if !cli. files . is_empty ( ) || !cli. commands . is_empty ( ) {
103- let merged_exec_config = merge_configs (
104- state. config . shared . clone ( ) ,
105- state. config . cli . execution . clone ( ) ,
106- ) ;
96+ let merged_exec_config = merge_configs ( cfg. shared . clone ( ) , cfg. cli . execution . clone ( ) ) ;
10797 let session_state_builder =
10898 DftSessionStateBuilder :: try_new ( Some ( merged_exec_config. clone ( ) ) ) ?
10999 . with_extensions ( )
@@ -118,12 +108,12 @@ async fn app_entry_point(cli: DftArgs) -> Result<()> {
118108 {
119109 if cli. flightsql {
120110 let auth = AuthConfig {
121- basic_auth : state . config . flightsql_client . auth . basic_auth ,
122- bearer_token : state . config . flightsql_client . auth . bearer_token ,
111+ basic_auth : cfg . flightsql_client . auth . basic_auth ,
112+ bearer_token : cfg . flightsql_client . auth . bearer_token ,
123113 } ;
124114 let flightsql_cfg = FlightSQLConfig :: new (
125- state . config . flightsql_client . connection_url ,
126- state . config . flightsql_client . benchmark_iterations ,
115+ cfg . flightsql_client . connection_url ,
116+ cfg . flightsql_client . benchmark_iterations ,
127117 auth,
128118 ) ;
129119 let flightsql_ctx = FlightSQLContext :: new ( flightsql_cfg) ;
@@ -136,10 +126,7 @@ async fn app_entry_point(cli: DftArgs) -> Result<()> {
136126 let app = CliApp :: new ( app_execution, cli. clone ( ) ) ;
137127 app. execute_files_or_commands ( ) . await ?;
138128 } else {
139- let merged_exec_config = merge_configs (
140- state. config . shared . clone ( ) ,
141- state. config . tui . execution . clone ( ) ,
142- ) ;
129+ let merged_exec_config = merge_configs ( cfg. shared . clone ( ) , cfg. tui . execution . clone ( ) ) ;
143130 let session_state_builder =
144131 DftSessionStateBuilder :: try_new ( Some ( merged_exec_config. clone ( ) ) ) ?
145132 . with_extensions ( )
@@ -148,7 +135,7 @@ async fn app_entry_point(cli: DftArgs) -> Result<()> {
148135
149136 // TUI mode: running the TUI
150137 telemetry:: initialize_logs ( ) ?; // use alternate logging for TUI
151- let state = state :: initialize ( cli . config_path ( ) ) ;
138+ let state = AppState :: new ( cfg ) ;
152139 let execution_ctx = ExecutionContext :: try_new ( & merged_exec_config, session_state) ?;
153140 let app_execution = AppExecution :: new ( execution_ctx) ;
154141 let app = App :: new ( state, cli, app_execution) ;
0 commit comments