Skip to content

Commit dbf1430

Browse files
committed
Use .clone instead of constructing the field
1 parent 6c66a3d commit dbf1430

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

datafusion/functions/src/core/getfield.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,14 +413,16 @@ impl ScalarUDFImpl for GetFieldFunc {
413413
plan_datafusion_err!("Field {field_name} not found in struct")
414414
})?;
415415

416-
let nullable =
417-
current_field.is_nullable() || child_field.is_nullable();
418416
let dict_type = DataType::Dictionary(
419417
key_type.clone(),
420418
Box::new(child_field.data_type().clone()),
421419
);
422-
current_field =
423-
Arc::new(Field::new(child_field.name(), dict_type, nullable));
420+
let mut new_field =
421+
child_field.as_ref().clone().with_data_type(dict_type);
422+
if current_field.is_nullable() {
423+
new_field = new_field.with_nullable(true);
424+
}
425+
current_field = Arc::new(new_field);
424426
}
425427
DataType::Struct(fields) => {
426428
let field_name = sv

0 commit comments

Comments
 (0)