Chen-Yuan-Lai commented on code in PR #16324:
URL: https://github.com/apache/datafusion/pull/16324#discussion_r2143152053
##########
datafusion/core/tests/sql/explain_analyze.rs:
##########
@@ -52,43 +54,45 @@ async fn explain_analyze_baseline_metrics() {
let formatted = arrow::util::pretty::pretty_format_batches(&results)
.unwrap()
.to_string();
+
println!("Query Output:\n\n{formatted}");
- assert_metrics!(
- &formatted,
- "AggregateExec: mode=Partial, gby=[]",
- "metrics=[output_rows=3, elapsed_compute="
- );
- assert_metrics!(
- &formatted,
- "AggregateExec: mode=FinalPartitioned, gby=[c1@0 as c1]",
- "metrics=[output_rows=5, elapsed_compute="
- );
- assert_metrics!(
- &formatted,
- "FilterExec: c13@1 != C2GT5KVyOPZpgKVl110TyZO0NcJ434",
- "metrics=[output_rows=99, elapsed_compute="
- );
- assert_metrics!(
- &formatted,
- "ProjectionExec: expr=[]",
- "metrics=[output_rows=5, elapsed_compute="
- );
- assert_metrics!(
- &formatted,
- "CoalesceBatchesExec: target_batch_size=4096",
- "metrics=[output_rows=5, elapsed_compute"
- );
- assert_metrics!(
- &formatted,
- "UnionExec",
- "metrics=[output_rows=3, elapsed_compute="
- );
- assert_metrics!(
- &formatted,
- "WindowAggExec",
- "metrics=[output_rows=1, elapsed_compute="
- );
+ let re = Regex::new(r"\|[^|]*\|([^|]*)\|").unwrap();
+ let actual = formatted
+ .lines()
+ .map(|line| re.replace_all(line, "$1").trim_end().to_string())
+ .filter(|line| !line.is_empty() && !line.starts_with('+'))
+ .collect::<Vec<_>>()
+ .join("\n");
+ insta::with_settings!({filters => vec![
+ (r"\d+\.?\d*[µmn]?s", "[TIME]"),
Review Comment:
> you can probably use lookahead
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookahead_assertion
Unfortunately, Rust's regex crate does not support lookahead or lookbehind
assertions 😢 ( [ref](https://github.com/rust-lang/regex/issues/127) )
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]