Skip to content

Commit 9e32de3

Browse files
authored
Pass booleans by value instead of by reference (#5487)
* Pass booleans by value instead of by reference * fix build error * Fix tests * clippy
1 parent deeaa56 commit 9e32de3

8 files changed

Lines changed: 41 additions & 39 deletions

File tree

‎datafusion/core/src/physical_optimizer/dist_enforcement.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ fn adjust_input_keys_ordering(
171171
filter.clone(),
172172
join_type,
173173
PartitionMode::Partitioned,
174-
null_equals_null,
174+
*null_equals_null,
175175
)?) as Arc<dyn ExecutionPlan>)
176176
};
177177
Ok(Some(reorder_partitioned_join_keys(
@@ -606,7 +606,7 @@ fn reorder_join_keys_to_inputs(
606606
filter.clone(),
607607
join_type,
608608
PartitionMode::Partitioned,
609-
null_equals_null,
609+
*null_equals_null,
610610
)?))
611611
} else {
612612
Ok(plan)
@@ -1086,7 +1086,7 @@ mod tests {
10861086
None,
10871087
join_type,
10881088
PartitionMode::Partitioned,
1089-
&false,
1089+
false,
10901090
)
10911091
.unwrap(),
10921092
)

‎datafusion/core/src/physical_optimizer/join_selection.rs‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ mod tests {
488488
None,
489489
&JoinType::Left,
490490
PartitionMode::CollectLeft,
491-
&false,
491+
false,
492492
)
493493
.unwrap();
494494

@@ -536,7 +536,7 @@ mod tests {
536536
None,
537537
&JoinType::Left,
538538
PartitionMode::CollectLeft,
539-
&false,
539+
false,
540540
)
541541
.unwrap();
542542

@@ -587,7 +587,7 @@ mod tests {
587587
None,
588588
&join_type,
589589
PartitionMode::Partitioned,
590-
&false,
590+
false,
591591
)
592592
.unwrap();
593593

@@ -652,7 +652,7 @@ mod tests {
652652
None,
653653
&JoinType::Inner,
654654
PartitionMode::CollectLeft,
655-
&false,
655+
false,
656656
)
657657
.unwrap();
658658
let child_schema = child_join.schema();
@@ -668,7 +668,7 @@ mod tests {
668668
None,
669669
&JoinType::Left,
670670
PartitionMode::CollectLeft,
671-
&false,
671+
false,
672672
)
673673
.unwrap();
674674

@@ -705,7 +705,7 @@ mod tests {
705705
None,
706706
&JoinType::Inner,
707707
PartitionMode::CollectLeft,
708-
&false,
708+
false,
709709
)
710710
.unwrap();
711711

@@ -930,7 +930,7 @@ mod tests {
930930
None,
931931
&JoinType::Inner,
932932
PartitionMode::Auto,
933-
&false,
933+
false,
934934
)
935935
.unwrap();
936936

‎datafusion/core/src/physical_optimizer/pipeline_fixer.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ mod hash_join_tests {
710710
None,
711711
&t.initial_join_type,
712712
t.initial_mode,
713-
&false,
713+
false,
714714
)?;
715715

716716
let initial_hash_join_state = PipelineStatePropagator {

‎datafusion/core/src/physical_plan/joins/hash_join.rs‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ impl HashJoinExec {
201201
filter: Option<JoinFilter>,
202202
join_type: &JoinType,
203203
partition_mode: PartitionMode,
204-
null_equals_null: &bool,
204+
null_equals_null: bool,
205205
) -> Result<Self> {
206206
let left_schema = left.schema();
207207
let right_schema = right.schema();
@@ -230,7 +230,7 @@ impl HashJoinExec {
230230
mode: partition_mode,
231231
metrics: ExecutionPlanMetricsSet::new(),
232232
column_indices,
233-
null_equals_null: *null_equals_null,
233+
null_equals_null,
234234
})
235235
}
236236

@@ -265,8 +265,8 @@ impl HashJoinExec {
265265
}
266266

