You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "Standing-Man (via GitHub)" <gi...@apache.org> on 2025/11/17 12:19:28 UTC

[PR] minor: enforce lint rule clippy::needless_pass_by_value to datafusion-functions [datafusion]

Standing-Man opened a new pull request, #18768:
URL: https://github.com/apache/datafusion/pull/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.
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] minor: enforce lint rule clippy::needless_pass_by_value to datafusion-functions [datafusion]

Posted by "Standing-Man (via GitHub)" <gi...@apache.org>.
Standing-Man commented on code in PR #18768:
URL: https://github.com/apache/datafusion/pull/18768#discussion_r2541004958


##########
datafusion/functions/src/regex/regexpcount.rs:
##########
@@ -260,6 +260,7 @@ pub fn regexp_count(
     }
 }
 
+#[expect(clippy::needless_pass_by_value)]
 pub fn regexp_count_inner<'a, S>(

Review Comment:
   Right, I’ve reduced the visibility of the public functions.👍🏻 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] minor: enforce lint rule clippy::needless_pass_by_value to datafusion-functions [datafusion]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on code in PR #18768:
URL: https://github.com/apache/datafusion/pull/18768#discussion_r2551641847


##########
datafusion/functions/src/crypto/basic.rs:
##########
@@ -295,7 +295,7 @@ impl DigestAlgorithm {
 
     pub fn digest_utf8_array_impl<'a, StringArrType>(
         self,
-        input_value: StringArrType,
+        input_value: &StringArrType,

Review Comment:
   I guess we'll just go along with this; for reference: https://github.com/apache/datafusion/pull/18839#discussion_r2550425593



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] minor: enforce lint rule clippy::needless_pass_by_value to datafusion-functions [datafusion]

Posted by "Standing-Man (via GitHub)" <gi...@apache.org>.
Standing-Man commented on code in PR #18768:
URL: https://github.com/apache/datafusion/pull/18768#discussion_r2544308526


##########
datafusion/functions/src/core/greatest_least_utils.rs:
##########
@@ -38,8 +38,8 @@ pub(super) trait GreatestLeastOperator {
 }
 
 fn keep_array<Op: GreatestLeastOperator>(
-    lhs: ArrayRef,
-    rhs: ArrayRef,
+    lhs: &ArrayRef,
+    rhs: &ArrayRef,

Review Comment:
   Thanks for pointing it out!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] minor: enforce lint rule clippy::needless_pass_by_value to datafusion-functions [datafusion]

Posted by "Standing-Man (via GitHub)" <gi...@apache.org>.
Standing-Man commented on code in PR #18768:
URL: https://github.com/apache/datafusion/pull/18768#discussion_r2548433289


##########
datafusion/functions/src/crypto/basic.rs:
##########
@@ -295,7 +295,7 @@ impl DigestAlgorithm {
 
     pub fn digest_utf8_array_impl<'a, StringArrType>(
         self,
-        input_value: StringArrType,
+        input_value: &StringArrType,

Review Comment:
   Yes, but Clippy warns that `input_value` is not consumed in the function body, suggesting we take a reference instead. Therefore, the parameter of `digest_utf8_array_impl` needs to be a double reference (&&).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] minor: enforce lint rule clippy::needless_pass_by_value to datafusion-functions [datafusion]

Posted by "Standing-Man (via GitHub)" <gi...@apache.org>.
Standing-Man commented on code in PR #18768:
URL: https://github.com/apache/datafusion/pull/18768#discussion_r2540975640


##########
datafusion/functions/src/core/greatest_least_utils.rs:
##########
@@ -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())?,
+            &Arc::clone(first_array),

Review Comment:
   Thank you for the suggestion. I’ve reduced unnecessary cloning in the new commit.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] minor: enforce lint rule clippy::needless_pass_by_value to datafusion-functions [datafusion]

