Apache DataFusion SQL Query Engine
Minor: Add `ScalarFunctionArgs::return_type` method (#16113)
Andrew Lamb4597d3bcffe4
diff --git a/datafusion/expr/src/udf.rs b/datafusion/expr/src/udf.rsindex 78bb56bc1c..3983d17516 100644--- a/datafusion/expr/src/udf.rs+++ b/datafusion/expr/src/udf.rs@@ -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 calleddiff --git a/datafusion/functions/src/core/named_struct.rs b/datafusion/functions/src/core/named_struct.rsindex 5fb118a8a2..9346b62b90 100644--- a/datafusion/functions/src/core/named_struct.rs+++ b/datafusion/functions/src/core/named_struct.rs@@ -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");};diff --git a/datafusion/functions/src/core/struct.rs b/datafusion/functions/src/core/struct.rsindex 416ad288fc..f068fc18a8 100644--- a/datafusion/functions/src/core/struct.rs+++ b/datafusion/functions/src/core/struct.rs@@ -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");};