| 711 | ARROW_ASSIGN_OR_RAISE(auto key_arr, key_builder->Finish()); |
| 712 | ARROW_ASSIGN_OR_RAISE(auto value_arr, value_builder->Finish()); |
| 713 | ARROW_ASSIGN_OR_RAISE( |
| 714 | auto kv_arr, |
| 715 | StructArray::Make(ArrayVector{std::move(key_arr), std::move(value_arr)}, |
| 716 | std::vector<std::string>{"key", "value"})); |
| 717 | return Datum(std::make_shared<MapScalar>(std::move(kv_arr))); |
| 718 | } |
| 719 | |
| 720 | case substrait::Expression::Literal::kEmptyList: { |
| 721 | ARROW_ASSIGN_OR_RAISE(auto type_nullable, FromProto(lit.empty_list().type(), |
| 722 | ext_set, conversion_options)); |
| 723 | ARROW_ASSIGN_OR_RAISE(auto values, MakeEmptyArray(type_nullable.first)); |
| 724 | return ListScalar{std::move(values)}; |
| 725 | } |
| 726 | |
| 727 | case substrait::Expression::Literal::kEmptyMap: { |
| 728 | ARROW_ASSIGN_OR_RAISE( |
| 729 | auto key_type_nullable, |
| 730 | FromProto(lit.empty_map().key(), ext_set, conversion_options)); |
| 731 | ARROW_ASSIGN_OR_RAISE(auto keys, |
| 732 | MakeEmptyArray(std::move(key_type_nullable.first))); |
| 733 | |
| 734 | ARROW_ASSIGN_OR_RAISE( |
| 735 | auto value_type_nullable, |
| 736 | FromProto(lit.empty_map().value(), ext_set, conversion_options)); |
| 737 | ARROW_ASSIGN_OR_RAISE(auto values, |
| 738 | MakeEmptyArray(std::move(value_type_nullable.first))); |
| 739 | |
| 740 | auto map_type = std::make_shared<MapType>(keys->type(), values->type()); |
| 741 | ARROW_ASSIGN_OR_RAISE( |
| 742 | auto key_values, |
| 743 | StructArray::Make( |
| 744 | {std::move(keys), std::move(values)}, |
| 745 | checked_cast<const ListType&>(*map_type).value_type()->fields())); |
| 746 | |
| 747 | return MapScalar{std::move(key_values)}; |
| 748 | } |
| 749 | |
| 750 | case substrait::Expression::Literal::kNull: { |
| 751 | ARROW_ASSIGN_OR_RAISE(auto type_nullable, |
| 752 | FromProto(lit.null(), ext_set, conversion_options)); |
| 753 | if (!type_nullable.second) { |
| 754 | return Status::Invalid("Substrait null literal ", lit.DebugString(), |
| 755 | " is of non-nullable type"); |
| 756 | } |
| 757 | |
| 758 | return Datum(MakeNullScalar(std::move(type_nullable.first))); |
| 759 | } |
| 760 | |
| 761 | case substrait::Expression::Literal::kUserDefined: { |
| 762 | const auto& user_defined = lit.user_defined(); |
| 763 | ARROW_ASSIGN_OR_RAISE(auto type_record, |
| 764 | ext_set.DecodeType(user_defined.type_reference())); |
| 765 | UserDefinedLiteralToArrow visitor{nullptr, &user_defined, &ext_set, |
| 766 | conversion_options}; |
| 767 | ARROW_RETURN_NOT_OK((visitor)(*type_record.type)); |
| 768 | return Datum(std::move(visitor.scalar_)); |
| 769 | } |
| 770 |
no test coverage detected