oc7o commented on PR #23188:
URL: https://github.com/apache/datafusion/pull/23188#issuecomment-5092037312
@kosiew
Looks like the PR blew up a bit 🥲 but I wanna do this right, and I think the
relevant things are now well covered. About 750 of the changed lines are tests
and 300 hand-written source (plus the generated proto code).
**Proto support:** I went with your first option rather than narrowing the
PR. `SqlSimilarToPattern` now has a `PhysicalSqlSimilarToPatternNode` message
(field 24 on `PhysicalExprNode`), `try_to_proto` / `try_from_proto`, and a
decode arm in `from_proto.rs`, following the same shape as `LikeExpr`. Some
proto code is generated from `regen.sh`. The tests are pretty similar to the
ones from the existing `LikeExpr` which I took as a reference.
**Type coercion:** while testing the above I found an issue with the plan
time type check. The plan-time check now accepts `LargeUtf8` / `Utf8View`
patterns. Previously mismatched string types could reach the regex kernel,
which dispatches on the left-hand type and then downcasts the pattern to that
same array type. So this panicked with `failed to downcast array`:
SELECT 'abc' SIMILAR TO arrow_cast('a%', 'LargeUtf8');
`Expr::SimilarTo` was sitting in the analyzer's no-op list, so nothing ever
reconciled the two sides. I added a coercion arm using `regex_coercion` (from
`Operator::RegexMatch`), which is what `SIMILAR TO` lowers to. As a side effect
dictionary-encoded strings now work too, since `dictionary_coercion` unwraps
them to their value type.
`\` is still treated as a literal, so `'a%' SIMILAR TO 'a\%'` is still false
and escaping doesn't work. Happy to take that as the follow-up I mentioned.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]