This is an automated email from the ASF dual-hosted git repository.
github-bot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 958a6de9d8 chore: Enforce 'clippy::needless_pass_by_value' to
datafusion-expr-common (#18775)
958a6de9d8 is described below
commit 958a6de9d8e8f827f2af59a333a372264ea3218f
Author: Peter Nguyen <[email protected]>
AuthorDate: Tue Nov 18 00:54:41 2025 -0800
chore: Enforce 'clippy::needless_pass_by_value' to datafusion-expr-common
(#18775)
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes #123` indicates that this PR will close issue #123.
-->
- Closes #18760
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->
## Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->
Cargo clippy and tests still pass
## Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->
No
<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->
---
datafusion/expr-common/src/interval_arithmetic.rs | 16 ++++++++--------
datafusion/expr-common/src/lib.rs | 3 +++
datafusion/expr-common/src/type_coercion/binary.rs | 12 ++++++------
3 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/datafusion/expr-common/src/interval_arithmetic.rs
b/datafusion/expr-common/src/interval_arithmetic.rs
index 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.rs
index 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.rs
index 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)
)
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]