Repository: tobymao/sqlglot

Issue:
Presto Dialect: group by  clause error
Official Doc: https://prestodb.io/docs/current/sql/select.html?highlight=rollup#group-by-clause

There are two problems here.
1. sqlglot cannot parse table alias
```python
sqlglot.parse_one(
    """
SELECT origin_state, destination_state, origin_zip, sum(package_weight)
FROM shipping as a
GROUP BY
    ROLLUP (a.origin_zip)
""",
    read="presto",
)
```

2. sqlglot cannot parse multiple expressions
See doc paragraph "Combining multiple grouping expressions", the example is from the doc, and there are two grouping expressions, 「grouping sets」 and 「 roll up」
```python
sqlglot.parse_one(
    """
SELECT origin_state, destination_state, origin_zip, sum(package_weight)
FROM shipping
GROUP BY
    GROUPING SETS ((origin_state, destination_state)),
    ROLLUP (origin_zip)
""",
    read="presto",
)
```


Discussion:
I'll take a look soon, thanks for the report

Resolving patch:
diff --git a/sqlglot/generator.py b/sqlglot/generator.py
--- a/sqlglot/generator.py
+++ b/sqlglot/generator.py
@@ -975,7 +975,7 @@ def group_sql(self, expression: exp.Group) -> str:
             rollup = self.expressions(expression, key="rollup", indent=False)
             rollup = f"{self.seg('ROLLUP')} {self.wrap(rollup)}" if rollup else ""
 
-        return f"{group_by}{grouping_sets}{cube}{rollup}"
+        return f"{group_by}{csv(grouping_sets, cube, rollup, sep=',')}"
 
     def having_sql(self, expression: exp.Having) -> str:
         this = self.indent(self.sql(expression, "this"))
diff --git a/sqlglot/parser.py b/sqlglot/parser.py
--- a/sqlglot/parser.py
+++ b/sqlglot/parser.py
@@ -2042,9 +2042,16 @@ def _parse_group(self, skip_group_by_token: bool = False) -> t.Optional[exp.Expr
         expressions = self._parse_csv(self._parse_conjunction)
         grouping_sets = self._parse_grouping_sets()
 
+        self._match(TokenType.COMMA)
         with_ = self._match(TokenType.WITH)
-        cube = self._match(TokenType.CUBE) and (with_ or self._parse_wrapped_id_vars())
-        rollup = self._match(TokenType.ROLLUP) and (with_ or self._parse_wrapped_id_vars())
+        cube = self._match(TokenType.CUBE) and (
+            with_ or self._parse_wrapped_csv(self._parse_column)
+        )
+
+        self._match(TokenType.COMMA)
+        rollup = self._match(TokenType.ROLLUP) and (
+            with_ or self._parse_wrapped_csv(self._parse_column)
+        )
 
         return self.expression(
             exp.Group,


Test patch:
diff --git a/tests/fixtures/identity.sql b/tests/fixtures/identity.sql
--- a/tests/fixtures/identity.sql
+++ b/tests/fixtures/identity.sql
@@ -264,7 +264,9 @@ SELECT a FROM test GROUP BY GROUPING SETS (x, ())
 SELECT a FROM test GROUP BY GROUPING SETS (x, (x, y), (x, y, z), q)
 SELECT a FROM test GROUP BY CUBE (x)
 SELECT a FROM test GROUP BY ROLLUP (x)
-SELECT a FROM test GROUP BY CUBE (x) ROLLUP (x, y, z)
+SELECT t.a FROM test AS t GROUP BY ROLLUP (t.x)
+SELECT a FROM test GROUP BY GROUPING SETS ((x, y)), ROLLUP (b)
+SELECT a FROM test GROUP BY CUBE (x), ROLLUP (x, y, z)
 SELECT CASE WHEN a < b THEN 1 WHEN a < c THEN 2 ELSE 3 END FROM test
 SELECT CASE 1 WHEN 1 THEN 1 ELSE 2 END
 SELECT CASE 1 WHEN 1 THEN MAP('a', 'b') ELSE MAP('b', 'c') END['a']
diff --git a/tests/fixtures/pretty.sql b/tests/fixtures/pretty.sql
--- a/tests/fixtures/pretty.sql
+++ b/tests/fixtures/pretty.sql
@@ -99,7 +99,7 @@ WITH cte1 AS (
     GROUPING SETS (
       a,
       (b, c)
-    )
+    ),
     CUBE (
       y,
       z