-
Notifications
You must be signed in to change notification settings - Fork 550
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
clickhouse: add support for LIMIT BY #977
Conversation
cd2478f
to
938a9d2
Compare
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 (again) @lustefaniak -- looks very nice.
src/parser/mod.rs
Outdated
@@ -5434,6 +5436,13 @@ impl<'a> Parser<'a> { | |||
} | |||
} | |||
|
|||
let limit_by = | |||
if dialect_of!(self is ClickHouseDialect) && self.parse_keyword(Keyword::BY) { |
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.
in general I think we try to have GenericDialect
support the union of all sql dialects, if possible. So this might be something like
if dialect_of!(self is ClickHouseDialect) && self.parse_keyword(Keyword::BY) { | |
if dialect_of!(self is ClickHouseDialect | GenericDialect) && self.parse_keyword(Keyword::BY) { |
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.
Right, good to know ;) I added tests testing both ClickhousDialect and GenericDialect
@@ -336,6 +336,13 @@ fn parse_create_table() { | |||
); | |||
} | |||
|
|||
#[test] | |||
fn parse_limit_by() { |
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.
Can you also please add a test for the multi-column form (e.g. LIMIT BY asset, class
or similar`)?
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.
Added
938a9d2
to
212ae9d
Compare
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 @lustefaniak . This looks really nice
https://clickhouse.com/docs/en/sql-reference/statements/select/limit-by