MCPcopy Create free account
hub / github.com/apache/arrow / MakeStructExec

Function MakeStructExec

cpp/src/arrow/compute/kernels/scalar_nested.cc:701–728  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

699}
700
701Status 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
730const FunctionDoc make_struct_doc{"Wrap Arrays into a StructArray",
731 ("Names of the StructArray's fields are\n"

Callers

nothing calls this directly

Calls 15

nullableMethod · 0.80
array_dataMethod · 0.80
resizeMethod · 0.80
is_arrayMethod · 0.80
ToArrayDataMethod · 0.80
InvalidFunction · 0.50
ARROW_ASSIGN_OR_RAISEFunction · 0.50
MakeArrayFromScalarFunction · 0.50
OKFunction · 0.50
num_valuesMethod · 0.45
fieldMethod · 0.45
null_countMethod · 0.45

Tested by

no test coverage detected