Skip to content

Commit

Permalink
Enable grouping sets parsing for GenericDialect (#771)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jefffrey committed Dec 28, 2022
1 parent 79d0baa commit f0870fd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/parser.rs
Expand Up @@ -943,7 +943,7 @@ impl<'a> Parser<'a> {
/// parse a group by expr. a group by expr can be one of group sets, roll up, cube, or simple
/// expr.
fn parse_group_by_expr(&mut self) -> Result<Expr, ParserError> {
if dialect_of!(self is PostgreSqlDialect) {
if dialect_of!(self is PostgreSqlDialect | GenericDialect) {
if self.parse_keywords(&[Keyword::GROUPING, Keyword::SETS]) {
self.expect_token(&Token::LParen)?;
let result = self.parse_comma_separated(|p| p.parse_tuple(false, true))?;
Expand Down
6 changes: 3 additions & 3 deletions tests/sqlparser_common.rs
Expand Up @@ -1513,7 +1513,7 @@ fn parse_select_group_by() {
#[test]
fn parse_select_group_by_grouping_sets() {
let dialects = TestedDialects {
dialects: vec![Box::new(PostgreSqlDialect {})],
dialects: vec![Box::new(GenericDialect {}), Box::new(PostgreSqlDialect {})],
};
let sql =
"SELECT brand, size, sum(sales) FROM items_sold GROUP BY size, GROUPING SETS ((brand), (size), ())";
Expand All @@ -1534,7 +1534,7 @@ fn parse_select_group_by_grouping_sets() {
#[test]
fn parse_select_group_by_rollup() {
let dialects = TestedDialects {
dialects: vec![Box::new(PostgreSqlDialect {})],
dialects: vec![Box::new(GenericDialect {}), Box::new(PostgreSqlDialect {})],
};
let sql = "SELECT brand, size, sum(sales) FROM items_sold GROUP BY size, ROLLUP (brand, size)";
let select = dialects.verified_only_select(sql);
Expand All @@ -1553,7 +1553,7 @@ fn parse_select_group_by_rollup() {
#[test]
fn parse_select_group_by_cube() {
let dialects = TestedDialects {
dialects: vec![Box::new(PostgreSqlDialect {})],
dialects: vec![Box::new(GenericDialect {}), Box::new(PostgreSqlDialect {})],
};
let sql = "SELECT brand, size, sum(sales) FROM items_sold GROUP BY size, CUBE (brand, size)";
let select = dialects.verified_only_select(sql);
Expand Down

0 comments on commit f0870fd

Please sign in to comment.