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