From 4a95d4d85c27035ad1997673d586cb594be8e943 Mon Sep 17 00:00:00 2001 From: M Lorek Date: Sun, 5 Jan 2025 19:55:51 +0000 Subject: [PATCH] exclude clause (#4374) --- sql/snowflake/SnowflakeLexer.g4 | 1 + sql/snowflake/SnowflakeParser.g4 | 6 +++++- sql/snowflake/examples/select.sql | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sql/snowflake/SnowflakeLexer.g4 b/sql/snowflake/SnowflakeLexer.g4 index b972688200..c4059222db 100644 --- a/sql/snowflake/SnowflakeLexer.g4 +++ b/sql/snowflake/SnowflakeLexer.g4 @@ -314,6 +314,7 @@ ESCAPE : 'ESCAPE'; ESCAPE_UNENCLOSED_FIELD : 'ESCAPE_UNENCLOSED_FIELD'; EVENT : 'EVENT'; EXCEPT : 'EXCEPT'; +EXCLUDE : 'EXCLUDE'; EXCHANGE : 'EXCHANGE'; EXECUTE : 'EXEC' 'UTE'?; EXECUTION : 'EXECUTION'; diff --git a/sql/snowflake/SnowflakeParser.g4 b/sql/snowflake/SnowflakeParser.g4 index 472e31f831..7575a661a2 100644 --- a/sql/snowflake/SnowflakeParser.g4 +++ b/sql/snowflake/SnowflakeParser.g4 @@ -4156,7 +4156,7 @@ select_list select_list_elem : column_elem as_alias? - | column_elem_star + | column_elem_star exclude_clause? // | udt_elem | expression_elem as_alias? ; @@ -4175,6 +4175,10 @@ object_name_or_alias | alias DOT ; +exclude_clause + : EXCLUDE (column_name | column_list_in_parentheses) + ; + as_alias : AS? alias ; diff --git a/sql/snowflake/examples/select.sql b/sql/snowflake/examples/select.sql index 5922c407ee..100b9f239e 100644 --- a/sql/snowflake/examples/select.sql +++ b/sql/snowflake/examples/select.sql @@ -128,3 +128,7 @@ select * from a; select count(t.*) as ca from t9 as t; + +SELECT a.* EXCLUDE (col1, col2), b.* EXCLUDE col3 +FROM t1 as a +JOIN t2 as b USING (col5, col6);