Skip to content

Commit fe88fd1

Browse files
authored
Allow bare columns in GROUPING SETS expressions (#2288)
1 parent 5042135 commit fe88fd1

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/parser/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2592,7 +2592,7 @@ impl<'a> Parser<'a> {
25922592
if self.dialect.supports_group_by_expr() {
25932593
if self.parse_keywords(&[Keyword::GROUPING, Keyword::SETS]) {
25942594
self.expect_token(&Token::LParen)?;
2595-
let result = self.parse_comma_separated(|p| p.parse_tuple(false, true))?;
2595+
let result = self.parse_comma_separated(|p| p.parse_tuple(true, true))?;
25962596
self.expect_token(&Token::RParen)?;
25972597
Ok(Expr::GroupingSets(result))
25982598
} else if self.parse_keyword(Keyword::CUBE) {

tests/sqlparser_common.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13109,6 +13109,19 @@ fn test_group_by_grouping_sets() {
1310913109
);
1311013110
}
1311113111

13112+
#[test]
13113+
fn test_group_by_grouping_sets_bare_columns() {
13114+
all_dialects_where(|d| d.supports_group_by_expr()).one_statement_parses_to(
13115+
"SELECT a, b FROM t GROUP BY GROUPING SETS (a, b, c)",
13116+
"SELECT a, b FROM t GROUP BY GROUPING SETS ((a), (b), (c))",
13117+
);
13118+
13119+
all_dialects_where(|d| d.supports_group_by_expr()).one_statement_parses_to(
13120+
"SELECT a, b FROM t GROUP BY GROUPING SETS ((a, b), c)",
13121+
"SELECT a, b FROM t GROUP BY GROUPING SETS ((a, b), (c))",
13122+
);
13123+
}
13124+
1311213125
#[test]
1311313126
fn test_xmltable() {
1311413127
all_dialects()

0 commit comments

Comments
 (0)