Posted by "Standing-Man (via GitHub)" <gi...@apache.org>.
Standing-Man commented on PR #18768:
URL: https://github.com/apache/datafusion/pull/18768#issuecomment-3565886768

   Thanks @Jefffrey for taking the time to review this PR!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] minor: enforce lint rule clippy::needless_pass_by_value to datafusion-functions [datafusion]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey merged PR #18768:
URL: https://github.com/apache/datafusion/pull/18768


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] minor: enforce lint rule clippy::needless_pass_by_value to datafusion-functions [datafusion]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on code in PR #18768:
URL: https://github.com/apache/datafusion/pull/18768#discussion_r2533923114


##########
datafusion/functions/src/core/greatest_least_utils.rs:
##########
@@ -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())?,
+            &Arc::clone(first_array),

Review Comment:
   We should be carefully reviewing the changes made to see if they make sense; in this case, passing the reference of an `Arc` we just cloned makes little sense. Consider removing the clone.



##########
datafusion/functions/src/crypto/basic.rs:
##########
@@ -295,7 +295,7 @@ impl DigestAlgorithm {
 
     pub fn digest_utf8_array_impl<'a, StringArrType>(
         self,
-        input_value: StringArrType,
+        input_value: &StringArrType,

Review Comment:
   This change seems odd; `input_value` should already be a reference I believe?



##########
datafusion/functions/src/core/getfield.rs:
##########
@@ -197,7 +197,7 @@ impl ScalarUDFImpl for GetFieldFunc {
         };
 
         fn process_map_array(
-            array: Arc<dyn Array>,
+            array: &Arc<dyn Array>,

Review Comment:
   Perhaps its better to pass `&dyn Array`?



##########
datafusion/functions/src/datetime/to_char.rs:
##########
@@ -145,12 +145,12 @@ impl ScalarUDFImpl for ToCharFunc {
         match format {
             ColumnarValue::Scalar(ScalarValue::Utf8(None))
             | ColumnarValue::Scalar(ScalarValue::Null) => {
-                to_char_scalar(date_time.clone(), None)
+                to_char_scalar(&date_time.clone(), None)

Review Comment:
   Another example of needless cloning; there's other occurrences in this PR



##########
datafusion/functions/src/regex/regexpcount.rs:
##########
@@ -260,6 +260,7 @@ pub fn regexp_count(
     }
 }
 
+#[expect(clippy::needless_pass_by_value)]
 pub fn regexp_count_inner<'a, S>(

Review Comment:
   Honestly I'm not sure this is meant to be a public function anyway



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] minor: enforce lint rule clippy::needless_pass_by_value to datafusion-functions [datafusion]

Posted by "Standing-Man (via GitHub)" <gi...@apache.org>.
Standing-Man commented on code in PR #18768:
URL: https://github.com/apache/datafusion/pull/18768#discussion_r2544316881


##########
datafusion/functions/src/crypto/basic.rs:
##########
@@ -295,7 +295,7 @@ impl DigestAlgorithm {
 
     pub fn digest_utf8_array_impl<'a, StringArrType>(
         self,
-        input_value: StringArrType,
+        input_value: &StringArrType,

Review Comment:
   You mean to keep the function definition like this:
   ```
   pub fn digest_utf8_array_impl<'a, StringArrType>(
       self, 
       input_value: StringArrType,
   ) -> ArrayRef 
   where
       StringArrType: StringArrayType<'a>,
   { ... }
   ```
   and then call it like this:
   ```
   self.digest_utf8_array_impl::<&GenericStringArray<T>>(&v)
   ```
   …but the Rust compiler still complains and doesn’t accept it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] minor: enforce lint rule clippy::needless_pass_by_value to datafusion-functions [datafusion]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on code in PR #18768:
URL: https://github.com/apache/datafusion/pull/18768#discussion_r2548326233


##########
datafusion/functions/src/crypto/basic.rs:
##########
@@ -295,7 +295,7 @@ impl DigestAlgorithm {
 
     pub fn digest_utf8_array_impl<'a, StringArrType>(
         self,
-        input_value: StringArrType,
+        input_value: &StringArrType,

Review Comment:
   My point is this might be a false positive by clippy because if we look here for example:
   
   https://github.com/apache/datafusion/blob/f1ecaccd183367086ecb5b7736d93b3aba109e01/datafusion/functions/src/crypto/basic.rs#L260-L263
   
   `v` is already of type `&GenericBinaryArray<T>`; it is already a reference 🤔 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] minor: enforce lint rule clippy::needless_pass_by_value to datafusion-functions [datafusion]

Posted by "Standing-Man (via GitHub)" <gi...@apache.org>.
Standing-Man commented on code in PR #18768:
URL: https://github.com/apache/datafusion/pull/18768#discussion_r2544307818


##########
datafusion/functions/src/core/getfield.rs:
##########
@@ -246,10 +246,10 @@ impl ScalarUDFImpl for GetFieldFunc {
         }
 
         fn process_map_with_nested_key(
-            array: Arc<dyn Array>,
-            key_array: Arc<dyn Array>,
+            array: &dyn Array,
+            key_array: &Arc<dyn Array>,

Review Comment:
   Got it, I’ve fixed the issue now. Thanks for pointing it out!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] minor: enforce lint rule clippy::needless_pass_by_value to datafusion-functions [datafusion]

Posted by "Standing-Man (via GitHub)" <gi...@apache.org>.
Standing-Man commented on code in PR #18768:
URL: https://github.com/apache/datafusion/pull/18768#discussion_r2540972046


##########
datafusion/functions/src/core/getfield.rs:
##########
@@ -197,7 +197,7 @@ impl ScalarUDFImpl for GetFieldFunc {
         };
 
         fn process_map_array(
-            array: Arc<dyn Array>,
+            array: &Arc<dyn Array>,

Review Comment:
   yep, it makes sense.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] minor: enforce lint rule clippy::needless_pass_by_value to datafusion-functions [datafusion]

Posted by "Standing-Man (via GitHub)" <gi...@apache.org>.
Standing-Man commented on code in PR #18768:
URL: https://github.com/apache/datafusion/pull/18768#discussion_r2541011582


##########
datafusion/functions/src/crypto/basic.rs:
##########
@@ -295,7 +295,7 @@ impl DigestAlgorithm {
 
     pub fn digest_utf8_array_impl<'a, StringArrType>(
         self,
-        input_value: StringArrType,
+        input_value: &StringArrType,

Review Comment:
   No, `StringArrType` is just a trait. `input_value` isn’t automatically a reference—we need to explicitly borrow it when required.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] minor: enforce lint rule clippy::needless_pass_by_value to datafusion-functions [datafusion]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on code in PR #18768:
URL: https://github.com/apache/datafusion/pull/18768#discussion_r2544125824


##########
datafusion/functions/src/crypto/basic.rs:
##########
@@ -295,7 +295,7 @@ impl DigestAlgorithm {
 
     pub fn digest_utf8_array_impl<'a, StringArrType>(
         self,
-        input_value: StringArrType,
+        input_value: &StringArrType,

Review Comment:
   But if we look at `StringArrayType` it is implemented for references:
   
   https://docs.rs/arrow/latest/arrow/array/trait.StringArrayType.html



##########
datafusion/functions/src/core/greatest_least_utils.rs:
##########
@@ -38,8 +38,8 @@ pub(super) trait GreatestLeastOperator {
 }
 
 fn keep_array<Op: GreatestLeastOperator>(
-    lhs: ArrayRef,
-    rhs: ArrayRef,
+    lhs: &ArrayRef,
+    rhs: &ArrayRef,

Review Comment:
   `&ArrayRef` can also be simplified to `&dyn Array` I believe?



##########
datafusion/functions/src/core/getfield.rs:
##########
@@ -246,10 +246,10 @@ impl ScalarUDFImpl for GetFieldFunc {
         }
 
         fn process_map_with_nested_key(
-            array: Arc<dyn Array>,
-            key_array: Arc<dyn Array>,
+            array: &dyn Array,
+            key_array: &Arc<dyn Array>,

Review Comment:
   Key can also be made dyn?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org