Skip to content

Apache DataFusion SQL Query Engine

fix some clippy warnings (#1277)

Jiayu Liu186b0b5279e6
diff --git a/datafusion/src/datasource/file_format/json.rs b/datafusion/src/datasource/file_format/json.rs
index 72bbee665a..b3fb1c4b46 100644
--- a/datafusion/src/datasource/file_format/json.rs
+++ b/datafusion/src/datasource/file_format/json.rs
@@ -38,19 +38,11 @@ use crate::physical_plan::ExecutionPlan;
use crate::physical_plan::Statistics;
/// New line delimited JSON `FileFormat` implementation.
-#[derive(Debug)]
+#[derive(Debug, Default)]
pub struct JsonFormat {
schema_infer_max_rec: Option<usize>,
}
-impl Default for JsonFormat {
- fn default() -> Self {
- Self {
- schema_infer_max_rec: None,
- }
- }
-}
-
impl JsonFormat {
/// Set a limit in terms of records to scan to infer the schema
/// - defaults to `None` (no limit)
diff --git a/datafusion/src/optimizer/common_subexpr_eliminate.rs b/datafusion/src/optimizer/common_subexpr_eliminate.rs
index c8f14040e8..930f0b8c3a 100644
--- a/datafusion/src/optimizer/common_subexpr_eliminate.rs
+++ b/datafusion/src/optimizer/common_subexpr_eliminate.rs
@@ -224,13 +224,13 @@ fn optimize(plan: &LogicalPlan, execution_props: &ExecutionProps) -> Result<Logi
fn to_arrays(
expr: &[Expr],
input: &LogicalPlan,
- mut expr_set: &mut ExprSet,
+ expr_set: &mut ExprSet,
) -> Result<Vec<Vec<(usize, String)>>> {
expr.iter()
.map(|e| {
let data_type = e.get_type(input.schema())?;
let mut id_array = vec![];
- expr_to_identifier(e, &mut expr_set, &mut id_array, data_type)?;
+ expr_to_identifier(e, expr_set, &mut id_array, data_type)?;
Ok(id_array)
})
diff --git a/datafusion/src/physical_plan/crypto_expressions.rs b/datafusion/src/physical_plan/crypto_expressions.rs
index 25d63b81ce..4ad3087753 100644
--- a/datafusion/src/physical_plan/crypto_expressions.rs
+++ b/datafusion/src/physical_plan/crypto_expressions.rs
@@ -65,8 +65,7 @@ fn digest_process(
DataType::LargeUtf8 => digest_algorithm.digest_array::<i64>(a.as_ref()),
other => Err(DataFusionError::Internal(format!(
"Unsupported data type {:?} for function {}",
- other,
- digest_algorithm.to_string(),
+ other, digest_algorithm,
))),
},
ColumnarValue::Scalar(scalar) => match scalar {
@@ -75,8 +74,7 @@ fn digest_process(
}
other => Err(DataFusionError::Internal(format!(
"Unsupported data type {:?} for function {}",
- other,
- digest_algorithm.to_string(),
+ other, digest_algorithm,
))),
},
}
@@ -244,7 +242,7 @@ pub fn md5(args: &[ColumnarValue]) -> Result<ColumnarValue> {
return Err(DataFusionError::Internal(format!(
"{:?} args were supplied but {} takes exactly one argument",
args.len(),
- DigestAlgorithm::Md5.to_string(),
+ DigestAlgorithm::Md5,
)));
}
let value = digest_process(&args[0], DigestAlgorithm::Md5)?;
diff --git a/datafusion/src/physical_plan/planner.rs b/datafusion/src/physical_plan/planner.rs
index 44bd4b16bb..8f7112ea14 100644
--- a/datafusion/src/physical_plan/planner.rs
+++ b/datafusion/src/physical_plan/planner.rs
@@ -260,18 +260,11 @@ pub trait ExtensionPlanner {
/// Default single node physical query planner that converts a
/// `LogicalPlan` to an `ExecutionPlan` suitable for execution.
+#[derive(Default)]
pub struct DefaultPhysicalPlanner {
extension_planners: Vec<Arc<dyn ExtensionPlanner + Send + Sync>>,
}
-impl Default for DefaultPhysicalPlanner {
- fn default() -> Self {
- Self {
- extension_planners: vec![],
- }
- }
-}
-
#[async_trait]
impl PhysicalPlanner for DefaultPhysicalPlanner {
/// Create a physical plan from a logical plan
diff --git a/datafusion/src/physical_plan/string_expressions.rs b/datafusion/src/physical_plan/string_expressions.rs
index 7cbebcec7e..e6d234fbc2 100644
--- a/datafusion/src/physical_plan/string_expressions.rs
+++ b/datafusion/src/physical_plan/string_expressions.rs
@@ -119,7 +119,7 @@ where
// first map is the iterator, second is for the `Option<_>`
Ok(string_array
.iter()
- .map(|string| string.map(|string| op(string)))
+ .map(|string| string.map(|s| op(s)))
.collect())
}
diff --git a/datafusion/src/scalar.rs b/datafusion/src/scalar.rs
index 33bc9dd104..4a5a2c34a3 100644
--- a/datafusion/src/scalar.rs
+++ b/datafusion/src/scalar.rs
@@ -788,7 +788,7 @@ impl ScalarValue {
(0..fields.len()).map(|_| Vec::new()).collect();
// Iterate over scalars to populate the column scalars for each row
- for scalar in scalars.into_iter() {
+ for scalar in scalars {
if let ScalarValue::Struct(values, fields) = scalar {
match values {
Some(values) => {
diff --git a/datafusion/src/sql/planner.rs b/datafusion/src/sql/planner.rs
index 9f1d2433fe..ad84bdc11b 100644
--- a/datafusion/src/sql/planner.rs
+++ b/datafusion/src/sql/planner.rs
@@ -1066,8 +1066,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
.map_err(|_: DataFusionError| {
DataFusionError::Plan(format!(
"Invalid identifier '{}' for schema {}",
- col,
- schema.to_string()
+ col, schema
))
}),
_ => Err(DataFusionError::Internal("Not a column".to_string())),
@@ -1852,9 +1851,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
.iter()
.rev()
.zip(columns)
- .map(|(ident, column_name)| {
- format!(r#"{} = '{}'"#, column_name, ident.to_string())
- })
+ .map(|(ident, column_name)| format!(r#"{} = '{}'"#, column_name, ident))
.collect::<Vec<_>>()
.join(" AND ");
diff --git a/datafusion/src/test_util.rs b/datafusion/src/test_util.rs
index b87b756dba..8548c62836 100644
--- a/datafusion/src/test_util.rs
+++ b/datafusion/src/test_util.rs
@@ -199,7 +199,7 @@ fn get_data_dir(udf_env: &str, submodule_data: &str) -> Result<PathBuf, Box<dyn
} else {
return Err(format!(
"the data dir `{}` defined by env {} not found",
- pb.display().to_string(),
+ pb.display(),
udf_env
)
.into());
@@ -222,7 +222,7 @@ fn get_data_dir(udf_env: &str, submodule_data: &str) -> Result<PathBuf, Box<dyn
"env `{}` is undefined or has empty value, and the pre-defined data dir `{}` not found\n\
HINT: try running `git submodule update --init`",
udf_env,
- pb.display().to_string(),
+ pb.display(),
).into())
}
}