Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor: add a hint how to adjust max rows displayed #9845

Merged
merged 1 commit into from
Mar 29, 2024
Merged
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
24 changes: 14 additions & 10 deletions datafusion-cli/src/print_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,22 @@ pub struct PrintOptions {
pub color: bool,
}

fn get_timing_info_str(
// Returns the query execution details formatted
fn get_execution_details_formatted(
row_count: usize,
maxrows: MaxRows,
query_start_time: Instant,
) -> String {
let row_word = if row_count == 1 { "row" } else { "rows" };
let nrows_shown_msg = match maxrows {
MaxRows::Limited(nrows) if nrows < row_count => format!(" ({} shown)", nrows),
MaxRows::Limited(nrows) if nrows < row_count => {
format!("(First {nrows} displayed. Use --maxrows to adjust)")
}
_ => String::new(),
};

format!(
"{} {} in set{}. Query took {:.3} seconds.\n",
"{} row(s) fetched. {}\nElapsed {:.3} seconds.\n",
row_count,
row_word,
nrows_shown_msg,
query_start_time.elapsed().as_secs_f64()
)
Expand All @@ -107,7 +108,7 @@ impl PrintOptions {
.print_batches(&mut writer, batches, self.maxrows, true)?;

let row_count: usize = batches.iter().map(|b| b.num_rows()).sum();
let timing_info = get_timing_info_str(
let formatted_exec_details = get_execution_details_formatted(
row_count,
if self.format == PrintFormat::Table {
self.maxrows
Expand All @@ -118,7 +119,7 @@ impl PrintOptions {
);

if !self.quiet {
writeln!(writer, "{timing_info}")?;
writeln!(writer, "{formatted_exec_details}")?;
}

Ok(())
Expand Down Expand Up @@ -154,11 +155,14 @@ impl PrintOptions {
with_header = false;
}

let timing_info =
get_timing_info_str(row_count, MaxRows::Unlimited, query_start_time);
let formatted_exec_details = get_execution_details_formatted(
row_count,
MaxRows::Unlimited,
query_start_time,
);

if !self.quiet {
writeln!(writer, "{timing_info}")?;
writeln!(writer, "{formatted_exec_details}")?;
}

Ok(())
Expand Down
Loading