[#8401] Add support for parsing REGEXP, RLIKE, and LIKE_REGEX operators

This commit is contained in:
lukaseder 2019-03-25 12:53:36 +01:00
parent 40715b25d8
commit ebc1dce54c
2 changed files with 9 additions and 0 deletions

View File

@ -665,6 +665,7 @@ predicate =
(
| 'IN' '(' ( select | fields ) ')'
| 'BETWEEN' [ 'SYMMETRIC' ] concat 'AND' concat
| ( 'REGEXP' | 'RLIKE' | 'LIKE_REGEX' ) concat
| 'LIKE' concat [ 'ESCAPE' characterLiteral ]
| 'SIMILAR' 'TO' concat [ 'ESCAPE' characterLiteral ]
)

View File

@ -4330,6 +4330,14 @@ final class ParserImpl implements Parser {
? ((Field) left).notLike(right)
: ((Field) left).like(right);
}
else if (left instanceof Field && (parseKeywordIf(ctx, "REGEXP")
|| parseKeywordIf(ctx, "RLIKE")
|| parseKeywordIf(ctx, "LIKE_REGEX"))) {
Field right = toField(ctx, parseConcat(ctx, null));
return not
? ((Field) left).notLikeRegex(right)
: ((Field) left).likeRegex(right);
}
else if (left instanceof Field && parseKeywordIf(ctx, "SIMILAR TO")) {
Field right = toField(ctx, parseConcat(ctx, null));
boolean escape = parseKeywordIf(ctx, "ESCAPE");