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

Function EncodeMatchSubstring

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

Source from the content-addressed store, hash-verified

1010}
1011
1012ExtensionIdRegistry::ArrowToSubstraitCall EncodeMatchSubstring(Id substrait_fn_id) {
1013 return
1014 [substrait_fn_id](const compute::Expression::Call& call) -> Result<SubstraitCall> {
1015 if (call.options == nullptr) {
1016 return Status::Invalid("The call to ", call.function_name,
1017 " is missing its MatchSubstringOptions");
1018 }
1019 // Substrait's starts_with / ends_with / contains only accept strings while
1020 // the Arrow kernels also accept binary-like input and non-UTF-8 patterns
1021 const DataType* input_type = call.arguments[0].type();
1022 if (input_type == nullptr || input_type->id() != Type::STRING) {
1023 return Status::NotImplemented(
1024 "Substrait only supports ", substrait_fn_id.name,
1025 " on string input but the input to ", call.function_name, " is ",
1026 input_type == nullptr ? "unbound" : input_type->ToString());
1027 }
1028 auto match_options =
1029 checked_pointer_cast<compute::MatchSubstringOptions>(call.options);
1030 util::InitializeUTF8();
1031 if (!util::ValidateUTF8(match_options->pattern)) {
1032 return Status::NotImplemented("Substrait only supports ", substrait_fn_id.name,
1033 " with a valid UTF-8 pattern");
1034 }
1035 // nullable=true errs on the side of caution
1036 SubstraitCall substrait_call(substrait_fn_id, call.type.GetSharedPtr(),
1037 /*nullable=*/true);
1038 substrait_call.SetValueArg(0, call.arguments[0]);
1039 substrait_call.SetValueArg(1, compute::literal(match_options->pattern));
1040 substrait_call.SetOption(
1041 "case_sensitivity",
1042 {match_options->ignore_case ? "CASE_INSENSITIVE" : "CASE_SENSITIVE"});
1043 return substrait_call;
1044 };
1045}
1046
1047ExtensionIdRegistry::SubstraitAggregateToArrow DecodeBasicAggregate(
1048 const std::string& arrow_function_name) {

Callers 1

Calls 10

InitializeUTF8Function · 0.85
SetValueArgMethod · 0.80
SetOptionMethod · 0.80
NotImplementedFunction · 0.70
InvalidFunction · 0.50
ValidateUTF8Function · 0.50
literalFunction · 0.50
typeMethod · 0.45
idMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected