Skip to content

Commit

Permalink
minor: fix cargo clippy some warning
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwener committed Mar 4, 2024
1 parent 1a4dc00 commit f635ddc
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
11 changes: 6 additions & 5 deletions datafusion/common/src/parsers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

//! Interval parsing logic
use sqlparser::parser::ParserError;
use std::fmt::Display;

use std::result;
use std::str::FromStr;
Expand Down Expand Up @@ -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)
}
}

Expand Down
6 changes: 3 additions & 3 deletions datafusion/physical-expr/src/equivalence/ordering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions datafusion/physical-expr/src/equivalence/projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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![
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)],
Expand Down
2 changes: 1 addition & 1 deletion datafusion/physical-expr/src/execution_props.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl ExecutionProps {
) -> Option<Arc<dyn VarProvider + Send + Sync>> {
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())
}
}

Expand Down
4 changes: 2 additions & 2 deletions datafusion/sql/tests/sql_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2881,11 +2881,11 @@ impl ContextProvider for MockContextProvider {
}

fn get_function_meta(&self, name: &str) -> Option<Arc<ScalarUDF>> {
self.udfs.get(name).map(Arc::clone)
self.udfs.get(name).cloned()
}

fn get_aggregate_meta(&self, name: &str) -> Option<Arc<AggregateUDF>> {
self.udafs.get(name).map(Arc::clone)
self.udafs.get(name).cloned()
}

fn get_variable_type(&self, _: &[String]) -> Option<DataType> {
Expand Down
7 changes: 4 additions & 3 deletions datafusion/sqllogictest/src/engines/postgres_engine/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// under the License.

use postgres_types::Type;
use std::fmt::Display;
use tokio_postgres::types::FromSql;

pub struct PgRegtype {
Expand All @@ -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)
}
}

0 comments on commit f635ddc

Please sign in to comment.