Skip to content

Commit d93b83d

Browse files
Write metrics to file
1 parent f8a440f commit d93b83d

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/cli/mod.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -592,10 +592,19 @@ impl CliApp {
592592
.analyze_query_raw(sql)
593593
.await?;
594594

595-
println!("==================== Query ====================");
596-
println!("{}", query_str);
597-
println!("\n==================== Metrics ====================");
598-
self.print_batch(&metrics_batch)?;
595+
if let Some(output_path) = &self.args.output {
596+
// Write metrics batch to file
597+
let schema = metrics_batch.schema();
598+
let mut writer = path_to_writer(output_path, schema)?;
599+
writer.write(&metrics_batch)?;
600+
writer.close().await?;
601+
} else {
602+
// Print to stdout
603+
println!("==================== Query ====================");
604+
println!("{}", query_str);
605+
println!("\n==================== Metrics ====================");
606+
self.print_batch(&metrics_batch)?;
607+
}
599608
} else {
600609
// Normal mode: reconstruct and display ExecutionStats
601610
let stats = self

0 commit comments

Comments
 (0)