Skip to content

Commit a169118

Browse files
codetyri0nlogan-keede
authored andcommitted
CI: add clippy::needless_pass_by_value rule to datafusion-functions-window crate (apache#18838)
## Which issue does this PR close? - Closes apache#18834 and part of apache#18503 ## What changes are included in this PR? - enforces clippy rule to the datafusion-functions-window crate ## Are these changes tested? - yes ## Are there any user-facing changes? - no
1 parent b2e8cd8 commit a169118

5 files changed

Lines changed: 9 additions & 6 deletions

File tree

‎datafusion/functions-window/src/lead_lag.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ impl WindowUDFImpl for WindowShift {
264264
) -> Result<Box<dyn PartitionEvaluator>> {
265265
let shift_offset =
266266
get_scalar_value_from_args(partition_evaluator_args.input_exprs(), 1)?
267-
.map(get_signed_integer)
267+
.map(|v| get_signed_integer(&v))
268268
.map_or(Ok(None), |v| v.map(Some))
269269
.map(|n| self.kind.shift_offset(n))
270270
.map(|offset| {

‎datafusion/functions-window/src/lib.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18+
// https://github.com/apache/datafusion/issues/18503
19+
#![deny(clippy::needless_pass_by_value)]
20+
#![cfg_attr(test, allow(clippy::needless_pass_by_value))]
1821
#![doc(
1922
html_logo_url = "https://raw.githubusercontent.com/apache/datafusion/19fe44cf2f30cbdd63d4a4f52c74055163c6cc38/docs/logos/standalone_logo/logo_original.svg",
2023
html_favicon_url = "https://raw.githubusercontent.com/apache/datafusion/19fe44cf2f30cbdd63d4a4f52c74055163c6cc38/docs/logos/standalone_logo/logo_original.svg"

‎datafusion/functions-window/src/nth_value.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ impl WindowUDFImpl for NthValue {
282282
exec_datafusion_err!(
283283
"Expected a signed integer literal for the second argument of nth_value")
284284
})?
285-
.map(get_signed_integer)
285+
.map(|v| get_signed_integer(&v))
286286
{
287287
Some(Ok(n)) => {
288288
if partition_evaluator_args.is_reversed() {

‎datafusion/functions-window/src/ntile.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@ impl WindowUDFImpl for Ntile {
135135
}
136136

137137
if scalar_n.is_unsigned() {
138-
let n = get_unsigned_integer(scalar_n)?;
138+
let n = get_unsigned_integer(&scalar_n)?;
139139
Ok(Box::new(NtileEvaluator { n }))
140140
} else {
141-
let n: i64 = get_signed_integer(scalar_n)?;
141+
let n: i64 = get_signed_integer(&scalar_n)?;
142142
if n <= 0 {
143143
return exec_err!("NTILE requires a positive integer");
144144
}

‎datafusion/functions-window/src/utils.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use datafusion_physical_expr::expressions::Literal;
2121
use datafusion_physical_expr_common::physical_expr::PhysicalExpr;
2222
use std::sync::Arc;
2323

24-
pub(crate) fn get_signed_integer(value: ScalarValue) -> Result<i64> {
24+
pub(crate) fn get_signed_integer(value: &ScalarValue) -> Result<i64> {
2525
if value.is_null() {
2626
return Ok(0);
2727
}
@@ -52,7 +52,7 @@ pub(crate) fn get_scalar_value_from_args(
5252
})
5353
}
5454

55-
pub(crate) fn get_unsigned_integer(value: ScalarValue) -> Result<u64> {
55+
pub(crate) fn get_unsigned_integer(value: &ScalarValue) -> Result<u64> {
5656
if value.is_null() {
5757
return Ok(0);
5858
}

0 commit comments

Comments
 (0)