Substrait's starts_with / ends_with / contains take the pattern as a second value argument. The matching Arrow kernels (starts_with / ends_with / match_substring) are unary and carry the pattern in MatchSubstringOptions, so the second argument must be a string literal.
| 981 | // match_substring) are unary and carry the pattern in MatchSubstringOptions, so |
| 982 | // the second argument must be a string literal. |
| 983 | ExtensionIdRegistry::SubstraitCallToArrow DecodeMatchSubstringMapping( |
| 984 | const std::string& function_name) { |
| 985 | return [function_name](const SubstraitCall& call) -> Result<compute::Expression> { |
| 986 | if (call.size() != 2) { |
| 987 | return Status::NotImplemented("Acero does not have a kernel for ", function_name, |
| 988 | " that receives ", call.size(), " arguments"); |
| 989 | } |
| 990 | ARROW_ASSIGN_OR_RAISE( |
| 991 | CaseSensitivity case_sensitivity, |
| 992 | ParseOptionOrElse( |
| 993 | call, "case_sensitivity", kCaseSensitivityParser, |
| 994 | {CaseSensitivity::kCaseSensitive, CaseSensitivity::kCaseInsensitive}, |
| 995 | CaseSensitivity::kCaseSensitive)); |
| 996 | ARROW_ASSIGN_OR_RAISE(compute::Expression input, call.GetValueArg(0)); |
| 997 | ARROW_ASSIGN_OR_RAISE(compute::Expression substring, call.GetValueArg(1)); |
| 998 | const Datum* pattern = substring.literal(); |
| 999 | if (pattern == nullptr || !pattern->is_scalar() || |
| 1000 | pattern->type()->id() != Type::STRING || !pattern->scalar()->is_valid) { |
| 1001 | return Status::NotImplemented( |
| 1002 | "The Arrow ", function_name, |
| 1003 | " kernel requires the substring argument to be a non-null string literal"); |
| 1004 | } |
| 1005 | auto options = std::make_shared<compute::MatchSubstringOptions>( |
| 1006 | std::string(pattern->scalar_as<StringScalar>().view()), |
| 1007 | /*ignore_case=*/case_sensitivity == CaseSensitivity::kCaseInsensitive); |
| 1008 | return compute::call(function_name, {std::move(input)}, std::move(options)); |
| 1009 | }; |
| 1010 | } |
| 1011 | |
| 1012 | ExtensionIdRegistry::ArrowToSubstraitCall EncodeMatchSubstring(Id substrait_fn_id) { |
| 1013 | return |
no test coverage detected