Skip to content

Commit 8e3f157

Browse files
authored
chore: enforce clippy lint needless_pass_by_value to datafusion-physical-optimizer (#18555)
## Which issue does this PR close? - Closes #18547. ## What changes are included in this PR? enforce clippy lint `needless_pass_by_value` to `datafusion-physical-optimizer` ## Are these changes tested? yes ## Are there any user-facing changes? no
1 parent c728d54 commit 8e3f157

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

datafusion/physical-optimizer/src/enforce_sorting/sort_pushdown.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ fn pushdown_requirement_to_children(
383383
} else if let Some(hash_join) = plan.as_any().downcast_ref::<HashJoinExec>() {
384384
handle_hash_join(hash_join, parent_required)
385385
} else {
386-
handle_custom_pushdown(plan, parent_required, maintains_input_order)
386+
handle_custom_pushdown(plan, parent_required, &maintains_input_order)
387387
}
388388
// TODO: Add support for Projection push down
389389
}
@@ -604,7 +604,7 @@ fn expr_source_side(
604604
fn handle_custom_pushdown(
605605
plan: &Arc<dyn ExecutionPlan>,
606606
parent_required: OrderingRequirements,
607-
maintains_input_order: Vec<bool>,
607+
maintains_input_order: &[bool],
608608
) -> Result<Option<Vec<Option<OrderingRequirements>>>> {
609609
// If the plan has no children, return early:
610610
if plan.children().is_empty() {

datafusion/physical-optimizer/src/filter_pushdown.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ impl PhysicalOptimizerRule for FilterPushdown {
422422
config: &ConfigOptions,
423423
) -> Result<Arc<dyn ExecutionPlan>> {
424424
Ok(
425-
push_down_filters(Arc::clone(&plan), vec![], config, self.phase)?
425+
push_down_filters(&Arc::clone(&plan), vec![], config, self.phase)?
426426
.updated_node
427427
.unwrap_or(plan),
428428
)
@@ -438,7 +438,7 @@ impl PhysicalOptimizerRule for FilterPushdown {
438438
}
439439

440440
fn push_down_filters(
441-
node: Arc<dyn ExecutionPlan>,
441+
node: &Arc<dyn ExecutionPlan>,
442442
parent_predicates: Vec<Arc<dyn PhysicalExpr>>,
443443
config: &ConfigOptions,
444444
phase: FilterPushdownPhase,
@@ -510,7 +510,8 @@ fn push_down_filters(
510510
let num_parent_filters = all_predicates.len() - num_self_filters;
511511

512512
// Any filters that could not be pushed down to a child are marked as not-supported to our parents
513-
let result = push_down_filters(Arc::clone(child), all_predicates, config, phase)?;
513+
let result =
514+
push_down_filters(&Arc::clone(child), all_predicates, config, phase)?;
514515

515516
if let Some(new_child) = result.updated_node {
516517
// If we have a filter pushdown result, we need to update our children
@@ -571,7 +572,7 @@ fn push_down_filters(
571572
}
572573

573574
// Re-create this node with new children
574-
let updated_node = with_new_children_if_necessary(Arc::clone(&node), new_children)?;
575+
let updated_node = with_new_children_if_necessary(Arc::clone(node), new_children)?;
575576

576577
// TODO: by calling `handle_child_pushdown_result` we are assuming that the
577578
// `ExecutionPlan` implementation will not change the plan itself.
@@ -596,7 +597,7 @@ fn push_down_filters(
596597
)?;
597598
// Compare pointers for new_node and node, if they are different we must replace
598599
// ourselves because of changes in our children.
599-
if res.updated_node.is_none() && !Arc::ptr_eq(&updated_node, &node) {
600+
if res.updated_node.is_none() && !Arc::ptr_eq(&updated_node, node) {
600601
res.updated_node = Some(updated_node)
601602
}
602603
Ok(res)

datafusion/physical-optimizer/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
// Make sure fast / cheap clones on Arc are explicit:
2424
// https://github.com/apache/datafusion/issues/11143
2525
#![deny(clippy::clone_on_ref_ptr)]
26+
// https://github.com/apache/datafusion/issues/18503
27+
#![deny(clippy::needless_pass_by_value)]
28+
#![cfg_attr(test, allow(clippy::needless_pass_by_value))]
2629

2730
pub mod aggregate_statistics;
2831
pub mod coalesce_async_exec_input;

datafusion/physical-optimizer/src/projection_pushdown.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ fn try_push_down_join_filter(
129129

130130
let join_filter = minimize_join_filter(
131131
Arc::clone(rhs_rewrite.data.1.expression()),
132-
rhs_rewrite.data.1.column_indices().to_vec(),
132+
rhs_rewrite.data.1.column_indices(),
133133
lhs_rewrite.data.0.schema().as_ref(),
134134
rhs_rewrite.data.0.schema().as_ref(),
135135
);
@@ -238,7 +238,7 @@ fn try_push_down_projection(
238238
/// columns are not needed anymore.
239239
fn minimize_join_filter(
240240
expr: Arc<dyn PhysicalExpr>,
241-
old_column_indices: Vec<ColumnIndex>,
241+
old_column_indices: &[ColumnIndex],
242242
lhs_schema: &Schema,
243243
rhs_schema: &Schema,
244244
) -> JoinFilter {

0 commit comments

Comments
 (0)