You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2025/03/17 20:33:13 UTC

[PR] Minor: consistently apply `clippy::clone_on_ref_ptr` in all crates [datafusion]

alamb opened a new pull request, #15284:
URL: https://github.com/apache/datafusion/pull/15284

   ## Which issue does this PR close?
   
   
   ## Rationale for this change
   
   - Found while reviewing https://github.com/apache/datafusion/pull/15263 from @adriangb 
   
   Some of the newer DataFusion crates don't have the `clippy::clone_on_ref_ptr` lint enabled. This lint is present to make it clear when `clone()` is very cheap (because it is on an Arc rather than some structure that requires deep copying
   
   ## What changes are included in this PR?
   1. Enable the lint in other crates
   2. Update a few places to get it to pass
   
   Here is an example of the lint enabled in the core crate https://github.com/apache/datafusion/blob/5224194944960c539f637991b22912bb8f61698e/datafusion/core/src/lib.rs#L24
   
   ## Are these changes tested?
   
   By CI
   
   ## Are there any user-facing changes?
   No
   <!--
   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: consistently apply `clippy::clone_on_ref_ptr` in all crates [datafusion]

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


-- 
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: consistently apply `clippy::clone_on_ref_ptr` in all crates [datafusion]

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

   > lgtm thanks @alamb not sure why CI failed though
   
   Thanks @comphead  -- I am not sure either -- I'll figure t 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: consistently apply `clippy::clone_on_ref_ptr` in all crates [datafusion]

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


##########
datafusion/catalog/src/session.rs:
##########
@@ -145,7 +145,7 @@ impl From<&dyn Session> for TaskContext {
             state.scalar_functions().clone(),
             state.aggregate_functions().clone(),
             state.window_functions().clone(),
-            state.runtime_env().clone(),
+            Arc::clone(state.runtime_env()),

Review Comment:
   this shows what the lint disallows -- when it is an `Arc` it must use `Arc::clone` rather than `.clone()` so it is easier to see when reading the code that no copies are made



-- 
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: consistently apply `clippy::clone_on_ref_ptr` in all crates [datafusion]

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


##########
datafusion/catalog/src/session.rs:
##########
@@ -145,7 +145,7 @@ impl From<&dyn Session> for TaskContext {
             state.scalar_functions().clone(),
             state.aggregate_functions().clone(),
             state.window_functions().clone(),
-            state.runtime_env().clone(),
+            Arc::clone(state.runtime_env()),

Review Comment:
   I always wondered what the motivation of the lint is 😆 



-- 
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: consistently apply `clippy::clone_on_ref_ptr` in all crates [datafusion]

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

   Thank you @alamb and @comphead 


-- 
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: consistently apply `clippy::clone_on_ref_ptr` in all crates [datafusion]

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


##########
datafusion/catalog/src/session.rs:
##########
@@ -145,7 +145,7 @@ impl From<&dyn Session> for TaskContext {
             state.scalar_functions().clone(),
             state.aggregate_functions().clone(),
             state.window_functions().clone(),
-            state.runtime_env().clone(),
+            Arc::clone(state.runtime_env()),

Review Comment:
   That is a good point -- I'll add some comments explaining 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