// Run a command against the currently selected remote database
Run a command against the currently selected remote database
Run a command against the currently selected remote database
async fn run_sql(&mut self, sql: String) -> Result<()> {
        let start = Instant::now();
        let batches = match &mut self.query_engine {
            None => {
                println!("Error: no database selected.");
                println!("Hint: Run USE DATABASE <dbname> to select database");
                return Ok(());
            }
            Some(QueryEngine::Remote(db_name)) => {
                info!(%db_name, %sql, "Running sql on remote database");
                scrape_query(&mut self.flight_client, db_name, &sql).await?
            }
            Some(QueryEngine::Observer(observer)) => {
                info!("Running sql on local observer");
                observer
                    .run_query(&sql)
                    .await
                    .context(RunningObserverQuerySnafu)?
            }
        };
        let end = Instant::now();
        self.print_results(&batches)?;
        println!(
            "Returned {} in {:?}",
            Self::row_summary(&batches),
            end - start
        );
        Ok(())
    }
async fn run_sql ( & mut self , sql : String ) -> Result < ( ) > { let start = Instant :: now ( ) ; let batches = match & mut self . query_engine { None => { println ! ( " " ) ; println ! ( " " ) ; return Ok ( ( ) ) ; } Some ( QueryEngine :: Remote ( db_name ) ) => { info ! ( db_name sql " " ) ; scrape_query ( & mut self . flight_client , db_name , & sql ) . await ? } Some ( QueryEngine :: Observer ( observer ) ) => { info ! ( " " ) ; observer . run_query ( & sql ) . await . context ( RunningObserverQuerySnafu ) ? } } ; let end = Instant :: now ( ) ; self . print_results ( & batches ) ? ; println ! ( " " Self row_summary ( batches ) end start ) ; Ok ( ( ) ) }
Run a command against the currently selected remote database
Run a command against the currently selected remote database
&mut self
sql
String