From e8a3fbabb1b3d5e27057e62e62fe16b8cf828cc0 Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Thu, 12 Sep 2024 07:29:13 -0400 Subject: [PATCH 1/2] Fix clippy warning about loop that never executes --- src/app/handlers/flightsql.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/app/handlers/flightsql.rs b/src/app/handlers/flightsql.rs index 65af60a..83c8868 100644 --- a/src/app/handlers/flightsql.rs +++ b/src/app/handlers/flightsql.rs @@ -91,14 +91,12 @@ pub fn normal_mode_handler(app: &mut App, key: KeyEvent) { Ok(batch) => { info!("Batch rows: {}", batch.num_rows()); batches.push(batch); - break; } Err(e) => { error!("Error getting batch: {:?}", e); let elapsed = start.elapsed(); query.set_error(Some(e.to_string())); query.set_execution_time(elapsed); - break; } } } From 037826a6500af5fd27bc4a0a8e7bed6418e1517e Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Thu, 12 Sep 2024 08:55:49 -0400 Subject: [PATCH 2/2] Alternate fix for clippy, still only show one batch --- src/app/handlers/flightsql.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/handlers/flightsql.rs b/src/app/handlers/flightsql.rs index bdf8f57..195d9d4 100644 --- a/src/app/handlers/flightsql.rs +++ b/src/app/handlers/flightsql.rs @@ -86,7 +86,12 @@ pub fn normal_mode_handler(app: &mut App, key: KeyEvent) { match c.do_get(ticket.into_request()).await { Ok(mut stream) => { let mut batches: Vec = Vec::new(); - while let Some(maybe_batch) = stream.next().await { + // temporarily only show the first batch to avoid + // buffering massive result sets. Eventually there should + // be some sort of paging logic + // see https://github.com/datafusion-contrib/datafusion-tui/pull/133#discussion_r1756680874 + // while let Some(maybe_batch) = stream.next().await { + if let Some(maybe_batch) = stream.next().await { match maybe_batch { Ok(batch) => { info!("Batch rows: {}", batch.num_rows()); @@ -100,7 +105,6 @@ pub fn normal_mode_handler(app: &mut App, key: KeyEvent) { } } } - let elapsed = start.elapsed(); let rows: usize = batches.iter().map(|r| r.num_rows()).sum();