Skip to content

Commit 09ff8f7

Browse files
committed
fix clippy
1 parent 0bb16fa commit 09ff8f7

29 files changed

+77
-83
lines changed

datafusion/datasource/src/sink.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,14 @@ impl ExecutionPlan for DataSinkExec {
251251

252252
fn with_node_id(
253253
self: Arc<Self>,
254-
_node_id: usize,
254+
node_id: usize,
255255
) -> Result<Option<Arc<dyn ExecutionPlan>>> {
256256
let mut new_plan = DataSinkExec::new(
257257
Arc::clone(self.input()),
258258
Arc::clone(&self.sink),
259259
self.sort_order.clone(),
260260
);
261-
let new_props = new_plan.cache.clone().with_node_id(_node_id);
261+
let new_props = new_plan.cache.clone().with_node_id(node_id);
262262
new_plan.cache = new_props;
263263
Ok(Some(Arc::new(new_plan)))
264264
}

datafusion/datasource/src/source.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,10 @@ impl ExecutionPlan for DataSourceExec {
308308

309309
fn with_node_id(
310310
self: Arc<Self>,
311-
_node_id: usize,
311+
node_id: usize,
312312
) -> Result<Option<Arc<dyn ExecutionPlan>>> {
313-
let mut new_plan = DataSourceExec::new(self.data_source.clone());
314-
let new_props = new_plan.cache.clone().with_node_id(_node_id);
313+
let mut new_plan = DataSourceExec::new(Arc::clone(&self.data_source));
314+
let new_props = new_plan.cache.clone().with_node_id(node_id);
315315
new_plan.cache = new_props;
316316
Ok(Some(Arc::new(new_plan)))
317317
}

datafusion/expr/src/expr.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,10 +1885,7 @@ impl Expr {
18851885

18861886
/// Check if the Expr is literal
18871887
pub fn is_literal(&self) -> bool {
1888-
match self {
1889-
Expr::Literal(_, _) => true,
1890-
_ => false,
1891-
}
1888+
matches!(self, Expr::Literal(_, _))
18921889
}
18931890
}
18941891

datafusion/optimizer/src/simplify_predicates.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ pub(crate) fn simplify_predicates(predicates: Vec<Expr>) -> Result<Vec<Expr>> {
3131

3232
for pred in predicates {
3333
match &pred {
34-
Expr::BinaryExpr(BinaryExpr { left, op, right })
35-
if matches!(
36-
op,
34+
Expr::BinaryExpr(BinaryExpr {
35+
left,
36+
op:
3737
Operator::Gt
38-
| Operator::GtEq
39-
| Operator::Lt
40-
| Operator::LtEq
41-
| Operator::Eq
42-
) =>
43-
{
38+
| Operator::GtEq
39+
| Operator::Lt
40+
| Operator::LtEq
41+
| Operator::Eq,
42+
right,
43+
}) => {
4444
let left_col = extract_column_from_expr(left);
4545
let right_col = extract_column_from_expr(right);
4646
let left_lit = left.is_literal();

datafusion/physical-optimizer/src/enforce_distribution.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -951,17 +951,16 @@ fn add_spm_on_top(
951951
// (determined by flag `config.optimizer.bounded_order_preserving_variants`)
952952
let should_preserve_ordering = input.plan.output_ordering().is_some();
953953

954+
let ordering = input
955+
.plan
956+
.output_ordering()
957+
.cloned()
958+
.unwrap_or_else(LexOrdering::default);
959+
954960
let new_plan = if should_preserve_ordering {
955961
Arc::new(
956-
SortPreservingMergeExec::new(
957-
input
958-
.plan
959-
.output_ordering()
960-
.unwrap_or(&LexOrdering::default())
961-
.clone(),
962-
Arc::clone(&input.plan),
963-
)
964-
.with_fetch(fetch.take()),
962+
SortPreservingMergeExec::new(ordering, Arc::clone(&input.plan))
963+
.with_fetch(fetch.take()),
965964
) as _
966965
} else {
967966
Arc::new(CoalescePartitionsExec::new(Arc::clone(&input.plan))) as _
@@ -1405,14 +1404,12 @@ pub fn ensure_distribution(
14051404
// It was removed by `remove_dist_changing_operators`
14061405
// and we need to add it back.
14071406
if fetch.is_some() {
1407+
let ordering = plan
1408+
.output_ordering()
1409+
.cloned()
1410+
.unwrap_or_else(LexOrdering::default);
14081411
let plan = Arc::new(
1409-
SortPreservingMergeExec::new(
1410-
plan.output_ordering()
1411-
.unwrap_or(&LexOrdering::default())
1412-
.clone(),
1413-
plan,
1414-
)
1415-
.with_fetch(fetch.take()),
1412+
SortPreservingMergeExec::new(ordering, plan).with_fetch(fetch.take()),
14161413
);
14171414
optimized_distribution_ctx =
14181415
DistributionContext::new(plan, data, vec![optimized_distribution_ctx]);

datafusion/physical-plan/src/aggregates/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ impl ExecutionPlan for AggregateExec {
10231023
}
10241024
fn with_node_id(
10251025
self: Arc<Self>,
1026-
_node_id: usize,
1026+
node_id: usize,
10271027
) -> Result<Option<Arc<dyn ExecutionPlan>>> {
10281028
let mut new_plan = AggregateExec {
10291029
mode: self.mode,
@@ -1040,7 +1040,7 @@ impl ExecutionPlan for AggregateExec {
10401040
metrics: self.metrics.clone(),
10411041
};
10421042

1043-
let new_props: PlanProperties = new_plan.cache.clone().with_node_id(_node_id);
1043+
let new_props: PlanProperties = new_plan.cache.clone().with_node_id(node_id);
10441044
new_plan.cache = new_props;
10451045
Ok(Some(Arc::new(new_plan)))
10461046
}

datafusion/physical-plan/src/analyze.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,15 @@ impl ExecutionPlan for AnalyzeExec {
213213

214214
fn with_node_id(
215215
self: Arc<Self>,
216-
_node_id: usize,
216+
node_id: usize,
217217
) -> Result<Option<Arc<dyn ExecutionPlan>>> {
218218
let mut new_plan = AnalyzeExec::new(
219219
self.verbose,
220220
self.show_statistics,
221221
Arc::clone(self.input()),
222222
Arc::clone(&self.schema),
223223
);
224-
let new_props = new_plan.cache.clone().with_node_id(_node_id);
224+
let new_props = new_plan.cache.clone().with_node_id(node_id);
225225
new_plan.cache = new_props;
226226
Ok(Some(Arc::new(new_plan)))
227227
}

datafusion/physical-plan/src/coalesce_batches.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,12 @@ impl ExecutionPlan for CoalesceBatchesExec {
228228
}
229229
fn with_node_id(
230230
self: Arc<Self>,
231-
_node_id: usize,
231+
node_id: usize,
232232
) -> Result<Option<Arc<dyn ExecutionPlan>>> {
233233
let mut new_plan =
234234
CoalesceBatchesExec::new(Arc::clone(self.input()), self.target_batch_size)
235235
.with_fetch(self.fetch());
236-
let new_props = new_plan.cache.clone().with_node_id(_node_id);
236+
let new_props = new_plan.cache.clone().with_node_id(node_id);
237237
new_plan.cache = new_props;
238238
Ok(Some(Arc::new(new_plan)))
239239
}

datafusion/physical-plan/src/coalesce_partitions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,11 @@ impl ExecutionPlan for CoalescePartitionsExec {
214214
}
215215
fn with_node_id(
216216
self: Arc<Self>,
217-
_node_id: usize,
217+
node_id: usize,
218218
) -> Result<Option<Arc<dyn ExecutionPlan>>> {
219219
let mut new_plan = CoalescePartitionsExec::new(Arc::clone(self.input()));
220220
new_plan.fetch = self.fetch;
221-
let new_props = new_plan.cache.clone().with_node_id(_node_id);
221+
let new_props = new_plan.cache.clone().with_node_id(node_id);
222222
new_plan.cache = new_props;
223223
Ok(Some(Arc::new(new_plan)))
224224
}

datafusion/physical-plan/src/empty.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,10 @@ impl ExecutionPlan for EmptyExec {
176176

177177
fn with_node_id(
178178
self: Arc<Self>,
179-
_node_id: usize,
179+
node_id: usize,
180180
) -> Result<Option<Arc<dyn ExecutionPlan>>> {
181-
let mut new_plan = EmptyExec::new(self.schema.clone());
182-
let new_props = new_plan.cache.clone().with_node_id(_node_id);
181+
let mut new_plan = EmptyExec::new(Arc::clone(&self.schema));
182+
let new_props = new_plan.cache.clone().with_node_id(node_id);
183183
new_plan.cache = new_props;
184184
Ok(Some(Arc::new(new_plan)))
185185
}

0 commit comments

Comments
 (0)