Skip to content

Commit

Permalink
fix: report time display for DDL commands (#2681)
Browse files Browse the repository at this point in the history
Resolves: #2549 

This shows time elapsed where it matters, For commands like COPY,
INSERT, DELETE and UPDATE.

Please suggest changes if any.
Thanks

Co-authored-by: universalmind303 <cory.grinstead@gmail.com>
  • Loading branch information
hemanth94 and universalmind303 authored Feb 22, 2024
1 parent f7206bd commit c96077e
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions crates/glaredb/src/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,17 @@ impl LocalSession {
)
.await?
}
other => println!("{}", other),
res @ (ExecutionResult::CopySuccess
| ExecutionResult::DeleteSuccess { .. }
| ExecutionResult::InsertSuccess { .. }
| ExecutionResult::UpdateSuccess { .. }) => {
println!("{}", res);
print_time_elapsed(now);
}

other => {
println!("{}", other);
}
}
}
Ok(())
Expand Down Expand Up @@ -346,12 +356,15 @@ async fn print_stream(
OutputMode::Json => write_json::<JsonArrayNewLines>(&batches)?,
OutputMode::Ndjson => write_json::<JsonLineDelimted>(&batches)?,
}
print_time_elapsed(maybe_now);

Ok(())
}

pub(crate) fn print_time_elapsed(maybe_now: Option<Instant>) {
if let Some(now) = maybe_now {
println!("Time: {:.3}s", now.elapsed().as_secs_f64())
println!("Time: {:.3}s", now.elapsed().as_secs_f64());
}

Ok(())
}

pub(crate) fn is_client_cmd(s: &str) -> bool {
Expand Down

0 comments on commit c96077e

Please sign in to comment.