Skip to content

Commit 6ffb1f6

Browse files
authored
Remove unnecessary clones from .../logical_plan/builder.rs (#12196)
1 parent 66bc222 commit 6ffb1f6

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

datafusion/expr/src/logical_plan/builder.rs

+13-16
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl LogicalPlanBuilder {
211211
};
212212
common_type = Some(new_type);
213213
} else {
214-
common_type = Some(data_type.clone());
214+
common_type = Some(data_type);
215215
}
216216
}
217217
field_types.push(common_type.unwrap_or(DataType::Utf8));
@@ -220,7 +220,7 @@ impl LogicalPlanBuilder {
220220
for row in &mut values {
221221
for (j, field_type) in field_types.iter().enumerate() {
222222
if let Expr::Literal(ScalarValue::Null) = row[j] {
223-
row[j] = Expr::Literal(ScalarValue::try_from(field_type.clone())?);
223+
row[j] = Expr::Literal(ScalarValue::try_from(field_type)?);
224224
} else {
225225
row[j] =
226226
std::mem::take(&mut row[j]).cast_to(field_type, &empty_schema)?;
@@ -552,20 +552,17 @@ impl LogicalPlanBuilder {
552552

553553
// Collect sort columns that are missing in the input plan's schema
554554
let mut missing_cols: Vec<Column> = vec![];
555-
exprs
556-
.clone()
557-
.into_iter()
558-
.try_for_each::<_, Result<()>>(|expr| {
559-
let columns = expr.column_refs();
555+
exprs.iter().try_for_each::<_, Result<()>>(|expr| {
556+
let columns = expr.column_refs();
560557

561-
columns.into_iter().for_each(|c| {
562-
if !schema.has_column(c) {
563-
missing_cols.push(c.clone());
564-
}
565-
});
558+
columns.into_iter().for_each(|c| {
559+
if !schema.has_column(c) {
560+
missing_cols.push(c.clone());
561+
}
562+
});
566563

567-
Ok(())
568-
})?;
564+
Ok(())
565+
})?;
569566

570567
if missing_cols.is_empty() {
571568
return Ok(Self::new(LogicalPlan::Sort(Sort {
@@ -710,7 +707,7 @@ impl LogicalPlanBuilder {
710707

711708
pub(crate) fn normalize(
712709
plan: &LogicalPlan,
713-
column: impl Into<Column> + Clone,
710+
column: impl Into<Column>,
714711
) -> Result<Column> {
715712
let schema = plan.schema();
716713
let fallback_schemas = plan.fallback_normalize_schemas();
@@ -1536,7 +1533,7 @@ pub fn get_unnested_columns(
15361533
| DataType::FixedSizeList(field, _)
15371534
| DataType::LargeList(field) => {
15381535
let new_field = Arc::new(Field::new(
1539-
col_name.clone(),
1536+
col_name,
15401537
field.data_type().clone(),
15411538
// Unnesting may produce NULLs even if the list is not null.
15421539
// For example: unnset([1], []) -> 1, null

0 commit comments

Comments
 (0)