You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by dh...@apache.org on 2021/11/21 20:06:00 UTC

[arrow-datafusion] branch master updated: fix some clippy warnings (#1277)

This is an automated email from the ASF dual-hosted git repository.

dheres pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git


The following commit(s) were added to refs/heads/master by this push:
     new 186b0b5  fix some clippy warnings (#1277)
186b0b5 is described below

commit 186b0b5279e6c0428fb992826428c25e1caa5a2e
Author: Jiayu Liu <Ji...@users.noreply.github.com>
AuthorDate: Mon Nov 22 04:05:54 2021 +0800

    fix some clippy warnings (#1277)
---
 datafusion/src/datasource/file_format/json.rs        | 10 +---------
 datafusion/src/optimizer/common_subexpr_eliminate.rs |  4 ++--
 datafusion/src/physical_plan/crypto_expressions.rs   |  8 +++-----
 datafusion/src/physical_plan/planner.rs              |  9 +--------
 datafusion/src/physical_plan/string_expressions.rs   |  2 +-
 datafusion/src/scalar.rs                             |  2 +-
 datafusion/src/sql/planner.rs                        |  7 ++-----
 datafusion/src/test_util.rs                          |  4 ++--
 8 files changed, 13 insertions(+), 33 deletions(-)

diff --git a/datafusion/src/datasource/file_format/json.rs b/datafusion/src/datasource/file_format/json.rs
index 72bbee6..b3fb1c4 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 c8f1404..930f0b8 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 25d63b8..4ad3087 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 44bd4b1..8f7112e 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 7cbebce..e6d234f 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 33bc9dd..4a5a2c3 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 9f1d243..ad84bdc 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 b87b756..8548c62 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())
     }
 }