Skip to content

Commit

Permalink
Add Snowflake data types to keywords list
Browse files Browse the repository at this point in the history
Fixes #641
  • Loading branch information
nene committed Nov 14, 2023
1 parent 8424d2b commit 723e9dd
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/languages/snowflake/snowflake.keywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
});
17 changes: 17 additions & 0 deletions test/snowflake.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);`);
});
});

0 comments on commit 723e9dd

Please sign in to comment.