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

Method MergeWith

cpp/src/arrow/type.cc:800–835  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

798} // namespace
799
800Result<std::shared_ptr<Field>> Field::MergeWith(const Field& other,
801 MergeOptions options) const {
802 if (name() != other.name()) {
803 return Status::Invalid("Field ", name(), " doesn't have the same name as ",
804 other.name());
805 }
806
807 if (Equals(other, /*check_metadata=*/false)) {
808 return Copy();
809 }
810
811 auto maybe_promoted_type = MergeTypes(type_, other.type(), options);
812 if (!maybe_promoted_type.ok()) {
813 return maybe_promoted_type.status().WithMessage(
814 "Unable to merge: Field ", name(),
815 " has incompatible types: ", type()->ToString(), " vs ", other.type()->ToString(),
816 ": ", maybe_promoted_type.status().message());
817 }
818 auto promoted_type = *std::move(maybe_promoted_type);
819 if (promoted_type) {
820 bool nullable = nullable_;
821 if (options.promote_nullability) {
822 nullable = nullable || other.nullable() || type_->id() == Type::NA ||
823 other.type()->id() == Type::NA;
824 } else if (nullable_ != other.nullable()) {
825 return Status::TypeError("Unable to merge: Field ", name(),
826 " has incompatible nullability: ", nullable_, " vs ",
827 other.nullable());
828 }
829
830 return std::make_shared<Field>(name_, std::move(promoted_type), nullable, metadata_);
831 }
832 return Status::TypeError("Unable to merge: Field ", name(),
833 " has incompatible types: ", type()->ToString(), " vs ",
834 other.type()->ToString());
835}
836
837Result<std::shared_ptr<Field>> Field::MergeWith(const std::shared_ptr<Field>& other,
838 MergeOptions options) const {

Callers 6

RecordBatchToTensorFunction · 0.80
AddFieldMethod · 0.80
TESTFunction · 0.80
TEST_FFunction · 0.80

Calls 14

MergeTypesFunction · 0.85
nullableMethod · 0.80
nameFunction · 0.70
InvalidFunction · 0.70
EqualsFunction · 0.70
typeFunction · 0.70
TypeErrorFunction · 0.70
CopyFunction · 0.50
nameMethod · 0.45
typeMethod · 0.45
okMethod · 0.45
statusMethod · 0.45

Tested by 4

TESTFunction · 0.64
TEST_FFunction · 0.64