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

Function MergeDictionaryTypes

cpp/src/arrow/type.cc:612–637  ·  view source on GitHub ↗

Merge two dictionary types, or else give an error.

Source from the content-addressed store, hash-verified

610
611// Merge two dictionary types, or else give an error.
612Result<std::shared_ptr<DataType>> MergeDictionaryTypes(
613 const std::shared_ptr<DataType>& promoted_type,
614 const std::shared_ptr<DataType>& other_type, const Field::MergeOptions& options) {
615 const auto& left = checked_cast<const DictionaryType&>(*promoted_type);
616 const auto& right = checked_cast<const DictionaryType&>(*other_type);
617 if (!options.promote_dictionary_ordered && left.ordered() != right.ordered()) {
618 return Status::TypeError(
619 "Cannot merge ordered and unordered dictionary unless "
620 "promote_dictionary_ordered=true");
621 }
622 Field::MergeOptions index_options = options;
623 index_options.promote_integer_sign = true;
624 index_options.promote_numeric_width = true;
625 ARROW_ASSIGN_OR_RAISE(
626 auto indices,
627 MaybeMergeNumericTypes(left.index_type(), right.index_type(), index_options));
628 ARROW_ASSIGN_OR_RAISE(auto values,
629 MergeTypes(left.value_type(), right.value_type(), options));
630 auto ordered = left.ordered() && right.ordered();
631 if (indices && values) {
632 return dictionary(indices, values, ordered);
633 } else if (values) {
634 return Status::TypeError("Could not merge dictionary index types");
635 }
636 return Status::TypeError("Could not merge dictionary value types");
637}
638
639// Merge temporal types based on options. Returns nullptr for non-binary types.
640Result<std::shared_ptr<DataType>> MaybeMergeBinaryTypes(

Callers 1

MergeTypesFunction · 0.85

Calls 2

TypeErrorFunction · 0.70
dictionaryFunction · 0.70

Tested by

no test coverage detected