| 759 | |
| 760 | template <typename Enum> |
| 761 | Result<Enum> ParseOptionOrElse(const SubstraitCall& call, std::string_view option_name, |
| 762 | const EnumParser<Enum>& parser, |
| 763 | const std::vector<Enum>& implemented_options, |
| 764 | Enum fallback) { |
| 765 | std::optional<const std::vector<std::string>*> enum_arg = call.GetOption(option_name); |
| 766 | if (!enum_arg.has_value()) { |
| 767 | return fallback; |
| 768 | } |
| 769 | const std::vector<std::string>* prefs = *enum_arg; |
| 770 | for (const std::string& pref : *prefs) { |
| 771 | ARROW_ASSIGN_OR_RAISE(Enum parsed, parser.Parse(pref)); |
| 772 | for (Enum implemented_opt : implemented_options) { |
| 773 | if (implemented_opt == parsed) { |
| 774 | return parsed; |
| 775 | } |
| 776 | } |
| 777 | } |
| 778 | |
| 779 | // Prepare error message |
| 780 | return Status::NotImplemented( |
| 781 | "During a call to a function with id ", call.id().uri, "#", call.id().name, |
| 782 | " the plan requested the option ", option_name, " to be one of [", |
| 783 | arrow::internal::JoinStrings(*prefs, ", "), |
| 784 | "] but the only supported options are [", |
| 785 | parser.ImplementedOptionsAsString(implemented_options), "]"); |
| 786 | } |
| 787 | |
| 788 | template <typename Enum> |
| 789 | Result<Enum> ParseEnumArg(const SubstraitCall& call, int arg_index, |
nothing calls this directly
no test coverage detected