@@ -42,24 +42,25 @@ use crate::{
4242
4343pub type FlightSQLClient = Arc < Mutex < Option < FlightSqlServiceClient < Channel > > > > ;
4444
45- #[ derive( Clone , Default ) ]
45+ #[ derive( Clone , Debug , Default ) ]
4646pub struct FlightSQLContext {
4747 config : FlightSQLConfig ,
48- flightsql_client : FlightSQLClient ,
48+ client : FlightSQLClient ,
4949}
5050
5151impl FlightSQLContext {
5252 pub fn new ( config : FlightSQLConfig ) -> Self {
5353 Self {
5454 config,
55- flightsql_client : Arc :: new ( Mutex :: new ( None ) ) ,
55+ client : Arc :: new ( Mutex :: new ( None ) ) ,
5656 }
5757 }
5858
5959 pub fn client ( & self ) -> & FlightSQLClient {
60- & self . flightsql_client
60+ & self . client
6161 }
6262
63+ // TODO - Make this part of `new` method
6364 /// Create FlightSQL client from users FlightSQL config
6465 pub async fn create_client ( & self , cli_host : Option < String > ) -> Result < ( ) > {
6566 let final_url = cli_host. unwrap_or ( self . config . connection_url . clone ( ) ) ;
@@ -74,6 +75,7 @@ impl FlightSQLContext {
7475 //
7576 // Although that is for HTTP/1.1 and GRPC uses HTTP/2 - so maybe it has changed.
7677 // To be tested later with the Tower auth layers to see what they support.
78+ // TODO - Do we need this feature block?
7779 #[ cfg( feature = "flightsql" ) ]
7880 {
7981 if let Some ( token) = & self . config . auth . bearer_token {
@@ -85,7 +87,7 @@ impl FlightSQLContext {
8587 client. set_header ( "Authorization" , format ! ( "Basic {encoded_basic}" ) )
8688 }
8789 }
88- let mut guard = self . flightsql_client . lock ( ) . await ;
90+ let mut guard = self . client . lock ( ) . await ;
8991 * guard = Some ( client) ;
9092 Ok ( ( ) )
9193 }
@@ -111,7 +113,7 @@ impl FlightSQLContext {
111113 let dialect = datafusion:: sql:: sqlparser:: dialect:: GenericDialect { } ;
112114 let statements = DFParser :: parse_sql_with_dialect ( query, & dialect) ?;
113115 if statements. len ( ) == 1 {
114- if let Some ( ref mut client) = * self . flightsql_client . lock ( ) . await {
116+ if let Some ( ref mut client) = * self . client . lock ( ) . await {
115117 for _ in 0 ..iterations {
116118 let mut rows = 0 ;
117119 let start = std:: time:: Instant :: now ( ) ;
@@ -171,7 +173,7 @@ impl FlightSQLContext {
171173 sql : & str ,
172174 _opts : ExecOptions ,
173175 ) -> DFResult < ExecResult > {
174- if let Some ( ref mut client) = * self . flightsql_client . lock ( ) . await {
176+ if let Some ( ref mut client) = * self . client . lock ( ) . await {
175177 let flight_info = client. execute ( sql. to_string ( ) , None ) . await ?;
176178 if flight_info. endpoint . len ( ) != 1 {
177179 return Err ( DataFusionError :: External ( "More than one endpoint" . into ( ) ) ) ;
0 commit comments