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 1e9c1f426e minor: enforce lint rule clippy::needless_pass_by_value to 
datafusion-functions (#18768)
1e9c1f426e is described below

commit 1e9c1f426eadc0afbfacf9715e5a900d1998927d
Author: Alan Tang <[email protected]>
AuthorDate: Fri Nov 21 17:49:53 2025 -0800

    minor: enforce lint rule clippy::needless_pass_by_value to 
datafusion-functions (#18768)
    
    ## 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 #18758.
    
    ## 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.
    -->
    
    - enforce lint rule `clippy::needless_pass_by_value` to
    `datafusion-functions`.
    
    ## 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)?
    -->
    
    ## Are there any user-facing changes?
    
    <!--
    If there are user-facing changes then we may require documentation to be
    updated before approving the PR.
    -->
    
    <!--
    If there are any breaking changes to public APIs, please add the `api
    change` label.
    -->
    
    ---------
    
    Signed-off-by: StandingMan <[email protected]>
---
 datafusion/functions/src/core/getfield.rs          | 20 ++++++------
 .../functions/src/core/greatest_least_utils.rs     | 12 +++----
 datafusion/functions/src/core/mod.rs               |  2 ++
 datafusion/functions/src/crypto/basic.rs           | 12 +++----
 datafusion/functions/src/datetime/common.rs        |  8 ++---
 datafusion/functions/src/datetime/to_char.rs       | 14 ++++----
 datafusion/functions/src/lib.rs                    |  3 ++
 datafusion/functions/src/regex/regexpcount.rs      | 38 +++++++++++-----------
 datafusion/functions/src/regex/regexpinstr.rs      |  1 +
 datafusion/functions/src/regex/regexpreplace.rs    |  1 +
 datafusion/functions/src/string/ascii.rs           |  8 ++---
 datafusion/functions/src/string/common.rs          |  1 +
 datafusion/functions/src/string/repeat.rs          |  8 ++---
 datafusion/functions/src/string/split_part.rs      |  1 +
 .../functions/src/unicode/character_length.rs      |  8 ++---
 datafusion/functions/src/unicode/find_in_set.rs    | 29 +++++++++--------
 datafusion/functions/src/unicode/lpad.rs           | 12 +++----
 datafusion/functions/src/unicode/reverse.rs        |  6 ++--
 datafusion/functions/src/unicode/rpad.rs           | 12 +++----
 datafusion/functions/src/unicode/strpos.rs         | 22 ++++++-------
 20 files changed, 114 insertions(+), 104 deletions(-)

diff --git a/datafusion/functions/src/core/getfield.rs 
b/datafusion/functions/src/core/getfield.rs
index 3be7dd6798..1194d11ba5 100644
--- a/datafusion/functions/src/core/getfield.rs
+++ b/datafusion/functions/src/core/getfield.rs
@@ -197,10 +197,10 @@ impl ScalarUDFImpl for GetFieldFunc {
         };
 
         fn process_map_array(
-            array: Arc<dyn Array>,
+            array: &dyn Array,
             key_array: Arc<dyn Array>,
         ) -> Result<ColumnarValue> {
-            let map_array = as_map_array(array.as_ref())?;
+            let map_array = as_map_array(array)?;
             let keys = if key_array.data_type().is_nested() {
                 let comparator = make_comparator(
                     map_array.keys().as_ref(),
@@ -246,14 +246,14 @@ impl ScalarUDFImpl for GetFieldFunc {
         }
 
         fn process_map_with_nested_key(
-            array: Arc<dyn Array>,
-            key_array: Arc<dyn Array>,
+            array: &dyn Array,
+            key_array: &dyn Array,
         ) -> Result<ColumnarValue> {
-            let map_array = as_map_array(array.as_ref())?;
+            let map_array = as_map_array(array)?;
 
             let comparator = make_comparator(
                 map_array.keys().as_ref(),
-                key_array.as_ref(),
+                key_array,
                 SortOptions::default(),
             )?;
 
@@ -288,17 +288,17 @@ impl ScalarUDFImpl for GetFieldFunc {
         match (array.data_type(), name) {
             (DataType::Map(_, _), ScalarValue::List(arr)) => {
                 let key_array: Arc<dyn Array> = arr;
-                process_map_array(array, key_array)
+                process_map_array(&array, key_array)
             }
             (DataType::Map(_, _), ScalarValue::Struct(arr)) => {
-                process_map_array(array, arr as Arc<dyn Array>)
+                process_map_array(&array, arr as Arc<dyn Array>)
             }
             (DataType::Map(_, _), other) => {
                 let data_type = other.data_type();
                 if data_type.is_nested() {
-                    process_map_with_nested_key(array, other.to_array()?)
+                    process_map_with_nested_key(&array, &other.to_array()?)
                 } else {
-                    process_map_array(array, other.to_array()?)
+                    process_map_array(&array, other.to_array()?)
                 }
             }
             (DataType::Struct(_), ScalarValue::Utf8(Some(k))) => {
diff --git a/datafusion/functions/src/core/greatest_least_utils.rs 
b/datafusion/functions/src/core/greatest_least_utils.rs
index b704acd9dc..2a86666856 100644
--- a/datafusion/functions/src/core/greatest_least_utils.rs
+++ b/datafusion/functions/src/core/greatest_least_utils.rs
@@ -38,11 +38,11 @@ pub(super) trait GreatestLeastOperator {
 }
 
 fn keep_array<Op: GreatestLeastOperator>(
-    lhs: ArrayRef,
-    rhs: ArrayRef,
+    lhs: &dyn Array,
+    rhs: &dyn Array,
 ) -> Result<ArrayRef> {
     // True for values that we should keep from the left array
-    let keep_lhs = Op::get_indexes_to_keep(lhs.as_ref(), rhs.as_ref())?;
+    let keep_lhs = Op::get_indexes_to_keep(lhs, rhs)?;
 
     let result = zip(&keep_lhs, &lhs, &rhs)?;
 
@@ -102,8 +102,8 @@ pub(super) fn execute_conditional<Op: 
GreatestLeastOperator>(
 
         // Start with the result value
         result = keep_array::<Op>(
-            Arc::clone(first_array),
-            result_scalar.to_array_of_size(first_array.len())?,
+            first_array,
+            &result_scalar.to_array_of_size(first_array.len())?,
         )?;
     } else {
         // If we only have arrays, start with the first array
@@ -112,7 +112,7 @@ pub(super) fn execute_conditional<Op: 
GreatestLeastOperator>(
     }
 
     for array in arrays_iter {
-        result = keep_array::<Op>(Arc::clone(array), result)?;
+        result = keep_array::<Op>(array, &result)?;
     }
 
     Ok(ColumnarValue::Array(result))
diff --git a/datafusion/functions/src/core/mod.rs 
b/datafusion/functions/src/core/mod.rs
index db080cd628..0c569d3006 100644
--- a/datafusion/functions/src/core/mod.rs
+++ b/datafusion/functions/src/core/mod.rs
@@ -110,11 +110,13 @@ pub mod expr_fn {
     ));
 
     #[doc = "Returns the value of the field with the given name from the 
struct"]
+    #[expect(clippy::needless_pass_by_value)]
     pub fn get_field(arg1: Expr, arg2: impl Literal) -> Expr {
         super::get_field().call(vec![arg1, arg2.lit()])
     }
 
     #[doc = "Returns the value of the field with the given name from the union 
when it's selected, or NULL otherwise"]
+    #[expect(clippy::needless_pass_by_value)]
     pub fn union_extract(arg1: Expr, arg2: impl Literal) -> Expr {
         super::union_extract().call(vec![arg1, arg2.lit()])
     }
diff --git a/datafusion/functions/src/crypto/basic.rs 
b/datafusion/functions/src/crypto/basic.rs
index 9b3c6fdbdb..f1b6c71763 100644
--- a/datafusion/functions/src/crypto/basic.rs
+++ b/datafusion/functions/src/crypto/basic.rs
@@ -259,11 +259,11 @@ impl DigestAlgorithm {
         let array = match value.data_type() {
             DataType::Binary | DataType::LargeBinary => {
                 let v = value.as_binary::<T>();
-                self.digest_binary_array_impl::<&GenericBinaryArray<T>>(v)
+                self.digest_binary_array_impl::<&GenericBinaryArray<T>>(&v)
             }
             DataType::BinaryView => {
                 let v = value.as_binary_view();
-                self.digest_binary_array_impl::<&BinaryViewArray>(v)
+                self.digest_binary_array_impl::<&BinaryViewArray>(&v)
             }
             other => {
                 return exec_err!("unsupported type for digest_utf_array: 
{other:?}")
@@ -280,11 +280,11 @@ impl DigestAlgorithm {
         let array = match value.data_type() {
             DataType::Utf8 | DataType::LargeUtf8 => {
                 let v = value.as_string::<T>();
-                self.digest_utf8_array_impl::<&GenericStringArray<T>>(v)
+                self.digest_utf8_array_impl::<&GenericStringArray<T>>(&v)
             }
             DataType::Utf8View => {
                 let v = value.as_string_view();
-                self.digest_utf8_array_impl::<&StringViewArray>(v)
+                self.digest_utf8_array_impl::<&StringViewArray>(&v)
             }
             other => {
                 return exec_err!("unsupported type for digest_utf_array: 
{other:?}")
@@ -295,7 +295,7 @@ impl DigestAlgorithm {
 
     pub fn digest_utf8_array_impl<'a, StringArrType>(
         self,
-        input_value: StringArrType,
+        input_value: &StringArrType,
     ) -> ArrayRef
     where
         StringArrType: StringArrayType<'a>,
@@ -326,7 +326,7 @@ impl DigestAlgorithm {
 
     pub fn digest_binary_array_impl<'a, BinaryArrType>(
         self,
-        input_value: BinaryArrType,
+        input_value: &BinaryArrType,
     ) -> ArrayRef
     where
         BinaryArrType: BinaryArrayType<'a>,
diff --git a/datafusion/functions/src/datetime/common.rs 
b/datafusion/functions/src/datetime/common.rs
index 90b92a7f88..a0daab66c7 100644
--- a/datafusion/functions/src/datetime/common.rs
+++ b/datafusion/functions/src/datetime/common.rs
@@ -190,19 +190,19 @@ where
         ColumnarValue::Array(a) => match a.data_type() {
             DataType::Utf8View => Ok(ColumnarValue::Array(Arc::new(
                 unary_string_to_primitive_function::<&StringViewArray, O, _>(
-                    a.as_ref().as_string_view(),
+                    &a.as_string_view(),
                     op,
                 )?,
             ))),
             DataType::LargeUtf8 => Ok(ColumnarValue::Array(Arc::new(
                 unary_string_to_primitive_function::<&GenericStringArray<i64>, 
O, _>(
-                    a.as_ref().as_string::<i64>(),
+                    &a.as_string::<i64>(),
                     op,
                 )?,
             ))),
             DataType::Utf8 => Ok(ColumnarValue::Array(Arc::new(
                 unary_string_to_primitive_function::<&GenericStringArray<i32>, 
O, _>(
-                    a.as_ref().as_string::<i32>(),
+                    &a.as_string::<i32>(),
                     op,
                 )?,
             ))),
@@ -431,7 +431,7 @@ where
 /// * the number of arguments is not 1 or
 /// * the function `op` errors
 fn unary_string_to_primitive_function<'a, StringArrType, O, F>(
-    array: StringArrType,
+    array: &StringArrType,
     op: F,
 ) -> Result<PrimitiveArray<O>>
 where
diff --git a/datafusion/functions/src/datetime/to_char.rs 
b/datafusion/functions/src/datetime/to_char.rs
index 7d9b2bc241..ed8090c9a2 100644
--- a/datafusion/functions/src/datetime/to_char.rs
+++ b/datafusion/functions/src/datetime/to_char.rs
@@ -144,13 +144,11 @@ impl ScalarUDFImpl for ToCharFunc {
 
         match format {
             ColumnarValue::Scalar(ScalarValue::Utf8(None))
-            | ColumnarValue::Scalar(ScalarValue::Null) => {
-                to_char_scalar(date_time.clone(), None)
-            }
+            | ColumnarValue::Scalar(ScalarValue::Null) => 
to_char_scalar(date_time, None),
             // constant format
             ColumnarValue::Scalar(ScalarValue::Utf8(Some(format))) => {
                 // invoke to_char_scalar with the known string, without 
converting to array
-                to_char_scalar(date_time.clone(), Some(format))
+                to_char_scalar(date_time, Some(format))
             }
             ColumnarValue::Array(_) => to_char_array(&args),
             _ => {
@@ -206,7 +204,7 @@ fn build_format_options<'a>(
 
 /// Special version when arg\[1] is a scalar
 fn to_char_scalar(
-    expression: ColumnarValue,
+    expression: &ColumnarValue,
     format: Option<&str>,
 ) -> Result<ColumnarValue> {
     // it's possible that the expression is a scalar however because
@@ -253,7 +251,7 @@ fn to_char_scalar(
         // if the data type was a Date32, formatting could have failed because 
the format string
         // contained datetime specifiers, so we'll retry by casting the date 
array as a timestamp array
         if data_type == &Date32 {
-            return to_char_scalar(expression.clone().cast_to(&Date64, None)?, 
format);
+            return to_char_scalar(&expression.cast_to(&Date64, None)?, format);
         }
 
         exec_err!("{}", formatted.unwrap_err())
@@ -292,7 +290,7 @@ fn to_char_array(args: &[ColumnarValue]) -> 
Result<ColumnarValue> {
                 if data_type == &Date32 {
                     let failed_date_value = arrays[0].slice(idx, 1);
 
-                    match retry_date_as_timestamp(failed_date_value, 
&format_options) {
+                    match retry_date_as_timestamp(&failed_date_value, 
&format_options) {
                         Ok(value) => {
                             results.push(Some(value));
                             continue;
@@ -322,7 +320,7 @@ fn to_char_array(args: &[ColumnarValue]) -> 
Result<ColumnarValue> {
 }
 
 fn retry_date_as_timestamp(
-    array_ref: ArrayRef,
+    array_ref: &ArrayRef,
     format_options: &FormatOptions,
 ) -> Result<String> {
     let target_data_type = Date64;
diff --git a/datafusion/functions/src/lib.rs b/datafusion/functions/src/lib.rs
index 7eb32b7ed7..252914026b 100644
--- a/datafusion/functions/src/lib.rs
+++ b/datafusion/functions/src/lib.rs
@@ -23,6 +23,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))]
 
 //! Function packages for [DataFusion].
 //!
diff --git a/datafusion/functions/src/regex/regexpcount.rs 
b/datafusion/functions/src/regex/regexpcount.rs
index 8bad506217..e61b3f764d 100644
--- a/datafusion/functions/src/regex/regexpcount.rs
+++ b/datafusion/functions/src/regex/regexpcount.rs
@@ -201,8 +201,8 @@ pub fn regexp_count(
 
     match (values.data_type(), regex_array.data_type(), flags_array) {
         (Utf8, Utf8, None) => regexp_count_inner(
-            values.as_string::<i32>(),
-            regex_array.as_string::<i32>(),
+            &values.as_string::<i32>(),
+            &regex_array.as_string::<i32>(),
             is_regex_scalar,
             start_array.map(|start| start.as_primitive::<Int64Type>()),
             is_start_scalar,
@@ -210,17 +210,17 @@ pub fn regexp_count(
             is_flags_scalar,
         ),
         (Utf8, Utf8, Some(flags_array)) if *flags_array.data_type() == Utf8 => 
regexp_count_inner(
-            values.as_string::<i32>(),
-            regex_array.as_string::<i32>(),
+            &values.as_string::<i32>(),
+            &regex_array.as_string::<i32>(),
             is_regex_scalar,
             start_array.map(|start| start.as_primitive::<Int64Type>()),
             is_start_scalar,
-            Some(flags_array.as_string::<i32>()),
+            Some(&flags_array.as_string::<i32>()),
             is_flags_scalar,
         ),
         (LargeUtf8, LargeUtf8, None) => regexp_count_inner(
-            values.as_string::<i64>(),
-            regex_array.as_string::<i64>(),
+            &values.as_string::<i64>(),
+            &regex_array.as_string::<i64>(),
             is_regex_scalar,
             start_array.map(|start| start.as_primitive::<Int64Type>()),
             is_start_scalar,
@@ -228,17 +228,17 @@ pub fn regexp_count(
             is_flags_scalar,
         ),
         (LargeUtf8, LargeUtf8, Some(flags_array)) if *flags_array.data_type() 
== LargeUtf8 => regexp_count_inner(
-            values.as_string::<i64>(),
-            regex_array.as_string::<i64>(),
+            &values.as_string::<i64>(),
+            &regex_array.as_string::<i64>(),
             is_regex_scalar,
             start_array.map(|start| start.as_primitive::<Int64Type>()),
             is_start_scalar,
-            Some(flags_array.as_string::<i64>()),
+            Some(&flags_array.as_string::<i64>()),
             is_flags_scalar,
         ),
         (Utf8View, Utf8View, None) => regexp_count_inner(
-            values.as_string_view(),
-            regex_array.as_string_view(),
+            &values.as_string_view(),
+            &regex_array.as_string_view(),
             is_regex_scalar,
             start_array.map(|start| start.as_primitive::<Int64Type>()),
             is_start_scalar,
@@ -246,12 +246,12 @@ pub fn regexp_count(
             is_flags_scalar,
         ),
         (Utf8View, Utf8View, Some(flags_array)) if *flags_array.data_type() == 
Utf8View => regexp_count_inner(
-            values.as_string_view(),
-            regex_array.as_string_view(),
+            &values.as_string_view(),
+            &regex_array.as_string_view(),
             is_regex_scalar,
             start_array.map(|start| start.as_primitive::<Int64Type>()),
             is_start_scalar,
-            Some(flags_array.as_string_view()),
+            Some(&flags_array.as_string_view()),
             is_flags_scalar,
         ),
         _ => Err(ArrowError::ComputeError(
@@ -260,13 +260,13 @@ pub fn regexp_count(
     }
 }
 
-pub fn regexp_count_inner<'a, S>(
-    values: S,
-    regex_array: S,
+fn regexp_count_inner<'a, S>(
+    values: &S,
+    regex_array: &S,
     is_regex_scalar: bool,
     start_array: Option<&Int64Array>,
     is_start_scalar: bool,
-    flags_array: Option<S>,
+    flags_array: Option<&S>,
     is_flags_scalar: bool,
 ) -> Result<ArrayRef, ArrowError>
 where
diff --git a/datafusion/functions/src/regex/regexpinstr.rs 
b/datafusion/functions/src/regex/regexpinstr.rs
index 851c182a90..10fddda1a3 100644
--- a/datafusion/functions/src/regex/regexpinstr.rs
+++ b/datafusion/functions/src/regex/regexpinstr.rs
@@ -287,6 +287,7 @@ pub fn regexp_instr(
 }
 
 #[allow(clippy::too_many_arguments)]
+#[expect(clippy::needless_pass_by_value)]
 pub fn regexp_instr_inner<'a, S>(
     values: S,
     regex_array: S,
diff --git a/datafusion/functions/src/regex/regexpreplace.rs 
b/datafusion/functions/src/regex/regexpreplace.rs
index ca3d19822e..f986642713 100644
--- a/datafusion/functions/src/regex/regexpreplace.rs
+++ b/datafusion/functions/src/regex/regexpreplace.rs
@@ -382,6 +382,7 @@ where
     }
 }
 
+#[expect(clippy::needless_pass_by_value)]
 fn _regexp_replace_early_abort<T: ArrayAccessor>(
     input_array: T,
     sz: usize,
diff --git a/datafusion/functions/src/string/ascii.rs 
b/datafusion/functions/src/string/ascii.rs
index bdf3083312..8b55f8fb8f 100644
--- a/datafusion/functions/src/string/ascii.rs
+++ b/datafusion/functions/src/string/ascii.rs
@@ -99,7 +99,7 @@ impl ScalarUDFImpl for AsciiFunc {
     }
 }
 
-fn calculate_ascii<'a, V>(array: V) -> Result<ArrayRef, ArrowError>
+fn calculate_ascii<'a, V>(array: &V) -> Result<ArrayRef, ArrowError>
 where
     V: StringArrayType<'a, Item = &'a str>,
 {
@@ -124,15 +124,15 @@ pub fn ascii(args: &[ArrayRef]) -> Result<ArrayRef> {
     match args[0].data_type() {
         DataType::Utf8 => {
             let string_array = args[0].as_string::<i32>();
-            Ok(calculate_ascii(string_array)?)
+            Ok(calculate_ascii(&string_array)?)
         }
         DataType::LargeUtf8 => {
             let string_array = args[0].as_string::<i64>();
-            Ok(calculate_ascii(string_array)?)
+            Ok(calculate_ascii(&string_array)?)
         }
         DataType::Utf8View => {
             let string_array = args[0].as_string_view();
-            Ok(calculate_ascii(string_array)?)
+            Ok(calculate_ascii(&string_array)?)
         }
         _ => internal_err!("Unsupported data type"),
     }
diff --git a/datafusion/functions/src/string/common.rs 
b/datafusion/functions/src/string/common.rs
index 5e0567eafe..6bce289edb 100644
--- a/datafusion/functions/src/string/common.rs
+++ b/datafusion/functions/src/string/common.rs
@@ -48,6 +48,7 @@ impl Display for TrimType {
     }
 }
 
+#[expect(clippy::needless_pass_by_value)]
 pub(crate) fn general_trim<T: OffsetSizeTrait>(
     args: &[ArrayRef],
     trim_type: TrimType,
diff --git a/datafusion/functions/src/string/repeat.rs 
b/datafusion/functions/src/string/repeat.rs
index 3f6128b651..1fc62d747d 100644
--- a/datafusion/functions/src/string/repeat.rs
+++ b/datafusion/functions/src/string/repeat.rs
@@ -115,7 +115,7 @@ fn repeat(args: &[ArrayRef]) -> Result<ArrayRef> {
         Utf8View => {
             let string_view_array = args[0].as_string_view();
             repeat_impl::<i32, &StringViewArray>(
-                string_view_array,
+                &string_view_array,
                 number_array,
                 i32::MAX as usize,
             )
@@ -123,7 +123,7 @@ fn repeat(args: &[ArrayRef]) -> Result<ArrayRef> {
         Utf8 => {
             let string_array = args[0].as_string::<i32>();
             repeat_impl::<i32, &GenericStringArray<i32>>(
-                string_array,
+                &string_array,
                 number_array,
                 i32::MAX as usize,
             )
@@ -131,7 +131,7 @@ fn repeat(args: &[ArrayRef]) -> Result<ArrayRef> {
         LargeUtf8 => {
             let string_array = args[0].as_string::<i64>();
             repeat_impl::<i64, &GenericStringArray<i64>>(
-                string_array,
+                &string_array,
                 number_array,
                 i64::MAX as usize,
             )
@@ -144,7 +144,7 @@ fn repeat(args: &[ArrayRef]) -> Result<ArrayRef> {
 }
 
 fn repeat_impl<'a, T, S>(
-    string_array: S,
+    string_array: &S,
     number_array: &Int64Array,
     max_str_len: usize,
 ) -> Result<ArrayRef>
diff --git a/datafusion/functions/src/string/split_part.rs 
b/datafusion/functions/src/string/split_part.rs
index 8462dd5149..b32eba990d 100644
--- a/datafusion/functions/src/string/split_part.rs
+++ b/datafusion/functions/src/string/split_part.rs
@@ -201,6 +201,7 @@ impl ScalarUDFImpl for SplitPartFunc {
 }
 
 /// impl
+#[expect(clippy::needless_pass_by_value)]
 pub fn split_part_impl<'a, StringArrType, DelimiterArrType, StringArrayLen>(
     string_array: StringArrType,
     delimiter_array: DelimiterArrType,
diff --git a/datafusion/functions/src/unicode/character_length.rs 
b/datafusion/functions/src/unicode/character_length.rs
index 85fe0956a9..a97bf9710e 100644
--- a/datafusion/functions/src/unicode/character_length.rs
+++ b/datafusion/functions/src/unicode/character_length.rs
@@ -111,21 +111,21 @@ fn character_length(args: &[ArrayRef]) -> 
Result<ArrayRef> {
     match args[0].data_type() {
         DataType::Utf8 => {
             let string_array = args[0].as_string::<i32>();
-            character_length_general::<Int32Type, _>(string_array)
+            character_length_general::<Int32Type, _>(&string_array)
         }
         DataType::LargeUtf8 => {
             let string_array = args[0].as_string::<i64>();
-            character_length_general::<Int64Type, _>(string_array)
+            character_length_general::<Int64Type, _>(&string_array)
         }
         DataType::Utf8View => {
             let string_array = args[0].as_string_view();
-            character_length_general::<Int32Type, _>(string_array)
+            character_length_general::<Int32Type, _>(&string_array)
         }
         _ => unreachable!("CharacterLengthFunc"),
     }
 }
 
-fn character_length_general<'a, T, V>(array: V) -> Result<ArrayRef>
+fn character_length_general<'a, T, V>(array: &V) -> Result<ArrayRef>
 where
     T: ArrowPrimitiveType,
     T::Native: OffsetSizeTrait,
diff --git a/datafusion/functions/src/unicode/find_in_set.rs 
b/datafusion/functions/src/unicode/find_in_set.rs
index fa68e53960..649bd631d1 100644
--- a/datafusion/functions/src/unicode/find_in_set.rs
+++ b/datafusion/functions/src/unicode/find_in_set.rs
@@ -149,21 +149,21 @@ impl ScalarUDFImpl for FindInSetFunc {
                                 let string_array = 
str_array.as_string::<i32>();
                                 find_in_set_right_literal::<Int32Type, _>(
                                     string_array,
-                                    str_list,
+                                    &str_list,
                                 )
                             }
                             DataType::LargeUtf8 => {
                                 let string_array = 
str_array.as_string::<i64>();
                                 find_in_set_right_literal::<Int64Type, _>(
                                     string_array,
-                                    str_list,
+                                    &str_list,
                                 )
                             }
                             DataType::Utf8View => {
                                 let string_array = str_array.as_string_view();
                                 find_in_set_right_literal::<Int32Type, _>(
                                     string_array,
-                                    str_list,
+                                    &str_list,
                                 )
                             }
                             other => {
@@ -194,15 +194,21 @@ impl ScalarUDFImpl for FindInSetFunc {
                         let result = match str_list_array.data_type() {
                             DataType::Utf8 => {
                                 let str_list = 
str_list_array.as_string::<i32>();
-                                find_in_set_left_literal::<Int32Type, 
_>(string, str_list)
+                                find_in_set_left_literal::<Int32Type, _>(
+                                    &string, str_list,
+                                )
                             }
                             DataType::LargeUtf8 => {
                                 let str_list = 
str_list_array.as_string::<i64>();
-                                find_in_set_left_literal::<Int64Type, 
_>(string, str_list)
+                                find_in_set_left_literal::<Int64Type, _>(
+                                    &string, str_list,
+                                )
                             }
                             DataType::Utf8View => {
                                 let str_list = str_list_array.as_string_view();
-                                find_in_set_left_literal::<Int32Type, 
_>(string, str_list)
+                                find_in_set_left_literal::<Int32Type, _>(
+                                    &string, str_list,
+                                )
                             }
                             other => {
                                 exec_err!("Unsupported data type {other:?} for 
function find_in_set")
@@ -216,7 +222,7 @@ impl ScalarUDFImpl for FindInSetFunc {
 
             // both inputs are arrays
             (ColumnarValue::Array(base_array), 
ColumnarValue::Array(exp_array)) => {
-                let res = find_in_set(base_array, exp_array)?;
+                let res = find_in_set(&base_array, &exp_array)?;
 
                 Ok(ColumnarValue::Array(res))
             }
@@ -234,7 +240,7 @@ impl ScalarUDFImpl for FindInSetFunc {
 /// Returns a value in the range of 1 to N if the string `str` is in the 
string list `strlist`
 /// consisting of N substrings. A string list is a string composed of 
substrings separated by `,`
 /// characters.
-fn find_in_set(str: ArrayRef, str_list: ArrayRef) -> Result<ArrayRef> {
+fn find_in_set(str: &ArrayRef, str_list: &ArrayRef) -> Result<ArrayRef> {
     match str.data_type() {
         DataType::Utf8 => {
             let string_array = str.as_string::<i32>();
@@ -289,10 +295,7 @@ where
     Ok(Arc::new(builder.finish()) as ArrayRef)
 }
 
-fn find_in_set_left_literal<'a, T, V>(
-    string: String,
-    str_list_array: V,
-) -> Result<ArrayRef>
+fn find_in_set_left_literal<'a, T, V>(string: &str, str_list_array: V) -> 
Result<ArrayRef>
 where
     T: ArrowPrimitiveType,
     T::Native: OffsetSizeTrait,
@@ -318,7 +321,7 @@ where
 
 fn find_in_set_right_literal<'a, T, V>(
     string_array: V,
-    str_list: Vec<&str>,
+    str_list: &[&str],
 ) -> Result<ArrayRef>
 where
     T: ArrowPrimitiveType,
diff --git a/datafusion/functions/src/unicode/lpad.rs 
b/datafusion/functions/src/unicode/lpad.rs
index 621dbd4970..b69af247b9 100644
--- a/datafusion/functions/src/unicode/lpad.rs
+++ b/datafusion/functions/src/unicode/lpad.rs
@@ -141,7 +141,7 @@ pub fn lpad<T: OffsetSizeTrait>(args: &[ArrayRef]) -> 
Result<ArrayRef> {
 
     match (args.len(), args[0].data_type()) {
         (2, Utf8View) => lpad_impl::<&StringViewArray, 
&GenericStringArray<i32>, T>(
-            args[0].as_string_view(),
+            &args[0].as_string_view(),
             length_array,
             None,
         ),
@@ -149,14 +149,14 @@ pub fn lpad<T: OffsetSizeTrait>(args: &[ArrayRef]) -> 
Result<ArrayRef> {
             &GenericStringArray<T>,
             &GenericStringArray<T>,
             T,
-        >(args[0].as_string::<T>(), length_array, None),
+        >(&args[0].as_string::<T>(), length_array, None),
         (3, Utf8View) => lpad_with_replace::<&StringViewArray, T>(
-            args[0].as_string_view(),
+            &args[0].as_string_view(),
             length_array,
             &args[2],
         ),
         (3, Utf8 | LargeUtf8) => lpad_with_replace::<&GenericStringArray<T>, 
T>(
-            args[0].as_string::<T>(),
+            &args[0].as_string::<T>(),
             length_array,
             &args[2],
         ),
@@ -165,7 +165,7 @@ pub fn lpad<T: OffsetSizeTrait>(args: &[ArrayRef]) -> 
Result<ArrayRef> {
 }
 
 fn lpad_with_replace<'a, V, T: OffsetSizeTrait>(
-    string_array: V,
+    string_array: &V,
     length_array: &Int64Array,
     fill_array: &'a ArrayRef,
 ) -> Result<ArrayRef>
@@ -195,7 +195,7 @@ where
 }
 
 fn lpad_impl<'a, V, V2, T>(
-    string_array: V,
+    string_array: &V,
     length_array: &Int64Array,
     fill_array: Option<V2>,
 ) -> Result<ArrayRef>
diff --git a/datafusion/functions/src/unicode/reverse.rs 
b/datafusion/functions/src/unicode/reverse.rs
index 500e762ec2..b5f870d54b 100644
--- a/datafusion/functions/src/unicode/reverse.rs
+++ b/datafusion/functions/src/unicode/reverse.rs
@@ -108,14 +108,14 @@ impl ScalarUDFImpl for ReverseFunc {
 /// The implementation uses UTF-8 code points as characters
 pub fn reverse<T: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef> {
     if args[0].data_type() == &Utf8View {
-        reverse_impl::<T, _>(args[0].as_string_view())
+        reverse_impl::<T, _>(&args[0].as_string_view())
     } else {
-        reverse_impl::<T, _>(args[0].as_string::<T>())
+        reverse_impl::<T, _>(&args[0].as_string::<T>())
     }
 }
 
 fn reverse_impl<'a, T: OffsetSizeTrait, V: StringArrayType<'a>>(
-    string_array: V,
+    string_array: &V,
 ) -> Result<ArrayRef> {
     let mut builder = 
GenericStringBuilder::<T>::with_capacity(string_array.len(), 1024);
 
diff --git a/datafusion/functions/src/unicode/rpad.rs 
b/datafusion/functions/src/unicode/rpad.rs
index 6ec78b0798..d644df9874 100644
--- a/datafusion/functions/src/unicode/rpad.rs
+++ b/datafusion/functions/src/unicode/rpad.rs
@@ -163,21 +163,21 @@ pub fn rpad<StringArrayLen: OffsetSizeTrait, 
FillArrayLen: OffsetSizeTrait>(
     ) {
         (2, Utf8View, _) => {
             rpad_impl::<&StringViewArray, &StringViewArray, StringArrayLen>(
-                args[0].as_string_view(),
+                &args[0].as_string_view(),
                 length_array,
                 None,
             )
         }
         (3, Utf8View, Some(Utf8View)) => {
             rpad_impl::<&StringViewArray, &StringViewArray, StringArrayLen>(
-                args[0].as_string_view(),
+                &args[0].as_string_view(),
                 length_array,
                 Some(args[2].as_string_view()),
             )
         }
         (3, Utf8View, Some(Utf8 | LargeUtf8)) => {
             rpad_impl::<&StringViewArray, &GenericStringArray<FillArrayLen>, 
StringArrayLen>(
-                args[0].as_string_view(),
+                &args[0].as_string_view(),
                 length_array,
                 Some(args[2].as_string::<FillArrayLen>()),
             )
@@ -187,7 +187,7 @@ pub fn rpad<StringArrayLen: OffsetSizeTrait, FillArrayLen: 
OffsetSizeTrait>(
             &StringViewArray,
             StringArrayLen,
         >(
-            args[0].as_string::<StringArrayLen>(),
+            &args[0].as_string::<StringArrayLen>(),
             length_array,
             Some(args[2].as_string_view()),
         ),
@@ -196,7 +196,7 @@ pub fn rpad<StringArrayLen: OffsetSizeTrait, FillArrayLen: 
OffsetSizeTrait>(
             &GenericStringArray<FillArrayLen>,
             StringArrayLen,
         >(
-            args[0].as_string::<StringArrayLen>(),
+            &args[0].as_string::<StringArrayLen>(),
             length_array,
             args.get(2).map(|arg| arg.as_string::<FillArrayLen>()),
         ),
@@ -206,7 +206,7 @@ pub fn rpad<StringArrayLen: OffsetSizeTrait, FillArrayLen: 
OffsetSizeTrait>(
 /// Extends the string to length 'length' by appending the characters fill (a 
space by default). If the string is already longer than length then it is 
truncated.
 /// rpad('hi', 5, 'xy') = 'hixyx'
 pub fn rpad_impl<'a, StringArrType, FillArrType, StringArrayLen>(
-    string_array: StringArrType,
+    string_array: &StringArrType,
     length_array: &Int64Array,
     fill_array: Option<FillArrType>,
 ) -> Result<ArrayRef>
diff --git a/datafusion/functions/src/unicode/strpos.rs 
b/datafusion/functions/src/unicode/strpos.rs
index 4f238b2644..294f783ba6 100644
--- a/datafusion/functions/src/unicode/strpos.rs
+++ b/datafusion/functions/src/unicode/strpos.rs
@@ -130,47 +130,47 @@ fn strpos(args: &[ArrayRef]) -> Result<ArrayRef> {
         (DataType::Utf8, DataType::Utf8) => {
             let string_array = args[0].as_string::<i32>();
             let substring_array = args[1].as_string::<i32>();
-            calculate_strpos::<_, _, Int32Type>(string_array, substring_array)
+            calculate_strpos::<_, _, Int32Type>(&string_array, 
&substring_array)
         }
         (DataType::Utf8, DataType::Utf8View) => {
             let string_array = args[0].as_string::<i32>();
             let substring_array = args[1].as_string_view();
-            calculate_strpos::<_, _, Int32Type>(string_array, substring_array)
+            calculate_strpos::<_, _, Int32Type>(&string_array, 
&substring_array)
         }
         (DataType::Utf8, DataType::LargeUtf8) => {
             let string_array = args[0].as_string::<i32>();
             let substring_array = args[1].as_string::<i64>();
-            calculate_strpos::<_, _, Int32Type>(string_array, substring_array)
+            calculate_strpos::<_, _, Int32Type>(&string_array, 
&substring_array)
         }
         (DataType::LargeUtf8, DataType::Utf8) => {
             let string_array = args[0].as_string::<i64>();
             let substring_array = args[1].as_string::<i32>();
-            calculate_strpos::<_, _, Int64Type>(string_array, substring_array)
+            calculate_strpos::<_, _, Int64Type>(&string_array, 
&substring_array)
         }
         (DataType::LargeUtf8, DataType::Utf8View) => {
             let string_array = args[0].as_string::<i64>();
             let substring_array = args[1].as_string_view();
-            calculate_strpos::<_, _, Int64Type>(string_array, substring_array)
+            calculate_strpos::<_, _, Int64Type>(&string_array, 
&substring_array)
         }
         (DataType::LargeUtf8, DataType::LargeUtf8) => {
             let string_array = args[0].as_string::<i64>();
             let substring_array = args[1].as_string::<i64>();
-            calculate_strpos::<_, _, Int64Type>(string_array, substring_array)
+            calculate_strpos::<_, _, Int64Type>(&string_array, 
&substring_array)
         }
         (DataType::Utf8View, DataType::Utf8View) => {
             let string_array = args[0].as_string_view();
             let substring_array = args[1].as_string_view();
-            calculate_strpos::<_, _, Int32Type>(string_array, substring_array)
+            calculate_strpos::<_, _, Int32Type>(&string_array, 
&substring_array)
         }
         (DataType::Utf8View, DataType::Utf8) => {
             let string_array = args[0].as_string_view();
             let substring_array = args[1].as_string::<i32>();
-            calculate_strpos::<_, _, Int32Type>(string_array, substring_array)
+            calculate_strpos::<_, _, Int32Type>(&string_array, 
&substring_array)
         }
         (DataType::Utf8View, DataType::LargeUtf8) => {
             let string_array = args[0].as_string_view();
             let substring_array = args[1].as_string::<i64>();
-            calculate_strpos::<_, _, Int32Type>(string_array, substring_array)
+            calculate_strpos::<_, _, Int32Type>(&string_array, 
&substring_array)
         }
 
         other => {
@@ -183,8 +183,8 @@ fn strpos(args: &[ArrayRef]) -> Result<ArrayRef> {
 /// strpos('high', 'ig') = 2
 /// The implementation uses UTF-8 code points as characters
 fn calculate_strpos<'a, V1, V2, T: ArrowPrimitiveType>(
-    string_array: V1,
-    substring_array: V2,
+    string_array: &V1,
+    substring_array: &V2,
 ) -> Result<ArrayRef>
 where
     V1: StringArrayType<'a, Item = &'a str>,


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


Reply via email to