Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions datafusion-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,16 @@ pub struct PrintOptions {

fn print_timing_info(row_count: usize, now: Instant) {
println!(
"{} {} in set. Query took {} seconds.",
"{} {} in set. Query took {:.3} seconds.",
row_count,
if row_count == 1 { "row" } else { "rows" },
now.elapsed().as_secs()
now.elapsed().as_secs_f64()
);
}

impl PrintOptions {
/// print the batches to stdout using the specified format
pub fn print_batches(&self, batches: &[RecordBatch]) -> Result<()> {
let now = Instant::now();
pub fn print_batches(&self, batches: &[RecordBatch], now: Instant) -> Result<()> {
if batches.is_empty() {
if !self.quiet {
print_timing_info(0, now);
Expand Down
5 changes: 4 additions & 1 deletion datafusion-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::path::Path;
use std::time::Instant;

#[tokio::main]
pub async fn main() {
Expand Down Expand Up @@ -238,7 +239,9 @@ async fn exec_and_print(
sql: String,
) -> Result<()> {
let df = ctx.sql(&sql)?;
let now = Instant::now();
let results = df.collect().await?;
print_options.print_batches(&results)?;

print_options.print_batches(&results, now)?;
Ok(())
}