267267
/// Get null_equals_null
268-
pub fn null_equals_null(&self) -> &bool {
269-
&self.null_equals_null
268+
pub fn null_equals_null(&self) -> bool {
269+
self.null_equals_null
270270
}
271271
}
272272

@@ -402,7 +402,7 @@ impl ExecutionPlan for HashJoinExec {
402402
self.filter.clone(),
403403
&self.join_type,
404404
self.mode,
405-
&self.null_equals_null,
405+
self.null_equals_null,
406406
)?))
407407
}
408408

@@ -691,7 +691,7 @@ pub fn build_join_indices(
691691
on_probe: &[Column],
692692
filter: Option<&JoinFilter>,
693693
random_state: &RandomState,
694-
null_equals_null: &bool,
694+
null_equals_null: bool,
695695
hashes_buffer: &mut Vec<u64>,
696696
offset: Option<usize>,
697697
build_side: JoinSide,
@@ -762,7 +762,7 @@ pub fn build_equal_condition_join_indices(
762762
build_on: &[Column],
763763
probe_on: &[Column],
764764
random_state: &RandomState,
765-
null_equals_null: &bool,
765+
null_equals_null: bool,
766766
hashes_buffer: &mut Vec<u64>,
767767
offset: Option<usize>,
768768
) -> Result<(UInt64Array, UInt32Array)> {
@@ -804,7 +804,7 @@ pub fn build_equal_condition_join_indices(
804804
row,
805805
&build_join_values,
806806
&keys_values,
807-
*null_equals_null,
807+
null_equals_null,
808808
)? {
809809
build_indices.append(offset_build_index as u64);
810810
probe_indices.append(row as u32);
@@ -1207,7 +1207,7 @@ impl HashJoinStream {
12071207
&self.on_right,
12081208
self.filter.as_ref(),
12091209
&self.random_state,
1210-
&self.null_equals_null,
1210+
self.null_equals_null,
12111211
&mut hashes_buffer,
12121212
None,
12131213
JoinSide::Left,
@@ -1356,7 +1356,7 @@ mod tests {
13561356
None,
13571357
join_type,
13581358
PartitionMode::CollectLeft,
1359-
&null_equals_null,
1359+
null_equals_null,
13601360
)
13611361
}
13621362

@@ -1375,7 +1375,7 @@ mod tests {
13751375
Some(filter),
13761376
join_type,
13771377
PartitionMode::CollectLeft,
1378-
&null_equals_null,
1378+
null_equals_null,
13791379
)
13801380
}
13811381

@@ -1429,7 +1429,7 @@ mod tests {
14291429
None,
14301430
join_type,
14311431
PartitionMode::Partitioned,
1432-
&null_equals_null,
1432+
null_equals_null,
14331433
)?;
14341434

14351435
let columns = columns(&join.schema());
@@ -2680,7 +2680,7 @@ mod tests {
26802680
&[Column::new("a", 0)],
26812681
&[Column::new("a", 0)],
26822682
&random_state,
2683-
&false,
2683+
false,
26842684
&mut vec![0; right.num_rows()],
26852685
None,
26862686
)?;

‎datafusion/core/src/physical_plan/joins/symmetric_hash_join.rs‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ impl SymmetricHashJoinExec {
249249
on: JoinOn,
250250
filter: JoinFilter,
251251
join_type: &JoinType,
252-
null_equals_null: &bool,
252+
null_equals_null: bool,
253253
) -> Result<Self> {
254254
let left_schema = left.schema();
255255
let right_schema = right.schema();
@@ -349,7 +349,7 @@ impl SymmetricHashJoinExec {
349349
random_state,
350350
metrics: ExecutionPlanMetricsSet::new(),
351351
column_indices,
352-
null_equals_null: *null_equals_null,
352+
null_equals_null,
353353
})
354354
}
355355

@@ -379,8 +379,8 @@ impl SymmetricHashJoinExec {
379379
}
380380

381381
/// Get null_equals_null
382-
pub fn null_equals_null(&self) -> &bool {
383-
&self.null_equals_null
382+
pub fn null_equals_null(&self) -> bool {
383+
self.null_equals_null
384384
}
385385
}
386386

@@ -472,7 +472,7 @@ impl ExecutionPlan for SymmetricHashJoinExec {
472472
self.on.clone(),
473473
self.filter.clone(),
474474
&self.join_type,
475-
&self.null_equals_null,
475+
self.null_equals_null,
476476
)?))
477477
}
478478

