Skip to content

Commit

Permalink
Make the struct function return the correct data type.
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangzhx committed Jun 8, 2023
1 parent 9c13a77 commit 5228bb3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion datafusion/expr/src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,14 @@ pub fn return_type(
_ => Ok(DataType::Float64),
},

BuiltinScalarFunction::Struct => Ok(DataType::Struct(Fields::empty())),
BuiltinScalarFunction::Struct => {
let return_fields = input_expr_types
.iter()
.enumerate()
.map(|(pos, dt)| Field::new(format!("c{pos}"), dt.clone(), true))
.collect::<Vec<Field>>();
Ok(DataType::Struct(Fields::from(return_fields)))
}

BuiltinScalarFunction::Atan2 => match &input_expr_types[0] {
DataType::Float32 => Ok(DataType::Float32),
Expand Down

0 comments on commit 5228bb3

Please sign in to comment.