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

Method ValidateSparseUnion

cpp/src/arrow/scalar.cc:469–486  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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