jorisvandenbossche commented on code in PR #14238:
URL: https://github.com/apache/arrow/pull/14238#discussion_r980025338
##########
python/pyarrow/src/arrow_to_pandas.cc:
##########
@@ -730,17 +731,33 @@ Status DecodeDictionaries(MemoryPool* pool, const
std::shared_ptr<DataType>& den
template <typename ListArrayT>
Status ConvertListsLike(PandasOptions options, const ChunkedArray& data,
PyObject** out_values) {
+ using ListArrayType = typename ListArrayT::TypeClass;
+ const auto& list_type = checked_cast<const ListArrayType&>(*data.type());
+ const auto& value_type = list_type.value_type();
+
+ const auto& val_type = checked_cast<const ExtensionType&>(*value_type);
+ const auto& storage_ty = val_type.storage_type();
+ const auto& lt = dynamic_cast<const FixedSizeListType*>(&list_type);
+
// Get column of underlying value arrays
ArrayVector value_arrays;
for (int c = 0; c < data.num_chunks(); c++) {
- const auto& arr = checked_cast<const ListArrayT&>(*data.chunk(c));
+
+ std::shared_ptr<DataType> out_ty;
+ if (lt != nullptr) {
+ out_ty = fixed_size_list(storage_ty, lt->list_size());
+ } else {
+ out_ty = list(storage_ty);
+ }
+ compute::CastOptions options;
+ options.to_type = out_ty;
+ ARROW_ASSIGN_OR_RAISE(std::shared_ptr<Array> casted,
compute::Cast(*data.chunk(c), out_ty, options));
Review Comment:
Or, when keeping the current approach, it's probably not needed to
explicitly `Cast`? I _think_ you can check if `arr.values()` has extension
type, and in that case take to underlying storage array.
In the ConvertStruct, we have some similar code for this:
```
// In case the field is an extension array, use .storage() to convert
to Pandas
if (field->type()->id() == Type::EXTENSION) {
const ExtensionArray& arr_ext = checked_cast<const
ExtensionArray&>(*field);
field = arr_ext.storage();
}
```
(in this case `field` would be `arr`, I think)
--
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]