Apache DataFusion SQL Query Engine
Enable `clone_on_ref_ptr` clippy lint on physical-expr-common crate (#13295)
Namgung Chanc1b6f7812846
diff --git a/datafusion/physical-expr-common/src/binary_map.rs b/datafusion/physical-expr-common/src/binary_map.rsindex 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 @@ wherelet 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.rsindex 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 @@ wherelet 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.rsindex 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.rsindex 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.rsindex 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()}