From 678b3e43d0aa904482d98178fb14c794aff03807 Mon Sep 17 00:00:00 2001 From: Rene Saarsoo Date: Wed, 28 Aug 2024 09:34:11 +0300 Subject: [PATCH] Allow TYPE to be used as an identifier in Snowflake Fixes #771 --- src/languages/snowflake/snowflake.formatter.ts | 2 +- test/snowflake.test.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/languages/snowflake/snowflake.formatter.ts b/src/languages/snowflake/snowflake.formatter.ts index 84f3740b0e..2ec81b1a86 100644 --- a/src/languages/snowflake/snowflake.formatter.ts +++ b/src/languages/snowflake/snowflake.formatter.ts @@ -68,7 +68,7 @@ const tabularOnelineClauses = expandPhrases([ 'DROP ALL ROW ACCESS POLICIES', '{SET | DROP} DEFAULT', // for alter column '{SET | DROP} NOT NULL', // for alter column - '[SET DATA] TYPE', // for alter column + 'SET DATA TYPE', // for alter column 'UNSET COMMENT', // for alter column '{SET | UNSET} MASKING POLICY', // for alter column // - truncate: diff --git a/test/snowflake.test.ts b/test/snowflake.test.ts index 419270ceca..f2d124f944 100644 --- a/test/snowflake.test.ts +++ b/test/snowflake.test.ts @@ -190,4 +190,18 @@ describe('SnowflakeFormatter', () => { third STRING );`); }); + + // Issue #771 + it('allows TYPE to be used as an identifier', () => { + expect(format(`SELECT CASE WHEN type = 'upgrade' THEN amount ELSE 0 END FROM items;`)) + .toBe(dedent` + SELECT + CASE + WHEN type = 'upgrade' THEN amount + ELSE 0 + END + FROM + items; + `); + }); });