From d9b160144b354224b1456c4529cf507aa4a8aba4 Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Thu, 12 Jan 2023 14:38:11 +0100 Subject: [PATCH] Update tests --- datafusion/core/tests/sql/explain_analyze.rs | 4 +- datafusion/core/tests/sql/window.rs | 42 ++++++++++---------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/datafusion/core/tests/sql/explain_analyze.rs b/datafusion/core/tests/sql/explain_analyze.rs index 0cc65abf08502..649a44cbc9f45 100644 --- a/datafusion/core/tests/sql/explain_analyze.rs +++ b/datafusion/core/tests/sql/explain_analyze.rs @@ -54,7 +54,7 @@ async fn explain_analyze_baseline_metrics() { assert_metrics!( &formatted, "AggregateExec: mode=Partial, gby=[]", - "metrics=[output_rows=3, elapsed_compute=" + "metrics=[output_rows=1, elapsed_compute=" ); assert_metrics!( &formatted, @@ -90,7 +90,7 @@ async fn explain_analyze_baseline_metrics() { assert_metrics!( &formatted, "CoalescePartitionsExec", - "metrics=[output_rows=3, elapsed_compute=" + "metrics=[output_rows=5, elapsed_compute=" ); assert_metrics!( &formatted, diff --git a/datafusion/core/tests/sql/window.rs b/datafusion/core/tests/sql/window.rs index 0a1c12f28a985..2f82329396557 100644 --- a/datafusion/core/tests/sql/window.rs +++ b/datafusion/core/tests/sql/window.rs @@ -2290,28 +2290,30 @@ async fn test_remove_unnecessary_sort_in_sub_query() -> Result<()> { let dataframe = ctx.sql(sql).await.expect(&msg); let physical_plan = dataframe.create_physical_plan().await?; let formatted = displayable(physical_plan.as_ref()).indent().to_string(); + // Unnecessary Sort in the sub query is removed - let expected = { - vec![ - "ProjectionExec: expr=[COUNT(UInt8(1))@0 as global_count]", - " AggregateExec: mode=Final, gby=[], aggr=[COUNT(UInt8(1))]", - " CoalescePartitionsExec", - " AggregateExec: mode=Partial, gby=[], aggr=[COUNT(UInt8(1))]", - " RepartitionExec: partitioning=RoundRobinBatch(8)", - " CoalescePartitionsExec", - " AggregateExec: mode=FinalPartitioned, gby=[c1@0 as c1], aggr=[COUNT(UInt8(1))]", - " CoalesceBatchesExec: target_batch_size=4096", - " RepartitionExec: partitioning=Hash([Column { name: \"c1\", index: 0 }], 8)", - " AggregateExec: mode=Partial, gby=[c1@0 as c1], aggr=[COUNT(UInt8(1))]", - " CoalesceBatchesExec: target_batch_size=4096", - " FilterExec: c13@1 != C2GT5KVyOPZpgKVl110TyZO0NcJ434", - " RepartitionExec: partitioning=RoundRobinBatch(8)", - ] - }; + let expected = vec![ + "ProjectionExec: expr=[COUNT(UInt8(1))@0 as global_count]", + " AggregateExec: mode=Final, gby=[], aggr=[COUNT(UInt8(1))]", + " AggregateExec: mode=Partial, gby=[], aggr=[COUNT(UInt8(1))]", + " CoalescePartitionsExec", + " AggregateExec: mode=FinalPartitioned, gby=[c1@0 as c1], aggr=[COUNT(UInt8(1))]", + " CoalesceBatchesExec: target_batch_size=4096", + " RepartitionExec: partitioning=Hash([Column { name: \"c1\", index: 0 }], 8)", + " AggregateExec: mode=Partial, gby=[c1@0 as c1], aggr=[COUNT(UInt8(1))]", + " CoalesceBatchesExec: target_batch_size=4096", + " FilterExec: c13@1 != C2GT5KVyOPZpgKVl110TyZO0NcJ434", + " RepartitionExec: partitioning=RoundRobinBatch(8)", + " CsvExec: files={1 group: [[ARROW_TEST_DATA/csv/aggregate_test_100.csv]]}, has_header=true, limit=None, projection=[c1, c13]", + ]; + + let normalizer = ExplainNormalizer::new(); + let actual: Vec<_> = formatted + .trim() + .lines() + .map(|s| normalizer.normalize(s)) + .collect(); - let actual: Vec<&str> = formatted.trim().lines().collect(); - let actual_len = actual.len(); - //let actual_trim_last = &actual[..actual_len - 1]; assert_eq!( expected, actual, "\n\nexpected:\n\n{expected:#?}\nactual:\n\n{actual:#?}\n\n"