Skip to content

Commit c1b6f78

Browse files
authored
Enable clone_on_ref_ptr clippy lint on physical-expr-common crate (apache#13295)
* Enable clone_on_ref_ptr clippy lint on physical-expr-common crate * cargo fmt * remove explicit type
1 parent 316e64a commit c1b6f78

File tree

5 files changed

+7
-4
lines changed

5 files changed

+7
-4
lines changed

datafusion/physical-expr-common/src/binary_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ where
349349
let batch_hashes = &mut self.hashes_buffer;
350350
batch_hashes.clear();
351351
batch_hashes.resize(values.len(), 0);
352-
create_hashes(&[values.clone()], &self.random_state, batch_hashes)
352+
create_hashes(&[Arc::clone(values)], &self.random_state, batch_hashes)
353353
// hash is supported for all types and create_hashes only
354354
// returns errors for unsupported types
355355
.unwrap();

datafusion/physical-expr-common/src/binary_view_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ where
244244
let batch_hashes = &mut self.hashes_buffer;
245245
batch_hashes.clear();
246246
batch_hashes.resize(values.len(), 0);
247-
create_hashes(&[values.clone()], &self.random_state, batch_hashes)
247+
create_hashes(&[Arc::clone(values)], &self.random_state, batch_hashes)
248248
// hash is supported for all types and create_hashes only
249249
// returns errors for unsupported types
250250
.unwrap();

datafusion/physical-expr-common/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18+
// Make cheap clones clear: https://github.com/apache/datafusion/issues/11143
19+
#![deny(clippy::clone_on_ref_ptr)]
20+
1821
//! Physical Expr Common packages for [DataFusion]
1922
//! This package contains high level PhysicalExpr trait
2023
//!

datafusion/physical-expr-common/src/tree_node.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl<T> ExprContext<T> {
6262
}
6363

6464
pub fn update_expr_from_children(mut self) -> Result<Self> {
65-
let children_expr = self.children.iter().map(|c| c.expr.clone()).collect();
65+
let children_expr = self.children.iter().map(|c| Arc::clone(&c.expr)).collect();
6666
self.expr = with_new_children_if_necessary(self.expr, children_expr)?;
6767
Ok(self)
6868
}

datafusion/physical-expr-common/src/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub fn scatter(mask: &BooleanArray, truthy: &dyn Array) -> Result<ArrayRef> {
9999
pub fn reverse_order_bys(order_bys: &LexOrdering) -> LexOrdering {
100100
order_bys
101101
.iter()
102-
.map(|e| PhysicalSortExpr::new(e.expr.clone(), !e.options))
102+
.map(|e| PhysicalSortExpr::new(Arc::clone(&e.expr), !e.options))
103103
.collect()
104104
}
105105

0 commit comments

Comments
 (0)