Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed Jan 12, 2023
1 parent dfc22ee commit d9b1601
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
4 changes: 2 additions & 2 deletions datafusion/core/tests/sql/explain_analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
42 changes: 22 additions & 20 deletions datafusion/core/tests/sql/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit d9b1601

Please sign in to comment.