()
| 2468 | |
| 2469 | #[tokio::test] |
| 2470 | async fn partition_aware_union() -> Result<()> { |
| 2471 | let left = test_table().await?.select_columns(&["c1", "c2"])?; |
| 2472 | let right = test_table_with_name("c2") |
| 2473 | .await? |
| 2474 | .select_columns(&["c1", "c3"])? |
| 2475 | .with_column_renamed("c2.c1", "c2_c1")?; |
| 2476 | |
| 2477 | let left_rows = left.clone().collect().await?; |
| 2478 | let right_rows = right.clone().collect().await?; |
| 2479 | let join1 = |
| 2480 | left.clone() |
| 2481 | .join(right.clone(), JoinType::Inner, &["c1"], &["c2_c1"], None)?; |
| 2482 | let join2 = left.join(right, JoinType::Inner, &["c1"], &["c2_c1"], None)?; |
| 2483 | |
| 2484 | let union = join1.union(join2)?; |
| 2485 | |
| 2486 | let union_rows = union.clone().collect().await?; |
| 2487 | |
| 2488 | assert_eq!(100, left_rows.iter().map(|x| x.num_rows()).sum::<usize>()); |
| 2489 | assert_eq!(100, right_rows.iter().map(|x| x.num_rows()).sum::<usize>()); |
| 2490 | assert_eq!(4016, union_rows.iter().map(|x| x.num_rows()).sum::<usize>()); |
| 2491 | |
| 2492 | let physical_plan = union.create_physical_plan().await?; |
| 2493 | let default_partition_count = SessionConfig::new().target_partitions(); |
| 2494 | |
| 2495 | // For partition aware union, the output partition count should not be changed. |
| 2496 | assert_eq!( |
| 2497 | physical_plan.output_partitioning().partition_count(), |
| 2498 | default_partition_count |
| 2499 | ); |
| 2500 | // For partition aware union, the output partition is the same with the union's inputs |
| 2501 | for child in physical_plan.children() { |
| 2502 | assert_eq!( |
| 2503 | physical_plan.output_partitioning(), |
| 2504 | child.output_partitioning() |
| 2505 | ); |
| 2506 | } |
| 2507 | |
| 2508 | Ok(()) |
| 2509 | } |
| 2510 | |
| 2511 | #[tokio::test] |
| 2512 | async fn non_partition_aware_union() -> Result<()> { |
nothing calls this directly
no test coverage detected
searching dependent graphs…