Skip to content

Commit e2f4657

Browse files
committed
test: handle empty join output in prepare_record_batches_for_cmp
The always-false column-free filter case makes the hash join oracle return no batches, so take the schema as a parameter instead of reading it from the first batch.
1 parent 378d525 commit e2f4657

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

  • datafusion/physical-plan/src/joins/sort_merge_join

‎datafusion/physical-plan/src/joins/sort_merge_join/tests.rs‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4881,8 +4881,11 @@ fn build_batched_finish_barrier_table(
48814881
}
48824882

48834883
/// Concat and sort batches by all the columns to make sure we can compare them with different join
4884-
fn prepare_record_batches_for_cmp(output: Vec<RecordBatch>) -> RecordBatch {
4885-
let output_batch = arrow::compute::concat_batches(output[0].schema_ref(), &output)
4884+
fn prepare_record_batches_for_cmp(
4885+
schema: &SchemaRef,
4886+
output: Vec<RecordBatch>,
4887+
) -> RecordBatch {
4888+
let output_batch = arrow::compute::concat_batches(schema, &output)
48864889
.expect("failed to concat batches");
48874890

48884891
// Sort on all columns to make sure we have a deterministic order for the assertion
@@ -4937,7 +4940,7 @@ async fn join_get_stream_and_get_expected(
49374940

49384941
let batches = common::collect(stream).await?;
49394942

4940-
prepare_record_batches_for_cmp(batches)
4943+
prepare_record_batches_for_cmp(&oracle.schema(), batches)
49414944
};
49424945

49434946
let join = SortMergeJoinExec::try_new(
@@ -5150,7 +5153,8 @@ async fn test_should_emit_early_when_have_enough_data_to_emit() -> Result<()> {
51505153
// Just sanity test to make sure we are still producing valid output
51515154
{
51525155
let output = [output_batched, output_batches_after_finish].concat();
5153-
let actual_prepared = prepare_record_batches_for_cmp(output);
5156+
let actual_prepared =
5157+
prepare_record_batches_for_cmp(&expected.schema(), output);
51545158

51555159
assert_eq!(actual_prepared.columns(), expected.columns());
51565160
}
@@ -8642,7 +8646,7 @@ async fn join_inner_early_filtering_matches_hash_join() -> Result<()> {
86428646
assert_eq!(expected.num_rows() > 0, keeps_pairs, "filter {filter}");
86438647
assert_streamed_order(&output);
86448648
assert_eq!(
8645-
prepare_record_batches_for_cmp(output),
8649+
prepare_record_batches_for_cmp(&expected.schema(), output),
86468650
expected,
86478651
"filter {filter} with batch_size {batch_size}"
86488652
);

0 commit comments

Comments
 (0)