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

Method ValidateSparseUnion

cpp/src/arrow/scalar.cc:467–484  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

465 }
466
467 Status ValidateSparseUnion(const SparseUnionScalar& s) {
468 const auto& union_type = checked_cast<const SparseUnionType&>(*s.type);
469 if (union_type.num_fields() != static_cast<int>(s.value.size())) {
470 return Status::Invalid("Sparse union scalar value had ", union_type.num_fields(),
471 " fields but type has ", s.value.size(), " fields.");
472 }
473 for (int j = 0; j < union_type.num_fields(); ++j) {
474 const auto& field_type = *union_type.field(j)->type();
475 const Scalar& field_value = *s.value[j];
476 if (!field_type.Equals(*field_value.type)) {
477 return Status::Invalid(s.type->ToString(), " value for field ",
478 union_type.field(j)->ToString(), " had incorrect type of ",
479 field_value.type->ToString());
480 }
481 RETURN_NOT_OK(ValidateValue(s, field_value));
482 }
483 return Status::OK();
484 }
485
486 Status Visit(const UnionScalar& s) {
487 const int type_code = s.type_code; // avoid 8-bit int types for printing

Callers

nothing calls this directly

Calls 8

InvalidFunction · 0.70
OKFunction · 0.70
num_fieldsMethod · 0.45
sizeMethod · 0.45
typeMethod · 0.45
fieldMethod · 0.45
EqualsMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected