| 699 | } |
| 700 | |
| 701 | Status MakeStructExec(KernelContext* ctx, const ExecSpan& batch, ExecResult* out) { |
| 702 | ARROW_ASSIGN_OR_RAISE(TypeHolder type, MakeStructResolve(ctx, batch.GetTypes())); |
| 703 | |
| 704 | for (int i = 0; i < batch.num_values(); ++i) { |
| 705 | const auto& field = checked_cast<const StructType&>(*type.type).field(i); |
| 706 | if (batch[i].null_count() > 0 && !field->nullable()) { |
| 707 | return Status::Invalid("Output field ", field, " (#", i, |
| 708 | ") does not allow nulls but the corresponding " |
| 709 | "argument was not entirely valid."); |
| 710 | } |
| 711 | } |
| 712 | |
| 713 | ArrayData* out_data = out->array_data().get(); |
| 714 | out_data->length = batch.length; |
| 715 | out_data->type = type.GetSharedPtr(); |
| 716 | out_data->child_data.resize(batch.num_values()); |
| 717 | for (int i = 0; i < batch.num_values(); ++i) { |
| 718 | if (batch[i].is_array()) { |
| 719 | out_data->child_data[i] = batch[i].array.ToArrayData(); |
| 720 | } else { |
| 721 | ARROW_ASSIGN_OR_RAISE( |
| 722 | std::shared_ptr<Array> promoted, |
| 723 | MakeArrayFromScalar(*batch[i].scalar, batch.length, ctx->memory_pool())); |
| 724 | out_data->child_data[i] = promoted->data(); |
| 725 | } |
| 726 | } |
| 727 | return Status::OK(); |
| 728 | } |
| 729 | |
| 730 | const FunctionDoc make_struct_doc{"Wrap Arrays into a StructArray", |
| 731 | ("Names of the StructArray's fields are\n" |
nothing calls this directly
no test coverage detected