This is an automated email from the ASF dual-hosted git repository.
comphead 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 c1b6f78128 Enable `clone_on_ref_ptr` clippy lint on
physical-expr-common crate (#13295)
c1b6f78128 is described below
commit c1b6f781284618450a5c18bc4af3cb46344c8f46
Author: Namgung Chan <[email protected]>
AuthorDate: Fri Nov 8 03:00:12 2024 +0900
Enable `clone_on_ref_ptr` clippy lint on physical-expr-common crate (#13295)
* Enable clone_on_ref_ptr clippy lint on physical-expr-common crate
* cargo fmt
* remove explicit type
---
datafusion/physical-expr-common/src/binary_map.rs | 2 +-
datafusion/physical-expr-common/src/binary_view_map.rs | 2 +-
datafusion/physical-expr-common/src/lib.rs | 3 +++
datafusion/physical-expr-common/src/tree_node.rs | 2 +-
datafusion/physical-expr-common/src/utils.rs | 2 +-
5 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/datafusion/physical-expr-common/src/binary_map.rs
b/datafusion/physical-expr-common/src/binary_map.rs
index 80c4963ae0..59280a3abb 100644
--- a/datafusion/physical-expr-common/src/binary_map.rs
+++ b/datafusion/physical-expr-common/src/binary_map.rs
@@ -349,7 +349,7 @@ where
let batch_hashes = &mut self.hashes_buffer;
batch_hashes.clear();
batch_hashes.resize(values.len(), 0);
- create_hashes(&[values.clone()], &self.random_state, batch_hashes)
+ create_hashes(&[Arc::clone(values)], &self.random_state, batch_hashes)
// hash is supported for all types and create_hashes only
// returns errors for unsupported types
.unwrap();
diff --git a/datafusion/physical-expr-common/src/binary_view_map.rs
b/datafusion/physical-expr-common/src/binary_view_map.rs
index e131ad8f50..8af35510dd 100644
--- a/datafusion/physical-expr-common/src/binary_view_map.rs
+++ b/datafusion/physical-expr-common/src/binary_view_map.rs
@@ -244,7 +244,7 @@ where
let batch_hashes = &mut self.hashes_buffer;
batch_hashes.clear();
batch_hashes.resize(values.len(), 0);
- create_hashes(&[values.clone()], &self.random_state, batch_hashes)
+ create_hashes(&[Arc::clone(values)], &self.random_state, batch_hashes)
// hash is supported for all types and create_hashes only
// returns errors for unsupported types
.unwrap();
diff --git a/datafusion/physical-expr-common/src/lib.rs
b/datafusion/physical-expr-common/src/lib.rs
index 7e2ea0c493..a05f1c9630 100644
--- a/datafusion/physical-expr-common/src/lib.rs
+++ b/datafusion/physical-expr-common/src/lib.rs
@@ -15,6 +15,9 @@
// specific language governing permissions and limitations
// under the License.
+// Make cheap clones clear: https://github.com/apache/datafusion/issues/11143
+#![deny(clippy::clone_on_ref_ptr)]
+
//! Physical Expr Common packages for [DataFusion]
//! This package contains high level PhysicalExpr trait
//!
diff --git a/datafusion/physical-expr-common/src/tree_node.rs
b/datafusion/physical-expr-common/src/tree_node.rs
index d9892ce555..c37e67575b 100644
--- a/datafusion/physical-expr-common/src/tree_node.rs
+++ b/datafusion/physical-expr-common/src/tree_node.rs
@@ -62,7 +62,7 @@ impl<T> ExprContext<T> {
}
pub fn update_expr_from_children(mut self) -> Result<Self> {
- let children_expr = self.children.iter().map(|c|
c.expr.clone()).collect();
+ let children_expr = self.children.iter().map(|c|
Arc::clone(&c.expr)).collect();
self.expr = with_new_children_if_necessary(self.expr, children_expr)?;
Ok(self)
}
diff --git a/datafusion/physical-expr-common/src/utils.rs
b/datafusion/physical-expr-common/src/utils.rs
index ffdab6c6d3..114007bfa6 100644
--- a/datafusion/physical-expr-common/src/utils.rs
+++ b/datafusion/physical-expr-common/src/utils.rs
@@ -99,7 +99,7 @@ pub fn scatter(mask: &BooleanArray, truthy: &dyn Array) ->
Result<ArrayRef> {
pub fn reverse_order_bys(order_bys: &LexOrdering) -> LexOrdering {
order_bys
.iter()
- .map(|e| PhysicalSortExpr::new(e.expr.clone(), !e.options))
+ .map(|e| PhysicalSortExpr::new(Arc::clone(&e.expr), !e.options))
.collect()
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]