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

Function ParseOptionOrElse

cpp/src/arrow/engine/substrait/extension_set.cc:761–786  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

759
760template <typename Enum>
761Result<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
788template <typename Enum>
789Result<Enum> ParseEnumArg(const SubstraitCall& call, int arg_index,

Callers

nothing calls this directly

Calls 5

JoinStringsFunction · 0.85
GetOptionMethod · 0.80
NotImplementedFunction · 0.70
idMethod · 0.45

Tested by

no test coverage detected