From f635ddc39bab1aba392621310185ee1821229b8b Mon Sep 17 00:00:00 2001 From: jackwener Date: Mon, 4 Mar 2024 12:20:35 +0800 Subject: [PATCH] minor: fix cargo clippy some warning --- datafusion/common/src/parsers.rs | 11 ++++++----- datafusion/physical-expr/src/equivalence/ordering.rs | 6 +++--- .../physical-expr/src/equivalence/projection.rs | 6 +++--- datafusion/physical-expr/src/execution_props.rs | 2 +- datafusion/sql/tests/sql_integration.rs | 4 ++-- .../sqllogictest/src/engines/postgres_engine/types.rs | 7 ++++--- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/datafusion/common/src/parsers.rs b/datafusion/common/src/parsers.rs index ea2508f8c4559..9583ecbdb7338 100644 --- a/datafusion/common/src/parsers.rs +++ b/datafusion/common/src/parsers.rs @@ -17,6 +17,7 @@ //! Interval parsing logic use sqlparser::parser::ParserError; +use std::fmt::Display; use std::result; use std::str::FromStr; @@ -54,16 +55,16 @@ impl FromStr for CompressionTypeVariant { } } -impl ToString for CompressionTypeVariant { - fn to_string(&self) -> String { - match self { +impl Display for CompressionTypeVariant { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let str = match self { Self::GZIP => "GZIP", Self::BZIP2 => "BZIP2", Self::XZ => "XZ", Self::ZSTD => "ZSTD", Self::UNCOMPRESSED => "", - } - .to_string() + }; + write!(f, "{}", str) } } diff --git a/datafusion/physical-expr/src/equivalence/ordering.rs b/datafusion/physical-expr/src/equivalence/ordering.rs index 1a414592ce4c8..64000937448e9 100644 --- a/datafusion/physical-expr/src/equivalence/ordering.rs +++ b/datafusion/physical-expr/src/equivalence/ordering.rs @@ -479,7 +479,7 @@ mod tests { vec![ (col_a, options), (col_c, options), - (&floor_a, options), + (floor_a, options), (&a_plus_b, options), ], // expected: requirement is not satisfied. @@ -505,8 +505,8 @@ mod tests { vec![ (col_a, options), (col_b, options), - (&col_c, options), - (&floor_a, options), + (col_c, options), + (floor_a, options), ], // expected: requirement is satisfied. true, diff --git a/datafusion/physical-expr/src/equivalence/projection.rs b/datafusion/physical-expr/src/equivalence/projection.rs index 0f92b2c2f431d..30a31b0ad402f 100644 --- a/datafusion/physical-expr/src/equivalence/projection.rs +++ b/datafusion/physical-expr/src/equivalence/projection.rs @@ -283,7 +283,7 @@ mod tests { // orderings vec![ // [a + b ASC, c ASC] - vec![(&a_plus_b, option_asc), (&col_c, option_asc)], + vec![(&a_plus_b, option_asc), (col_c, option_asc)], ], // projection exprs vec![ @@ -546,7 +546,7 @@ mod tests { vec![ (col_a, option_asc), (col_c, option_asc), - (&col_b, option_asc), + (col_b, option_asc), ], ], // proj exprs @@ -805,7 +805,7 @@ mod tests { // [a+b ASC, round(c) ASC, c_new ASC] vec![ (&a_new_plus_b_new, option_asc), - (&col_round_c_res, option_asc), + (col_round_c_res, option_asc), ], // [a+b ASC, c_new ASC] vec![(&a_new_plus_b_new, option_asc), (col_c_new, option_asc)], diff --git a/datafusion/physical-expr/src/execution_props.rs b/datafusion/physical-expr/src/execution_props.rs index 8fdbbb7c5452f..20999ab8d3db3 100644 --- a/datafusion/physical-expr/src/execution_props.rs +++ b/datafusion/physical-expr/src/execution_props.rs @@ -99,7 +99,7 @@ impl ExecutionProps { ) -> Option> { self.var_providers .as_ref() - .and_then(|var_providers| var_providers.get(&var_type).map(Arc::clone)) + .and_then(|var_providers| var_providers.get(&var_type).cloned()) } } diff --git a/datafusion/sql/tests/sql_integration.rs b/datafusion/sql/tests/sql_integration.rs index 55551d1d25a35..9d7b209d77b71 100644 --- a/datafusion/sql/tests/sql_integration.rs +++ b/datafusion/sql/tests/sql_integration.rs @@ -2881,11 +2881,11 @@ impl ContextProvider for MockContextProvider { } fn get_function_meta(&self, name: &str) -> Option> { - self.udfs.get(name).map(Arc::clone) + self.udfs.get(name).cloned() } fn get_aggregate_meta(&self, name: &str) -> Option> { - self.udafs.get(name).map(Arc::clone) + self.udafs.get(name).cloned() } fn get_variable_type(&self, _: &[String]) -> Option { diff --git a/datafusion/sqllogictest/src/engines/postgres_engine/types.rs b/datafusion/sqllogictest/src/engines/postgres_engine/types.rs index 0c66150d1bb4e..510462befb086 100644 --- a/datafusion/sqllogictest/src/engines/postgres_engine/types.rs +++ b/datafusion/sqllogictest/src/engines/postgres_engine/types.rs @@ -16,6 +16,7 @@ // under the License. use postgres_types::Type; +use std::fmt::Display; use tokio_postgres::types::FromSql; pub struct PgRegtype { @@ -37,8 +38,8 @@ impl<'a> FromSql<'a> for PgRegtype { } } -impl ToString for PgRegtype { - fn to_string(&self) -> String { - self.value.clone() +impl Display for PgRegtype { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.value) } }