Skip to content

Commit 4ae0b04

Browse files
committed
test: trim hash join build order tests
Drop the new inner duplicate-key test, which passes with or without the fix, and run join_inner_one_two_parts_left_randomly_ordered over the hash map and array map configs instead. Drop the prepared build test: prepared_build_matches_collect_left already covers multi-batch hash map builds. Reword the LeftAnti test doc so it does not read as an ordering guarantee.
1 parent 702f761 commit 4ae0b04

2 files changed

Lines changed: 10 additions & 115 deletions

File tree

‎datafusion/physical-plan/src/joins/hash_join/exec.rs‎

Lines changed: 10 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -4814,9 +4814,13 @@ mod tests {
48144814
Ok(())
48154815
}
48164816

4817+
#[apply(hash_join_exec_configs)]
48174818
#[tokio::test]
4818-
async fn join_inner_one_two_parts_left_randomly_ordered() -> Result<()> {
4819-
let task_ctx = Arc::new(TaskContext::default());
4819+
async fn join_inner_one_two_parts_left_randomly_ordered(
4820+
batch_size: usize,
4821+
use_perfect_hash_join_as_possible: bool,
4822+
) -> Result<()> {
4823+
let task_ctx = prepare_task_ctx(batch_size, use_perfect_hash_join_as_possible);
48204824
let batch1 = build_table_i32(
48214825
("a1", &vec![0, 3]),
48224826
("b1", &vec![4, 5]),
@@ -4870,6 +4874,7 @@ mod tests {
48704874
}
48714875

48724876
assert_join_metrics!(metrics, 4);
4877+
assert_phj_used(&metrics, use_perfect_hash_join_as_possible);
48734878

48744879
Ok(())
48754880
}
@@ -4998,8 +5003,9 @@ mod tests {
49985003
TestMemoryExec::try_new_exec(&[vec![batch.clone(), batch]], schema, None).unwrap()
49995004
}
50005005

5001-
/// Unmatched build rows of a `LeftAnti` join are emitted in build index
5002-
/// order, so the concatenated build batch must keep the input batch order.
5006+
/// The hash map and array map paths must emit unmatched build rows of a
5007+
/// `LeftAnti` join in the same order. Build order is not a plan-level
5008+
/// guarantee (see #26235).
50035009
#[apply(hash_join_exec_configs)]
50045010
#[tokio::test]
50055011
async fn join_left_anti_keeps_build_order_across_batches(
@@ -5054,67 +5060,6 @@ mod tests {
50545060
Ok(())
50555061
}
50565062

5057-
/// Build rows sharing a key across build batches are matched in build
5058-
/// order, which relies on the hash map chains putting smaller build
5059-
/// indices first.
5060-
#[apply(hash_join_exec_configs)]
5061-
#[tokio::test]
5062-
async fn join_inner_keeps_build_order_for_duplicate_keys_across_batches(
5063-
batch_size: usize,
5064-
use_perfect_hash_join_as_possible: bool,
5065-
) -> Result<()> {
5066-
let task_ctx = prepare_task_ctx(batch_size, use_perfect_hash_join_as_possible);
5067-
let batch1 = build_table_i32(
5068-
("a1", &vec![1, 2]),
5069-
("b1", &vec![5, 6]),
5070-
("c1", &vec![7, 8]),
5071-
);
5072-
let batch2 = build_table_i32(
5073-
("a1", &vec![3, 4]),
5074-
("b1", &vec![5, 6]),
5075-
("c1", &vec![9, 10]),
5076-
);
5077-
let schema = batch1.schema();
5078-
let left =
5079-
TestMemoryExec::try_new_exec(&[vec![batch1, batch2]], schema, None).unwrap();
5080-
let right = build_table(
5081-
("a2", &vec![10, 20]),
5082-
("b1", &vec![5, 6]),
5083-
("c2", &vec![70, 80]),
5084-
);
5085-
let on = vec![(
5086-
Arc::new(Column::new_with_schema("b1", &left.schema())?) as _,
5087-
Arc::new(Column::new_with_schema("b1", &right.schema())?) as _,
5088-
)];
5089-
5090-
let (columns, batches, metrics) = join_collect(
5091-
left,
5092-
right,
5093-
on,
5094-
&JoinType::Inner,
5095-
NullEquality::NullEqualsNothing,
5096-
task_ctx,
5097-
)
5098-
.await?;
5099-
5100-
assert_eq!(columns, vec!["a1", "b1", "c1", "a2", "b1", "c2"]);
5101-
allow_duplicates! {
5102-
assert_snapshot!(batches_to_string(&batches), @r"
5103-
+----+----+----+----+----+----+
5104-
| a1 | b1 | c1 | a2 | b1 | c2 |
5105-
+----+----+----+----+----+----+
5106-
| 1 | 5 | 7 | 10 | 5 | 70 |
5107-
| 3 | 5 | 9 | 10 | 5 | 70 |
5108-
| 2 | 6 | 8 | 20 | 6 | 80 |
5109-
| 4 | 6 | 10 | 20 | 6 | 80 |
5110-
+----+----+----+----+----+----+
5111-
");
5112-
}
5113-
assert_phj_used(&metrics, use_perfect_hash_join_as_possible);
5114-
5115-
Ok(())
5116-
}
5117-
51185063
/// `probe_hit_rate` and `avg_fanout` must count each probe row once, even
51195064
/// when a probe batch is processed in several chunks. Every probe row matches
51205065
/// all 3 build rows, so any `batch_size` below 9 splits the probe batch into

‎datafusion/physical-plan/src/joins/hash_join/exec/prepared/tests.rs‎

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -689,56 +689,6 @@ async fn prepared_build_matches_collect_left() -> Result<()> {
689689
Ok(())
690690
}
691691

692-
/// A prepared hash-map build keeps its rows in input batch order, and each
693-
/// hash-map index still points at the row with its key.
694-
#[tokio::test]
695-
async fn prepared_build_keeps_build_order_across_batches() -> Result<()> {
696-
let batches = vec![
697-
batch(vec![Some(10), Some(20)]),
698-
batch(vec![Some(3000), Some(4000)]),
699-
];
700-
let base = join(batches[0].schema(), batch(vec![Some(20), Some(3000)]))?;
701-
// Never pick the array map, so the hash-map build path is exercised.
702-
let mut config = ConfigOptions::default();
703-
config.execution.perfect_hash_join_small_build_threshold = 0;
704-
config.execution.perfect_hash_join_min_key_density = f64::INFINITY;
705-
let prepared = base
706-
.prepare_build(
707-
input(batches.clone(), batches[0].schema()),
708-
Arc::new(GreedyMemoryPool::new(1 << 20)),
709-
Arc::new(config),
710-
)
711-
.await?;
712-
assert!(matches!(prepared.build.map.as_ref(), Map::HashMap(_)));
713-
assert_batches_eq!(
714-
[
715-
"+------+---------+",
716-
"| key | payload |",
717-
"+------+---------+",
718-
"| 10 | 10 |",
719-
"| 20 | 11 |",
720-
"| 3000 | 10 |",
721-
"| 4000 | 11 |",
722-
"+------+---------+",
723-
],
724-
std::slice::from_ref(&prepared.build.batch)
725-
);
726-
727-
let task = base.builder().with_prepared_build(prepared).build()?;
728-
assert_batches_eq!(
729-
[
730-
"+------+---------+------+---------+",
731-
"| key | payload | key | payload |",
732-
"+------+---------+------+---------+",
733-
"| 20 | 11 | 20 | 10 |",
734-
"| 3000 | 10 | 3000 | 11 |",
735-
"+------+---------+------+---------+",
736-
],
737-
&run(&task).await?
738-
);
739-
Ok(())
740-
}
741-
742692
#[tokio::test]
743693
async fn prepared_concat_admission_with_small_batches() -> Result<()> {
744694
let rows = 65_536;

0 commit comments

Comments
 (0)