Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions datafusion/expr/src/udf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,14 @@ pub struct ScalarFunctionArgs<'a, 'b> {
pub return_field: &'b Field,
}

impl<'a, 'b> ScalarFunctionArgs<'a, 'b> {
/// The return type of the function. See [`Self::return_field`] for more
/// details.
pub fn return_type(&self) -> &DataType {
self.return_field.data_type()
}
}

/// Information about arguments passed to the function
///
/// This structure contains metadata about how the function was called
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions/src/core/named_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl ScalarUDFImpl for NamedStructFunc {
}

fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
let DataType::Struct(fields) = args.return_field.data_type() else {
let DataType::Struct(fields) = args.return_type() else {
return internal_err!("incorrect named_struct return type");
};

Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions/src/core/struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl ScalarUDFImpl for StructFunc {
}

fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
let DataType::Struct(fields) = args.return_field.data_type() else {
let DataType::Struct(fields) = args.return_type() else {
return internal_err!("incorrect struct return type");
};

Expand Down