Skip to content

Commit 79148eb

Browse files
committed
Fix arrow_field CI and expand tests
1 parent c4e9831 commit 79148eb

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

datafusion/functions/src/core/arrow_field.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ impl ScalarUDFImpl for ArrowFieldFunc {
107107
}
108108

109109
fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
110+
let return_type = args.return_type().clone();
110111
let [field] = take_function_args(self.name(), args.arg_fields)?;
111112

112113
// Build the name array
@@ -139,7 +140,7 @@ impl ScalarUDFImpl for ArrowFieldFunc {
139140
let metadata_array = Arc::new(map_builder.finish()) as Arc<dyn Array>;
140141

141142
// Build the struct
142-
let &DataType::Struct(fields) = args.return_type() else {
143+
let DataType::Struct(fields) = return_type else {
143144
unreachable!()
144145
};
145146

datafusion/sqllogictest/test_files/arrow_field.slt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,24 @@ SELECT arrow_field(ARRAY[1,2,3])
5151
----
5252
{name: lit, data_type: List(Int64), nullable: false, metadata: {}}
5353

54+
# arrow_field on map
55+
query ?
56+
SELECT arrow_field(MAP {'a': 1, 'b': 2})
57+
----
58+
{name: lit, data_type: Map("entries": non-null Struct("key": non-null Utf8, "value": Int64), unsorted), nullable: false, metadata: {}}
59+
60+
# arrow_field on struct
61+
query ?
62+
SELECT arrow_field({a: 1, b: 'foo'})
63+
----
64+
{name: lit, data_type: Struct("a": Int64, "b": Utf8), nullable: false, metadata: {}}
65+
66+
# arrow_field on dictionary
67+
query ?
68+
SELECT arrow_field(arrow_cast('foo', 'Dictionary(Int32, Utf8)'))
69+
----
70+
{name: lit, data_type: Dictionary(Int32, Utf8), nullable: false, metadata: {}}
71+
5472
# arrow_field struct field access - data_type
5573
query T
5674
SELECT arrow_field(1)['data_type']

0 commit comments

Comments
 (0)