Skip to content

Commit

Permalink
Merge #41: Format GROUP BY ALL for BigQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
nene committed Jan 1, 2025
2 parents ed4176f + fe29ccd commit 37681d7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.12.1",
"description": "Prettier plugin for SQL",
"contributors": [
"Barna Magyarkuti <[email protected]>",
"Bowen Parnell <[email protected]>",
"Rene Saarsoo <[email protected]>"
],
Expand Down Expand Up @@ -36,7 +37,7 @@
],
"dependencies": {
"prettier": "^3.0.3",
"sql-parser-cst": "^0.31.1"
"sql-parser-cst": "^0.32.0"
},
"devDependencies": {
"@types/jest": "^29.2.5",
Expand Down
1 change: 1 addition & 0 deletions src/syntax/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export const selectMap: CstToDocMap<AllSelectNodes> = {
group_by_cube: (print) => print(["cubeKw", "columns"]),
group_by_grouping_sets: (print) =>
print.spaced(["groupingSetsKw", "columns"]),
group_by_all: (print) => print(["allKw"]),

// PARTITION BY clause
partition_by_clause: (print) =>
Expand Down
6 changes: 6 additions & 0 deletions test/select/select.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ describe("select", () => {
`);
});

it(`formats GROUP BY ALL`, async () => {
await testBigquery(dedent`
SELECT * FROM tbl GROUP BY ALL
`);
});

it(`formats QUALIFY clause`, async () => {
await testBigquery(`SELECT * FROM tbl QUALIFY x > 10`);
});
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2181,10 +2181,10 @@ sprintf-js@~1.0.2:
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==

sql-parser-cst@^0.31.1:
version "0.31.1"
resolved "https://registry.yarnpkg.com/sql-parser-cst/-/sql-parser-cst-0.31.1.tgz#c7d4e1b3f355e7f687aec2682f69f0593c2f1892"
integrity sha512-Af1QRnlMwDPQHFXrnt4lSYXxxEHvB/UvYroOe3oHFvfxZhGZ4uKlFSCCPoIhN3lReBQJIoXFwkNCTsS7rYUX7Q==
sql-parser-cst@^0.32.0:
version "0.32.0"
resolved "https://registry.yarnpkg.com/sql-parser-cst/-/sql-parser-cst-0.32.0.tgz#26bedbd8309801f1218a683a67b3c6af136816e9"
integrity sha512-J/8IeKGBGftFbssmWlE7NnIOnkH0EW8FwJoctcgZB9cY0aeCb1QFp/rl9uYPX87SY38PwCKiPUJO8+fssqg5vQ==

stack-utils@^2.0.3:
version "2.0.6"
Expand Down

0 comments on commit 37681d7

Please sign in to comment.