Skip to content

Commit 2023f57

Browse files
committed
Use .clone instead of constructing the field
1 parent 174068e commit 2023f57

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
@@ -408,14 +408,16 @@ impl ScalarUDFImpl for GetFieldFunc {
408408
plan_datafusion_err!("Field {field_name} not found in struct")
409409
})?;
410410

411-
let nullable =
412-
current_field.is_nullable() || child_field.is_nullable();
413411
let dict_type = DataType::Dictionary(
414412
key_type.clone(),
415413
Box::new(child_field.data_type().clone()),
416414
);
417-
current_field =
418-
Arc::new(Field::new(child_field.name(), dict_type, nullable));
415+
let mut new_field =
416+
child_field.as_ref().clone().with_data_type(dict_type);
417+
if current_field.is_nullable() {
418+
new_field = new_field.with_nullable(true);
419+
}
420+
current_field = Arc::new(new_field);
419421
}
420422
DataType::Struct(fields) => {
421423
let field_name = sv

0 commit comments

Comments
 (0)