From 723e9dd130e7540efe991175d22810723e725111 Mon Sep 17 00:00:00 2001 From: Rene Saarsoo Date: Tue, 14 Nov 2023 14:11:55 +0200 Subject: [PATCH] Add Snowflake data types to keywords list Fixes #641 --- src/languages/snowflake/snowflake.keywords.ts | 38 +++++++++++++++++++ test/snowflake.test.ts | 17 +++++++++ 2 files changed, 55 insertions(+) diff --git a/src/languages/snowflake/snowflake.keywords.ts b/src/languages/snowflake/snowflake.keywords.ts index 43d7df51f1..fe3a82b5ee 100644 --- a/src/languages/snowflake/snowflake.keywords.ts +++ b/src/languages/snowflake/snowflake.keywords.ts @@ -99,4 +99,42 @@ export const keywords = flatKeywordList({ ], // These are definitely keywords, but haven't found a definite list in the docs additional: ['COMMENT'], + datatypes: [ + 'NUMBER', + 'DECIMAL', + 'NUMERIC', + 'INT', + 'INTEGER', + 'BIGINT', + 'SMALLINT', + 'TINYINT', + 'BYTEINT', + 'FLOAT', + 'FLOAT4', + 'FLOAT8', + 'DOUBLE', + 'DOUBLE PRECISION', + 'REAL', + 'VARCHAR', + 'CHAR', + 'CHARACTER', + 'STRING', + 'TEXT', + 'BINARY', + 'VARBINARY', + 'BOOLEAN', + 'DATE', + 'DATETIME', + 'TIME', + 'TIMESTAMP', + 'TIMESTAMP_LTZ', + 'TIMESTAMP_NTZ', + 'TIMESTAMP', + 'TIMESTAMP_TZ', + 'VARIANT', + 'OBJECT', + 'ARRAY', + 'GEOGRAPHY', + 'GEOMETRY', + ], }); diff --git a/test/snowflake.test.ts b/test/snowflake.test.ts index 4c4200455c..561c91b406 100644 --- a/test/snowflake.test.ts +++ b/test/snowflake.test.ts @@ -166,4 +166,21 @@ describe('SnowflakeFormatter', () => { UNSET TAG tname; `); }); + + it('detects data types as keywords', () => { + expect( + format( + `CREATE TABLE tbl (first_column double Precision, second_column numBer (38, 0), third String);`, + { + keywordCase: 'upper', + } + ) + ).toBe(dedent` + CREATE TABLE + tbl ( + first_column DOUBLE PRECISION, + second_column NUMBER (38, 0), + third STRING + );`); + }); });