pitrou commented on a change in pull request #12505:
URL: https://github.com/apache/arrow/pull/12505#discussion_r813942649
##########
File path: cpp/src/arrow/python/arrow_to_pandas.cc
##########
@@ -656,8 +656,19 @@ Status ConvertStruct(PandasOptions options, const
ChunkedArray& data,
// Convert the struct arrays first
for (int32_t i = 0; i < num_fields; i++) {
const auto field = arr->field(static_cast<int>(i));
- RETURN_NOT_OK(ConvertArrayToPandas(options, field, nullptr,
- fields_data[i +
fields_data_offset].ref()));
+ // In case the field is an extension array, use .storage() to convert to
Pandas
+ if (field->type()->id() == Type::EXTENSION){
+ // Save the field object as an Extension Array
+ const ExtensionArray& arr_ext = checked_cast<const
ExtensionArray&>(*field);
+ // Save the storage Array and use it to convert to Pandas
+ const std::shared_ptr<Array> field_ext = arr_ext.storage();
+ RETURN_NOT_OK(ConvertArrayToPandas(options, field_ext, nullptr,
+ fields_data[i +
fields_data_offset].ref()));
+ }
+ else{
+ RETURN_NOT_OK(ConvertArrayToPandas(options, field, nullptr,
+ fields_data[i +
fields_data_offset].ref()));
+ }
Review comment:
Perhaps replace `const auto field` with `auto field` in the line
introducting the `field` variable?
--
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]