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

Function MergeTypes

cpp/src/arrow/type.cc:758–797  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

756}
757
758Result<std::shared_ptr<DataType>> MergeTypes(std::shared_ptr<DataType> promoted_type,
759 std::shared_ptr<DataType> other_type,
760 const Field::MergeOptions& options) {
761 if (promoted_type->Equals(*other_type)) return promoted_type;
762
763 bool promoted = false;
764 if (options.promote_nullability) {
765 if (promoted_type->id() == Type::NA) {
766 return other_type;
767 } else if (other_type->id() == Type::NA) {
768 return promoted_type;
769 }
770 } else if (promoted_type->id() == Type::NA || other_type->id() == Type::NA) {
771 return Status::TypeError(
772 "Cannot merge type with null unless promote_nullability=true");
773 }
774
775 if (options.promote_dictionary && is_dictionary(promoted_type->id()) &&
776 is_dictionary(other_type->id())) {
777 return MergeDictionaryTypes(promoted_type, other_type, options);
778 }
779
780 ARROW_ASSIGN_OR_RAISE(auto maybe_promoted,
781 MaybeMergeTemporalTypes(promoted_type, other_type, options));
782 if (maybe_promoted) return maybe_promoted;
783
784 ARROW_ASSIGN_OR_RAISE(maybe_promoted,
785 MaybeMergeNumericTypes(promoted_type, other_type, options));
786 if (maybe_promoted) return maybe_promoted;
787
788 ARROW_ASSIGN_OR_RAISE(maybe_promoted,
789 MaybeMergeBinaryTypes(promoted_type, other_type, options));
790 if (maybe_promoted) return maybe_promoted;
791
792 ARROW_ASSIGN_OR_RAISE(maybe_promoted,
793 MaybeMergeListTypes(promoted_type, other_type, options));
794 if (maybe_promoted) return maybe_promoted;
795
796 return promoted ? promoted_type : nullptr;
797}
798} // namespace
799
800Result<std::shared_ptr<Field>> Field::MergeWith(const Field& other,

Callers 1

MergeWithMethod · 0.85

Calls 9

MergeDictionaryTypesFunction · 0.85
MaybeMergeNumericTypesFunction · 0.85
MaybeMergeBinaryTypesFunction · 0.85
MaybeMergeListTypesFunction · 0.85
TypeErrorFunction · 0.70
is_dictionaryFunction · 0.70
ARROW_ASSIGN_OR_RAISEFunction · 0.50
EqualsMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected