Skip to content

Commit 4597d3b

Browse files
authored
Minor: Add ScalarFunctionArgs::return_type method (#16113)
1 parent 0589dbb commit 4597d3b

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

datafusion/expr/src/udf.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,14 @@ pub struct ScalarFunctionArgs<'a, 'b> {
306306
pub return_field: &'b Field,
307307
}
308308

309+
impl<'a, 'b> ScalarFunctionArgs<'a, 'b> {
310+
/// The return type of the function. See [`Self::return_field`] for more
311+
/// details.
312+
pub fn return_type(&self) -> &DataType {
313+
self.return_field.data_type()
314+
}
315+
}
316+
309317
/// Information about arguments passed to the function
310318
///
311319
/// This structure contains metadata about how the function was called

datafusion/functions/src/core/named_struct.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl ScalarUDFImpl for NamedStructFunc {
150150
}
151151

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

datafusion/functions/src/core/struct.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl ScalarUDFImpl for StructFunc {
117117
}
118118

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

0 commit comments

Comments
 (0)