Skip to content

Apache DataFusion SQL Query Engine

ARROW-10828: [Rust][DataFusion] Address / fix clippy lints

Heres, Daniela1184590dd1f
diff --git a/rust/datafusion/src/execution/context.rs b/rust/datafusion/src/execution/context.rs
index 3660fff7a5..ee28f2ed9f 100644
--- a/rust/datafusion/src/execution/context.rs
+++ b/rust/datafusion/src/execution/context.rs
@@ -386,7 +386,7 @@ impl ExecutionContext {
.map(|batch| writer.write(&batch?))
.try_collect()
.await
- .map_err(|e| DataFusionError::from(e))?;
+ .map_err(DataFusionError::from)?;
}
Ok(())
}
@@ -415,7 +415,7 @@ impl ExecutionContext {
.map(|batch| writer.write(&batch?))
.try_collect()
.await
- .map_err(|e| DataFusionError::from(e))?;
+ .map_err(DataFusionError::from)?;
writer.close()?;
}
diff --git a/rust/datafusion/src/lib.rs b/rust/datafusion/src/lib.rs
index 9f2979b93e..27ba041dd9 100644
--- a/rust/datafusion/src/lib.rs
+++ b/rust/datafusion/src/lib.rs
@@ -40,10 +40,6 @@
clippy::new_without_default,
clippy::or_fun_call,
clippy::ptr_arg,
- clippy::redundant_field_names,
- clippy::redundant_static_lifetimes,
- clippy::redundant_pattern_matching,
- clippy::redundant_closure,
clippy::single_match,
clippy::stable_sort_primitive,
clippy::type_complexity,
diff --git a/rust/datafusion/src/logical_plan/builder.rs b/rust/datafusion/src/logical_plan/builder.rs
index 37b82b1a80..ca3d8ed6cc 100644
--- a/rust/datafusion/src/logical_plan/builder.rs
+++ b/rust/datafusion/src/logical_plan/builder.rs
@@ -97,8 +97,7 @@ impl LogicalPlanBuilder {
let projected_schema = projection
.clone()
.map(|p| Schema::new(p.iter().map(|i| schema.field(*i).clone()).collect()));
- let projected_schema =
- projected_schema.map_or(schema.clone(), |s| SchemaRef::new(s));
+ let projected_schema = projected_schema.map_or(schema.clone(), SchemaRef::new);
Ok(Self::from(&LogicalPlan::ParquetScan {
path: path.to_owned(),
@@ -120,7 +119,7 @@ impl LogicalPlanBuilder {
Schema::new(p.iter().map(|i| table_schema.field(*i).clone()).collect())
});
let projected_schema =
- projected_schema.map_or(table_schema.clone(), |s| SchemaRef::new(s));
+ projected_schema.map_or(table_schema.clone(), SchemaRef::new);
Ok(Self::from(&LogicalPlan::TableScan {
schema_name: schema_name.to_owned(),
diff --git a/rust/datafusion/src/optimizer/projection_push_down.rs b/rust/datafusion/src/optimizer/projection_push_down.rs
index e06a605e55..ac653065cc 100644
--- a/rust/datafusion/src/optimizer/projection_push_down.rs
+++ b/rust/datafusion/src/optimizer/projection_push_down.rs
@@ -263,7 +263,7 @@ fn optimize_plan(
source: source.clone(),
table_schema: table_schema.clone(),
projection: Some(projection),
- projected_schema: projected_schema,
+ projected_schema,
})
}
LogicalPlan::InMemoryScan {
@@ -282,7 +282,7 @@ fn optimize_plan(
data: data.clone(),
schema: schema.clone(),
projection: Some(projection),
- projected_schema: projected_schema,
+ projected_schema,
})
}
LogicalPlan::CsvScan {
@@ -306,7 +306,7 @@ fn optimize_plan(
schema: schema.clone(),
delimiter: *delimiter,
projection: Some(projection),
- projected_schema: projected_schema,
+ projected_schema,
})
}
LogicalPlan::ParquetScan {
@@ -326,7 +326,7 @@ fn optimize_plan(
path: path.to_owned(),
schema: schema.clone(),
projection: Some(projection),
- projected_schema: projected_schema,
+ projected_schema,
})
}
LogicalPlan::Explain {
diff --git a/rust/datafusion/src/physical_plan/aggregates.rs b/rust/datafusion/src/physical_plan/aggregates.rs
index eba8c7552a..78d1d10358 100644
--- a/rust/datafusion/src/physical_plan/aggregates.rs
+++ b/rust/datafusion/src/physical_plan/aggregates.rs
@@ -163,7 +163,7 @@ pub fn create_aggregate_expr(
})
}
-static NUMERICS: &'static [DataType] = &[
+static NUMERICS: &[DataType] = &[
DataType::Int8,
DataType::Int16,
DataType::Int32,
diff --git a/rust/datafusion/src/physical_plan/array_expressions.rs b/rust/datafusion/src/physical_plan/array_expressions.rs
index 528cbb3da8..7bdb742fd7 100644
--- a/rust/datafusion/src/physical_plan/array_expressions.rs
+++ b/rust/datafusion/src/physical_plan/array_expressions.rs
@@ -91,7 +91,7 @@ pub fn array(args: &[ArrayRef]) -> Result<ArrayRef> {
/// Currently supported types by the array function.
/// The order of these types correspond to the order on which coercion applies
/// This should thus be from least informative to most informative
-pub static SUPPORTED_ARRAY_TYPES: &'static [DataType] = &[
+pub static SUPPORTED_ARRAY_TYPES: &[DataType] = &[
DataType::Boolean,
DataType::UInt8,
DataType::UInt16,
diff --git a/rust/datafusion/src/physical_plan/common.rs b/rust/datafusion/src/physical_plan/common.rs
index 7c4f217902..3c63a447e9 100644
--- a/rust/datafusion/src/physical_plan/common.rs
+++ b/rust/datafusion/src/physical_plan/common.rs
@@ -84,7 +84,7 @@ pub async fn collect(stream: SendableRecordBatchStream) -> Result<Vec<RecordBatc
stream
.try_collect::<Vec<_>>()
.await
- .map_err(|e| DataFusionError::from(e))
+ .map_err(DataFusionError::from)
}
/// Recursively build a list of files in a directory with a given extension
diff --git a/rust/datafusion/src/physical_plan/expressions.rs b/rust/datafusion/src/physical_plan/expressions.rs
index 9718f461b5..d9a00c8e29 100644
--- a/rust/datafusion/src/physical_plan/expressions.rs
+++ b/rust/datafusion/src/physical_plan/expressions.rs
@@ -1603,7 +1603,7 @@ pub fn nullif_func(args: &[ArrayRef]) -> Result<ArrayRef> {
/// Currently supported types by the nullif function.
/// The order of these types correspond to the order on which coercion applies
/// This should thus be from least informative to most informative
-pub static SUPPORTED_NULLIF_TYPES: &'static [DataType] = &[
+pub static SUPPORTED_NULLIF_TYPES: &[DataType] = &[
DataType::Boolean,
DataType::UInt8,
DataType::UInt16,
diff --git a/rust/datafusion/src/physical_plan/functions.rs b/rust/datafusion/src/physical_plan/functions.rs
index 56fe2c5060..d296512ffd 100644
--- a/rust/datafusion/src/physical_plan/functions.rs
+++ b/rust/datafusion/src/physical_plan/functions.rs
@@ -455,7 +455,7 @@ mod tests {
#[test]
fn test_concat_error() -> Result<()> {
let result = return_type(&BuiltinScalarFunction::Concat, &vec![]);
- if let Ok(_) = result {
+ if result.is_ok() {
Err(DataFusionError::Plan(
"Function 'concat' cannot accept zero arguments".to_string(),
))
diff --git a/rust/datafusion/src/physical_plan/planner.rs b/rust/datafusion/src/physical_plan/planner.rs
index 40603832f0..80f0613c19 100644
--- a/rust/datafusion/src/physical_plan/planner.rs
+++ b/rust/datafusion/src/physical_plan/planner.rs
@@ -603,7 +603,7 @@ impl DefaultPhysicalPlanner {
) -> Result<PhysicalSortExpr> {
Ok(PhysicalSortExpr {
expr: self.create_physical_expr(e, input_schema, ctx_state)?,
- options: options,
+ options,
})
}
}
diff --git a/rust/datafusion/src/physical_plan/type_coercion.rs b/rust/datafusion/src/physical_plan/type_coercion.rs
index 728dd81538..55e24a7147 100644
--- a/rust/datafusion/src/physical_plan/type_coercion.rs
+++ b/rust/datafusion/src/physical_plan/type_coercion.rs
@@ -346,7 +346,7 @@ mod tests {
];
for case in cases {
- if let Ok(_) = coerce(&case.0, &case.1, &case.2) {
+ if coerce(&case.0, &case.1, &case.2).is_ok() {
return Err(DataFusionError::Plan(format!(
"Error was expected in {:?}",
case