@@ -1054,7 +1054,7 @@ impl OneSideHashJoiner {
10541054
probe_offset: usize,
10551055
column_indices: &[ColumnIndex],
10561056
random_state: &RandomState,
1057-
null_equals_null: &bool,
1057+
null_equals_null: bool,
10581058
) -> Result<Option<RecordBatch>> {
10591059
if self.input_buffer.num_rows() == 0 || probe_batch.num_rows() == 0 {
10601060
return Ok(Some(RecordBatch::new_empty(schema.clone())));
@@ -1371,7 +1371,7 @@ impl SymmetricHashJoinStream {
13711371
probe_hash_joiner.offset,
13721372
&self.column_indices,
13731373
&self.random_state,
1374-
&self.null_equals_null,
1374+
self.null_equals_null,
13751375
)?;
13761376
// Increment the offset for the probe hash joiner:
13771377
probe_hash_joiner.offset += probe_batch.num_rows();
@@ -1504,7 +1504,7 @@ mod tests {
15041504
on,
15051505
filter,
15061506
join_type,
1507-
&null_equals_null,
1507+
null_equals_null,
15081508
)?;
15091509

15101510
let mut batches = vec![];
@@ -1551,7 +1551,7 @@ mod tests {
15511551
Some(filter),
15521552
join_type,
15531553
PartitionMode::Partitioned,
1554-
&null_equals_null,
1554+
null_equals_null,
15551555
)?;
15561556

15571557
let mut batches = vec![];
@@ -2465,7 +2465,7 @@ mod tests {
24652465
right_side_joiner.offset,
24662466
&join_column_indices,
24672467
&random_state,
2468-
&false,
2468+
false,
24692469
)?;
24702470
assert_eq!(left_side_joiner.visited_rows.is_empty(), should_be_empty);
24712471
Ok(())

‎datafusion/core/src/physical_plan/planner.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,8 @@ impl DefaultPhysicalPlanner {
860860
schema: join_schema,
861861
..
862862
}) => {
863+
let null_equals_null = *null_equals_null;
864+
863865
// If join has expression equijoin keys, add physical projecton.
864866
let has_expr_join_key = keys.iter().any(|(l, r)| {
865867
!(matches!(l, Expr::Column(_))
@@ -1030,7 +1032,7 @@ impl DefaultPhysicalPlanner {
10301032
join_on,
10311033
*join_type,
10321034
vec![SortOptions::default(); join_on_len],
1033-
*null_equals_null,
1035+
null_equals_null,
10341036
)?))
10351037
}
10361038
} else if session_state.config().target_partitions() > 1

‎datafusion/core/tests/join_fuzz.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ async fn run_join_test(
153153
None,
154154
&join_type,
155155
PartitionMode::Partitioned,
156-
&false,
156+
false,
157157
)
158158
.unwrap(),
159159
);

‎datafusion/proto/src/physical_plan/mod.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ impl AsExecutionPlan for PhysicalPlanNode {
536536
filter,
537537
&join_type.into(),
538538
partition_mode,
539-
&hashjoin.null_equals_null,
539+
hashjoin.null_equals_null,
540540
)?))
541541
}
542542
PhysicalPlanType::Union(union) => {
@@ -827,7 +827,7 @@ impl AsExecutionPlan for PhysicalPlanNode {
827827
on,
828828
join_type: join_type.into(),
829829
partition_mode: partition_mode.into(),
830-
null_equals_null: *exec.null_equals_null(),
830+
null_equals_null: exec.null_equals_null(),
831831
filter,
832832
},
833833
))),
@@ -1367,7 +1367,7 @@ mod roundtrip_tests {
13671367
None,
13681368
join_type,
13691369
*partition_mode,
1370-
&false,
1370+
false,
13711371
)?))?;
13721372
}
13731373
}

0 commit comments

Comments
 (0)