-
Notifications
You must be signed in to change notification settings - Fork 605
Add support for the LIKE ANY and ILIKE ANY pattern-matching condition #1456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
tests/sqlparser_snowflake.rs
Outdated
@@ -2162,6 +2162,19 @@ fn test_select_wildcard_with_ilike_replace() { | |||
); | |||
} | |||
|
|||
#[test] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the syntax support was added for all dialects (I think seems reasonable), can we move the test to sqlparser_common.rs so that they run against all dialects?
expr: Box<Expr>, | ||
pattern: Box<Expr>, | ||
escape_char: Option<String>, | ||
}, | ||
/// `ILIKE` (case-insensitive `LIKE`) | ||
ILike { | ||
negated: bool, | ||
any: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add a link to the snowflake doc where the syntax is mentioned? It would help with context for someone that comes across it in the codebase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in the latest commit
src/parser/mod.rs
Outdated
if self.parse_keyword(Keyword::ANY) { | ||
self.prev_token(); | ||
return self.expected("pattern after RLIKE or REGEXP", self.peek_token()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah not sure I followed this part, we don't seem to take any action for when parsing ANY is successful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only point of this condition was to add a meaningful error message when parsing incorrect syntax, for example: RLIKE ANY
. See the last check of the unit test. Can be removed, I debated this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in the latest commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! cc @alamb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @yoavcloud and @iffyio
Pull Request Test Coverage Report for Build 11180959841Details
💛 - Coveralls |
Snowflake supports pattern matching over a list of patterns with the use of the case-sensitive LIKE ANY and case-insensitive ILIKE ANY functions. Added support for the ANY option in the Expr::Like and Expr::ILike variants.