| 774 | |
| 775 | template <typename Enum> |
| 776 | Result<Enum> ParseOptionOrElse(const SubstraitCall& call, std::string_view option_name, |
| 777 | const EnumParser<Enum>& parser, |
| 778 | const std::vector<Enum>& implemented_options, |
| 779 | Enum fallback) { |
| 780 | std::optional<const std::vector<std::string>*> enum_arg = call.GetOption(option_name); |
| 781 | if (!enum_arg.has_value()) { |
| 782 | return fallback; |
| 783 | } |
| 784 | const std::vector<std::string>* prefs = *enum_arg; |
| 785 | for (const std::string& pref : *prefs) { |
| 786 | ARROW_ASSIGN_OR_RAISE(Enum parsed, parser.Parse(pref)); |
| 787 | for (Enum implemented_opt : implemented_options) { |
| 788 | if (implemented_opt == parsed) { |
| 789 | return parsed; |
| 790 | } |
| 791 | } |
| 792 | } |
| 793 | |
| 794 | // Prepare error message |
| 795 | return Status::NotImplemented( |
| 796 | "During a call to a function with id ", call.id().uri, "#", call.id().name, |
| 797 | " the plan requested the option ", option_name, " to be one of [", |
| 798 | arrow::internal::JoinStrings(*prefs, ", "), |
| 799 | "] but the only supported options are [", |
| 800 | parser.ImplementedOptionsAsString(implemented_options), "]"); |
| 801 | } |
| 802 | |
| 803 | template <typename Enum> |
| 804 | Result<Enum> ParseEnumArg(const SubstraitCall& call, int arg_index, |
nothing calls this directly
no test coverage detected