Merge temporal types based on options. Returns nullptr for non-binary types.
| 638 | |
| 639 | // Merge temporal types based on options. Returns nullptr for non-binary types. |
| 640 | Result<std::shared_ptr<DataType>> MaybeMergeBinaryTypes( |
| 641 | std::shared_ptr<DataType>& promoted_type, std::shared_ptr<DataType>& other_type, |
| 642 | const Field::MergeOptions& options) { |
| 643 | if (options.promote_binary) { |
| 644 | if (other_type->id() == Type::FIXED_SIZE_BINARY && |
| 645 | is_base_binary_like(promoted_type->id())) { |
| 646 | return MakeBinary(*promoted_type); |
| 647 | } else if (promoted_type->id() == Type::FIXED_SIZE_BINARY && |
| 648 | is_base_binary_like(other_type->id())) { |
| 649 | return MakeBinary(*other_type); |
| 650 | } else if (promoted_type->id() == Type::FIXED_SIZE_BINARY && |
| 651 | other_type->id() == Type::FIXED_SIZE_BINARY) { |
| 652 | return binary(); |
| 653 | } |
| 654 | |
| 655 | if ((other_type->id() == Type::LARGE_STRING || |
| 656 | other_type->id() == Type::LARGE_BINARY) && |
| 657 | (promoted_type->id() == Type::STRING || promoted_type->id() == Type::BINARY) |
| 658 | |
| 659 | ) { |
| 660 | // Promoted type is always large in case there are regular and large types |
| 661 | promoted_type.swap(other_type); |
| 662 | } |
| 663 | |
| 664 | // When one field is binary and the other a string |
| 665 | if (is_string(promoted_type->id()) && is_binary(other_type->id())) { |
| 666 | return MakeBinary(*promoted_type); |
| 667 | } else if (is_binary(promoted_type->id()) && is_string(other_type->id())) { |
| 668 | return MakeBinary(*promoted_type); |
| 669 | } |
| 670 | |
| 671 | // When the types are the same, but one is large |
| 672 | if ((promoted_type->id() == Type::STRING && other_type->id() == Type::LARGE_STRING) || |
| 673 | (promoted_type->id() == Type::LARGE_STRING && other_type->id() == Type::STRING)) { |
| 674 | return large_utf8(); |
| 675 | } else if ((promoted_type->id() == Type::BINARY && |
| 676 | other_type->id() == Type::LARGE_BINARY) || |
| 677 | (promoted_type->id() == Type::LARGE_BINARY && |
| 678 | other_type->id() == Type::BINARY)) { |
| 679 | return large_binary(); |
| 680 | } |
| 681 | } |
| 682 | |
| 683 | return nullptr; |
| 684 | } |
| 685 | |
| 686 | // Merge list types based on options. Returns nullptr for non-list types. |
| 687 | Result<std::shared_ptr<DataType>> MergeStructs( |
no test coverage detected