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

Function ParseOptionOrElse

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

Source from the content-addressed store, hash-verified

774
775template <typename Enum>
776Result<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
803template <typename Enum>
804Result<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