diff --git a/src/commands/sql/repl.rs b/src/commands/sql/repl.rs index d33251b0e4..9e2de371e2 100644 --- a/src/commands/sql/repl.rs +++ b/src/commands/sql/repl.rs @@ -230,10 +230,26 @@ impl Repl { let end = Instant::now(); self.print_results(&batches)?; - println!("Query execution complete in {:?}", end - start); + println!( + "Returned {} in {:?}", + Self::row_summary(&batches), + end - start + ); Ok(()) } + fn row_summary<'a>(batches: impl IntoIterator) -> String { + let total_rows: usize = batches.into_iter().map(|b| b.num_rows()).sum(); + + if total_rows > 1 { + format!("{} rows", total_rows) + } else if total_rows == 0 { + "no rows".to_string() + } else { + "1 row".to_string() + } + } + fn use_database(&mut self, db_name: String) { info!(%db_name, "setting current database"); println!("You are now in remote mode, querying database {}", db_name); diff --git a/tests/end_to_end_cases/sql_cli.rs b/tests/end_to_end_cases/sql_cli.rs index b73245e74d..ec3fd287ef 100644 --- a/tests/end_to_end_cases/sql_cli.rs +++ b/tests/end_to_end_cases/sql_cli.rs @@ -125,7 +125,7 @@ async fn test_sql_use_database() { .write_stdin(format!("use {};\n\nselect * from cpu;", db_name)) .assert() .success() - .stdout(predicate::str::contains(expected_output)); + .stdout(predicate::str::contains(expected_output).and(predicate::str::contains("1 row"))); } #[tokio::test]