clickhouse: add support for LIMIT BY (#977)

This commit is contained in:
Lukasz Stefaniak 2023-10-02 17:53:32 +02:00 committed by GitHub
parent 993769ec02
commit 2786c7eaf1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 56 additions and 1 deletions

View file

@ -5431,6 +5431,7 @@ impl<'a> Parser<'a> {
with,
body: Box::new(SetExpr::Insert(insert)),
limit: None,
limit_by: vec![],
order_by: vec![],
offset: None,
fetch: None,
@ -5442,6 +5443,7 @@ impl<'a> Parser<'a> {
with,
body: Box::new(SetExpr::Update(update)),
limit: None,
limit_by: vec![],
order_by: vec![],
offset: None,
fetch: None,
@ -5468,7 +5470,7 @@ impl<'a> Parser<'a> {
offset = Some(self.parse_offset()?)
}
if dialect_of!(self is GenericDialect | MySqlDialect)
if dialect_of!(self is GenericDialect | MySqlDialect | ClickHouseDialect)
&& limit.is_some()
&& offset.is_none()
&& self.consume_token(&Token::Comma)
@ -5483,6 +5485,14 @@ impl<'a> Parser<'a> {
}
}
let limit_by = if dialect_of!(self is ClickHouseDialect | GenericDialect)
&& self.parse_keyword(Keyword::BY)
{
self.parse_comma_separated(Parser::parse_expr)?
} else {
vec![]
};
let fetch = if self.parse_keyword(Keyword::FETCH) {
Some(self.parse_fetch()?)
} else {
@ -5499,6 +5509,7 @@ impl<'a> Parser<'a> {
body,
order_by,
limit,
limit_by,
offset,
fetch,
locks,