Mark1626 opened a new issue, #20429:
URL: https://github.com/apache/datafusion/issues/20429
### Describe the bug
Not sure if this is a bug or expected behaviour. `make_array` works with
simple structs where the keys match
The following query works
```
> SELECT make_array(named_struct('1', 'a'), named_struct('1', 'b'));
+---------------------------------------------------------------------------------+
|
make_array(named_struct(Utf8("1"),Utf8("a")),named_struct(Utf8("1"),Utf8("b")))
|
+---------------------------------------------------------------------------------+
| [{1: a}, {1: b}]
|
+---------------------------------------------------------------------------------+
1 row(s) fetched.
Elapsed 0.013 seconds.
```
but fails when the struct's keys mismatch
### To Reproduce
```
> SELECT make_array(named_struct('1', 'a'), named_struct('2', 'b'));
Error during planning: Execution error: Function 'make_array' user-defined
coercion failed with "Error during planning: Failed to unify argument types of
make_array: [Struct(\"1\": Utf8), Struct(\"2\": Utf8)]" No function matches the
given name and argument types 'make_array(Struct("1": Utf8), Struct("2":
Utf8))'. You might need to add explicit type casts.
Candidate functions:
make_array(UserDefined)
```
### Expected behavior
Databricks for instance in this case assigns it's own column names `col1`,
`col2` for the struct fields. Should something like this be done? Or is it up
to the user to add explicit casts
<img width="800" height="673" alt="Image"
src="https://github.com/user-attachments/assets/2d123510-d6d9-4ca1-91a1-b27c0383adc4"
/>
### Additional context
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]