Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions datafusion/expr-common/src/interval_arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -847,12 +847,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)
}
Expand Down Expand Up @@ -1454,10 +1454,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);
Expand Down Expand Up @@ -1506,11 +1506,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) => (
Expand Down
3 changes: 3 additions & 0 deletions datafusion/expr-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions datafusion/expr-common/src/type_coercion/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
)
}

Expand Down