westonpace commented on code in PR #34691:
URL: https://github.com/apache/arrow/pull/34691#discussion_r1147757734
##########
cpp/src/arrow/record_batch.cc:
##########
@@ -198,14 +198,20 @@ Result<std::shared_ptr<RecordBatch>>
RecordBatch::MakeEmpty(
}
Result<std::shared_ptr<RecordBatch>> RecordBatch::FromStructArray(
- const std::shared_ptr<Array>& array) {
+ const std::shared_ptr<Array>& array, MemoryPool* memory_pool) {
if (array->type_id() != Type::STRUCT) {
return Status::TypeError("Cannot construct record batch from array of type
",
*array->type());
}
- if (array->null_count() != 0) {
- return Status::Invalid(
- "Unable to construct record batch from a StructArray with non-zero
nulls.");
+ if (array->null_count() != 0 || array->offset() != 0) {
+ // If the struct array has a validity map or offset we need to push those
into
Review Comment:
Good question but I think we are ok. If there is only an offset then I
believe `StructArray::Flatten` is zero-copy. I think the only case that
allocates is when [both arrays have a non-trivial validity
bitmap](https://github.com/apache/arrow/blob/apache-arrow-11.0.0/cpp/src/arrow/array/array_nested.cc#L636-L641).
--
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]