From 31820b8ce38b56cf48ff85450bbc50ff39db32a0 Mon Sep 17 00:00:00 2001 From: taozhi8833998 Date: Thu, 20 Jun 2024 20:24:11 +0800 Subject: [PATCH] feat: support group by all in snowflake --- pegjs/snowflake.pegjs | 5 +++-- test/snowflake.spec.js | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pegjs/snowflake.pegjs b/pegjs/snowflake.pegjs index 4de13408..2e79ba96 100644 --- a/pegjs/snowflake.pegjs +++ b/pegjs/snowflake.pegjs @@ -2536,9 +2536,10 @@ where_clause = KW_WHERE __ e:or_and_where_expr { /* => binary_expr */ return e; } group_by_clause - = KW_GROUP __ KW_BY __ e:expr_list { + = KW_GROUP __ KW_BY __ e:(KW_ALL / expr_list) { + const columns = e === 'ALL' ? [{ type: 'origin', value: 'all'}] : e.value return { - columns: e.value + columns } } diff --git a/test/snowflake.spec.js b/test/snowflake.spec.js index c9a7b49a..496614ce 100644 --- a/test/snowflake.spec.js +++ b/test/snowflake.spec.js @@ -242,6 +242,13 @@ describe('snowflake', () => { 'CREATE TABLE "1dog" ("id" INT)' ] }, + { + title: 'group by all', + sql: [ + 'SELECT A, B, COUNT(*) FROM T GROUP BY All', + 'SELECT "A", "B", COUNT(*) FROM "T" GROUP BY ALL' + ] + }, ] SQL_LIST.forEach(sqlInfo => { const { title, sql } = sqlInfo