Commits


shinespiked authored and GitHub committed e588ed175f9
GH-42014: [Python] Let StructArray.from_array accept a type in addition to names or fields (#43047) ### Rationale for this change StructArray.from_array currently accepts names or fields to create the struct array. However if you already have a struct type it's more convenient to pass that in and allow the function to use it to build the StructArray instead of the user having to pull out the fields themselves. ### What changes are included in this PR? Add a new argument to StructArray.from_array called structtype. The function will prevent both fields and structype from being passed by raising a ValueError. If structtype is not null then the existing fields argument is set from the structtype fields. This allows all of the existing code in the function to remain untouched. ### Are these changes tested? Yes. Testing creating the structarray from fields a test is added to make sure that a struct type can be used to create the array. ### Are there any user-facing changes? Yes, the StructArray.from_arrays function now has an extra optional argument * GitHub Issue: #42014 Authored-by: Akshay Subramanian <173708861+shinespiked@users.noreply.github.com> Signed-off-by: AlenkaF <frim.alenka@gmail.com>