Skip to content

Commit c4e9831

Browse files
adriangbmartin-g
andauthored
Apply suggestions from code review
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
1 parent 41f9312 commit c4e9831

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

datafusion/functions/src/core/arrow_field.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use std::sync::Arc;
3636
+----------------------------------------------+
3737
| arrow_field(Int64(1)) |
3838
+----------------------------------------------+
39-
| {name: Int64(1), data_type: Int64, ...} |
39+
| {name: lit, data_type: Int64, ...} |
4040
+----------------------------------------------+
4141
4242
> select arrow_field(1)['data_type'];
@@ -51,7 +51,7 @@ use std::sync::Arc;
5151
description = "Expression to evaluate. The expression can be a constant, column, or function, and any combination of operators."
5252
)
5353
)]
54-
#[derive(Debug, PartialEq, Eq, Hash)]
54+
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
5555
pub struct ArrowFieldFunc {
5656
signature: Signature,
5757
}
@@ -107,15 +107,14 @@ impl ScalarUDFImpl for ArrowFieldFunc {
107107
}
108108

109109
fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
110-
let [_arg] = take_function_args(self.name(), args.args)?;
111-
let field = &args.arg_fields[0];
110+
let [field] = take_function_args(self.name(), args.arg_fields)?;
112111

113112
// Build the name array
114113
let name_array =
115114
Arc::new(StringArray::from(vec![field.name().as_str()])) as Arc<dyn Array>;
116115

117116
// Build the data_type array
118-
let data_type_str = format!("{}", field.data_type());
117+
let data_type_str = field.data_type().to_string();
119118
let data_type_array =
120119
Arc::new(StringArray::from(vec![data_type_str.as_str()])) as Arc<dyn Array>;
121120

@@ -140,7 +139,7 @@ impl ScalarUDFImpl for ArrowFieldFunc {
140139
let metadata_array = Arc::new(map_builder.finish()) as Arc<dyn Array>;
141140

142141
// Build the struct
143-
let DataType::Struct(fields) = Self::return_struct_type() else {
142+
let &DataType::Struct(fields) = args.return_type() else {
144143
unreachable!()
145144
};
146145

0 commit comments

Comments
 (0)