| 249 | } |
| 250 | |
| 251 | Result<std::shared_ptr<RecordBatch>> RecordBatch::FromStructArray( |
| 252 | const std::shared_ptr<Array>& array, MemoryPool* memory_pool) { |
| 253 | if (array->type_id() != Type::STRUCT) { |
| 254 | return Status::TypeError("Cannot construct record batch from array of type ", |
| 255 | *array->type()); |
| 256 | } |
| 257 | // Push the struct array's validity map and slicing (if any) into the child arrays |
| 258 | // by calling Flatten |
| 259 | const std::shared_ptr<StructArray>& struct_array = |
| 260 | internal::checked_pointer_cast<StructArray>(array); |
| 261 | ARROW_ASSIGN_OR_RAISE(std::vector<std::shared_ptr<Array>> fields, |
| 262 | struct_array->Flatten(memory_pool)); |
| 263 | return Make(arrow::schema(array->type()->fields()), array->length(), std::move(fields)); |
| 264 | } |
| 265 | |
| 266 | namespace { |
| 267 |
no test coverage detected