Allow to use () as the GROUP BY nothing (#1347)

This commit is contained in:
hulk 2024-07-23 03:50:24 +08:00 committed by GitHub
parent 48ea5640a2
commit b27abf00e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 33 additions and 0 deletions

View file

@ -1487,6 +1487,11 @@ impl<'a> Parser<'a> {
let result = self.parse_comma_separated(|p| p.parse_tuple(true, true))?;
self.expect_token(&Token::RParen)?;
Ok(Expr::Rollup(result))
} else if self.consume_tokens(&[Token::LParen, Token::RParen]) {
// PostgreSQL allow to use empty tuple as a group by expression,
// e.g. `GROUP BY (), name`. Please refer to GROUP BY Clause section in
// [PostgreSQL](https://www.postgresql.org/docs/16/sql-select.html)
Ok(Expr::Tuple(vec![]))
} else {
self.parse_expr()
}