You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[C++][Compute] Support casting struct fields to a different order #45028
Traceback (most recent call last):
File "/home/tomnewton/arrow/cpp/src/arrow/compute/example.py", line 30, in <module>
table_read = pq.read_table(
File "/home/tomnewton/.local/lib/python3.8/site-packages/pyarrow/parquet/core.py", line 1843, in read_table
return dataset.read(columns=columns, use_threads=use_threads,
File "/home/tomnewton/.local/lib/python3.8/site-packages/pyarrow/parquet/core.py", line 1485, in read
table = self._dataset.to_table(
File "pyarrow/_dataset.pyx", line 562, in pyarrow._dataset.Dataset.to_table
File "pyarrow/_dataset.pyx", line 3804, in pyarrow._dataset.Scanner.to_table
File "pyarrow/error.pxi", line 155, in pyarrow.lib.pyarrow_internal_check_status
File "pyarrow/error.pxi", line 92, in pyarrow.lib.check_status
pyarrow.lib.ArrowTypeError: struct fields don't match or are in the wrong order: Input fields: struct<sub_column0: int32, sub_column1: int32> output fields: struct<sub_column1: int32, sub_column0: int32>
. This means that cast actually can't fill with null like I thought when I created #44555. Instead this logic is part of the dataset scanner.
This does make me wonder if implementing #44587 as part of the cast may have been a mistake. However I think an advantage of putting this logic in cast is that it should work recursively e.g. if there are nested structs or structs inside arrays of maps, etc.
Therefore I'm going to investigate adding re-ordering to the cast logic in CastStruct::Exec as I did in #44587. I think the only complexity is duplicate field names - I need to think a bit more about how to handle this.
Activity
Tom-Newton commentedon Dec 16, 2024
To clarify a bit what I'm talking about
This works
But this does not
I'm hoping to make both work.
Tom-Newton commentedon Jan 13, 2025
The logic that handles this and #44555 for top level columns is at
arrow/cpp/src/arrow/compute/expression.cc
Line 669 in 6252e9c
This does make me wonder if implementing #44587 as part of the cast may have been a mistake. However I think an advantage of putting this logic in cast is that it should work recursively e.g. if there are nested structs or structs inside arrays of maps, etc.
Therefore I'm going to investigate adding re-ordering to the cast logic in
CastStruct::Execas I did in #44587. I think the only complexity is duplicate field names - I need to think a bit more about how to handle this.GH-45028: [C++][Compute] Allow cast to reorder struct fields (#45246)
lidavidm commentedon Apr 27, 2025
Issue resolved by pull request 45246
#45246