Apache DataFusion SQL Query Engine
chore: Enforce 'clippy::needless_pass_by_value' to datafusion-expr-common (#18775)
Peter Nguyen958a6de9d8e8
diff --git a/datafusion/expr-common/src/interval_arithmetic.rs b/datafusion/expr-common/src/interval_arithmetic.rsindex a04005072e..407cc1032d 100644--- a/datafusion/expr-common/src/interval_arithmetic.rs+++ b/datafusion/expr-common/src/interval_arithmetic.rs@@ -858,12 +858,12 @@ impl Interval {) {(true, true, false) => mul_helper_multi_zero_inclusive(&dt, self, rhs),(true, false, false) => {- mul_helper_single_zero_inclusive(&dt, self, rhs, zero)+ mul_helper_single_zero_inclusive(&dt, self, rhs, &zero)}(false, true, false) => {- mul_helper_single_zero_inclusive(&dt, rhs, self, zero)+ mul_helper_single_zero_inclusive(&dt, rhs, self, &zero)}- _ => mul_helper_zero_exclusive(&dt, self, rhs, zero),+ _ => mul_helper_zero_exclusive(&dt, self, rhs, &zero),};Ok(result)}@@ -1462,10 +1462,10 @@ fn mul_helper_single_zero_inclusive(dt: &DataType,lhs: &Interval,rhs: &Interval,- zero: ScalarValue,+ zero: &ScalarValue,) -> Interval {// With the following interval bounds, there is no possibility to create an invalid interval.- if rhs.upper <= zero && !rhs.upper.is_null() {+ if rhs.upper <= *zero && !rhs.upper.is_null() {// <-------=====0=====------->// <--======----0------------>let lower = mul_bounds::<false>(dt, &lhs.upper, &rhs.lower);@@ -1514,11 +1514,11 @@ fn mul_helper_zero_exclusive(dt: &DataType,lhs: &Interval,rhs: &Interval,- zero: ScalarValue,+ zero: &ScalarValue,) -> Interval {let (lower, upper) = match (- lhs.upper <= zero && !lhs.upper.is_null(),- rhs.upper <= zero && !rhs.upper.is_null(),+ lhs.upper <= *zero && !lhs.upper.is_null(),+ rhs.upper <= *zero && !rhs.upper.is_null(),) {// With the following interval bounds, there is no possibility to create an invalid interval.(true, true) => (diff --git a/datafusion/expr-common/src/lib.rs b/datafusion/expr-common/src/lib.rsindex a4f6414a8c..5323c3cb18 100644--- a/datafusion/expr-common/src/lib.rs+++ b/datafusion/expr-common/src/lib.rs@@ -31,6 +31,9 @@// Make sure fast / cheap clones on Arc are explicit:// https://github.com/apache/datafusion/issues/11143#![deny(clippy::clone_on_ref_ptr)]+// https://github.com/apache/datafusion/issues/18503+#![deny(clippy::needless_pass_by_value)]+#![cfg_attr(test, allow(clippy::needless_pass_by_value))]pub mod accumulator;pub mod casts;diff --git a/datafusion/expr-common/src/type_coercion/binary.rs b/datafusion/expr-common/src/type_coercion/binary.rsindex 44f1a42c54..4aacc7533c 100644--- a/datafusion/expr-common/src/type_coercion/binary.rs+++ b/datafusion/expr-common/src/type_coercion/binary.rs@@ -933,7 +933,7 @@ fn string_temporal_coercion(match temporal {Date32 | Date64 => Some(temporal.clone()),Time32(_) | Time64(_) => {- if is_time_with_valid_unit(temporal.to_owned()) {+ if is_time_with_valid_unit(temporal) {Some(temporal.to_owned())} else {None@@ -1703,13 +1703,13 @@ pub fn regex_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataTy/// Checks if the TimeUnit associated with a Time32 or Time64 type is consistent,/// as Time32 can only be used to Second and Millisecond accuracy, while Time64/// is exclusively used to Microsecond and Nanosecond accuracy-fn is_time_with_valid_unit(datatype: DataType) -> bool {+fn is_time_with_valid_unit(datatype: &DataType) -> bool {matches!(datatype,- DataType::Time32(TimeUnit::Second)- | DataType::Time32(TimeUnit::Millisecond)- | DataType::Time64(TimeUnit::Microsecond)- | DataType::Time64(TimeUnit::Nanosecond)+ &DataType::Time32(TimeUnit::Second)+ | &DataType::Time32(TimeUnit::Millisecond)+ | &DataType::Time64(TimeUnit::Microsecond)+ | &DataType::Time64(TimeUnit::Nanosecond))}