MCPcopy Create free account
hub / github.com/apache/datafusion / partition_aware_union

Function partition_aware_union

datafusion/core/tests/dataframe/mod.rs:2470–2509  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2468
2469#[tokio::test]
2470async 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]
2512async fn non_partition_aware_union() -> Result<()> {

Callers

nothing calls this directly

Calls 12

test_tableFunction · 0.85
test_table_with_nameFunction · 0.85
newFunction · 0.85
select_columnsMethod · 0.80
with_column_renamedMethod · 0.80
collectMethod · 0.80
target_partitionsMethod · 0.80
cloneMethod · 0.45
joinMethod · 0.45
unionMethod · 0.45
create_physical_planMethod · 0.45
childrenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…