|
18 | 18 | use std::sync::Arc; |
19 | 19 |
|
20 | 20 | use crate::physical_optimizer::enforce_distribution::projection_exec_with_alias; |
21 | | -use crate::physical_optimizer::sanity_checker::{ |
22 | | - assert_sanity_check, assert_sanity_check_err, |
23 | | -}; |
| 21 | +use crate::physical_optimizer::sanity_checker::assert_sanity_check; |
24 | 22 | use crate::physical_optimizer::test_utils::{ |
25 | 23 | aggregate_exec, bounded_window_exec, bounded_window_exec_non_set_monotonic, |
26 | 24 | bounded_window_exec_with_partition, check_integrity, coalesce_batches_exec, |
@@ -2307,40 +2305,27 @@ async fn test_preserve_needed_coalesce() -> Result<()> { |
2307 | 2305 | let plan = sort_exec(sort_key, plan); |
2308 | 2306 |
|
2309 | 2307 | // Starting plan: as in our test case. |
2310 | | - assert_eq!( |
2311 | | - get_plan_string(&plan), |
2312 | | - vec![ |
2313 | | - "SortExec: expr=[a@0 ASC], preserve_partitioning=[false]", |
2314 | | - " AggregateExec: mode=SinglePartitioned, gby=[a@0 as a1], aggr=[]", |
2315 | | - " CoalescePartitionsExec", |
2316 | | - " ProjectionExec: expr=[a@0 as a, b@1 as value]", |
2317 | | - " UnionExec", |
2318 | | - " DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet", |
2319 | | - " DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet", |
2320 | | - ], |
2321 | | - ); |
| 2308 | + let starting_plan = vec![ |
| 2309 | + "SortExec: expr=[a@0 ASC], preserve_partitioning=[false]", |
| 2310 | + " AggregateExec: mode=SinglePartitioned, gby=[a@0 as a1], aggr=[]", |
| 2311 | + " CoalescePartitionsExec", |
| 2312 | + " ProjectionExec: expr=[a@0 as a, b@1 as value]", |
| 2313 | + " UnionExec", |
| 2314 | + " DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet", |
| 2315 | + " DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet", |
| 2316 | + ]; |
| 2317 | + assert_eq!(get_plan_string(&plan), starting_plan); |
| 2318 | + |
2322 | 2319 | // Test: plan is valid. |
2323 | 2320 | assert_sanity_check(&plan, true); |
2324 | 2321 |
|
2325 | | - // EnforceSorting will remove the coalesce, and add an SPM further up (above the aggregate). |
| 2322 | + // EnforceSorting will not remove the coalesce, as it's required. |
2326 | 2323 | let optimizer = EnforceSorting::new(); |
2327 | 2324 | let optimized = optimizer.optimize(plan, &Default::default())?; |
2328 | | - assert_eq!( |
2329 | | - get_plan_string(&optimized), |
2330 | | - vec![ |
2331 | | - "SortPreservingMergeExec: [a@0 ASC]", |
2332 | | - " SortExec: expr=[a@0 ASC], preserve_partitioning=[true]", |
2333 | | - " AggregateExec: mode=SinglePartitioned, gby=[a@0 as a1], aggr=[]", |
2334 | | - " ProjectionExec: expr=[a@0 as a, b@1 as value]", |
2335 | | - " UnionExec", |
2336 | | - " DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet", |
2337 | | - " DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet", |
2338 | | - ], |
2339 | | - ); |
| 2325 | + assert_eq!(get_plan_string(&optimized), starting_plan); |
2340 | 2326 |
|
2341 | | - // Bug: Plan is now invalid. |
2342 | | - let err = "does not satisfy distribution requirements: HashPartitioned[[a@0]]). Child-0 output partitioning: UnknownPartitioning(2)"; |
2343 | | - assert_sanity_check_err(&optimized, err); |
| 2327 | + // Test: plan is valid. |
| 2328 | + assert_sanity_check(&optimized, true); |
2344 | 2329 |
|
2345 | 2330 | Ok(()) |
2346 | 2331 | } |
0 commit comments