Skip to content

Commit

Permalink
Separate more dataTypes from keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
karlhorky committed Nov 30, 2023
1 parent 4f410f3 commit 5cb6131
Show file tree
Hide file tree
Showing 22 changed files with 292 additions and 197 deletions.
2 changes: 0 additions & 2 deletions src/languages/bigquery/bigquery.keywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export const keywords: string[] = [
'ALL',
'AND',
'ANY',
'ARRAY',
'AS',
'ASC',
'ASSERT_ROWS_MODIFIED',
Expand Down Expand Up @@ -80,7 +79,6 @@ export const keywords: string[] = [
'SELECT',
'SET',
'SOME',
'STRUCT',
'TABLE',
'TABLESAMPLE',
'THEN',
Expand Down
6 changes: 4 additions & 2 deletions src/languages/db2i/db2i.formatter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DialectOptions } from '../../dialect.js';
import { expandPhrases } from '../../expandPhrases.js';
import { functions } from './db2i.functions.js';
import { keywords } from './db2i.keywords.js';
import { dataTypes, keywords } from './db2i.keywords.js';

const reservedSelect = expandPhrases(['SELECT [ALL | DISTINCT]']);

Expand Down Expand Up @@ -161,7 +161,9 @@ export const db2i: DialectOptions = {
reservedSetOperations,
reservedJoins,
reservedPhrases,
reservedKeywords: keywords,
reservedKeywords:
// Temporary, will be replaced by reservedDataTypes
[...new Set(keywords.concat(dataTypes))],
reservedFunctionNames: functions,
nestedBlockComments: true,
extraParens: ['[]'],
Expand Down
47 changes: 34 additions & 13 deletions src/languages/db2i/db2i.keywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ export const keywords: string[] = [
'BEFORE',
'BEGIN',
'BETWEEN',
'BINARY',
'BIND',
'BIT',
'BOOLEAN',
'BSON',
'BUFFERPOOL',
'BY',
Expand All @@ -45,9 +42,6 @@ export const keywords: string[] = [
'CARDINALITY',
'CASE',
'CAST',
'CCSID',
'CHAR',
'CHARACTER',
'CHECK',
'CL',
'CLOSE',
Expand Down Expand Up @@ -90,11 +84,9 @@ export const keywords: string[] = [
'CURRENT_USER',
'CURSOR',
'CYCLE',
'DATA',
'DATABASE',
'DATAPARTITIONNAME',
'DATAPARTITIONNUM',
'DATE',
'DAY',
'DAYS',
'DB2GENERAL',
Expand Down Expand Up @@ -127,7 +119,6 @@ export const keywords: string[] = [
'DISTINCT',
'DO',
'DOCUMENT',
'DOUBLE',
'DROP',
'DYNAMIC',
'EACH',
Expand Down Expand Up @@ -177,7 +168,6 @@ export const keywords: string[] = [
'GO',
'GOTO',
'GRANT',
'GRAPHIC',
'GROUP',
'HANDLER',
'HASH',
Expand Down Expand Up @@ -256,7 +246,6 @@ export const keywords: string[] = [
'LOCKSIZE',
'LOG',
'LOGGED',
'LONG',
'LOOP',
'MAINTAINED',
'MASK',
Expand Down Expand Up @@ -436,8 +425,6 @@ export const keywords: string[] = [
'TAG',
'THEN',
'THREADSAFE',
'TIME',
'TIMESTAMP',
'TO',
'TRANSACTION',
'TRANSFER',
Expand Down Expand Up @@ -508,3 +495,37 @@ export const keywords: string[] = [
'YES',
'ZONE',
];

export const dataTypes: string[] = [
// https://www.ibm.com/docs/en/i/7.2?topic=iaodsd-odbc-data-types-how-they-correspond-db2-i-database-types
'BIGINT',
'BINARY',
'BIT',
'BLOB',
'BOOLEAN',
'CCSID',
'CHAR',
'CHARACTER',
'CLOB',
'DATA',
'DATALINK',
'DATE',
'DBCLOB',
'DECFLOAT',
'DECIMAL',
'DOUBLE',
'FLOAT',
'GRAPHIC',
'INTEGER',
'LONG',
'NUMERIC',
'REAL',
'ROWID',
'SMALLINT',
'TIME',
'TIMESTAMP',
'VARBINARY',
'VARCHAR',
'VARGRAPHIC',
'XML',
];
6 changes: 4 additions & 2 deletions src/languages/hive/hive.formatter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DialectOptions } from '../../dialect.js';
import { expandPhrases } from '../../expandPhrases.js';
import { functions } from './hive.functions.js';
import { keywords } from './hive.keywords.js';
import { dataTypes, keywords } from './hive.keywords.js';

const reservedSelect = expandPhrases(['SELECT [ALL | DISTINCT]']);

Expand Down Expand Up @@ -90,7 +90,9 @@ export const hive: DialectOptions = {
reservedSetOperations,
reservedJoins,
reservedPhrases,
reservedKeywords: keywords,
reservedKeywords:
// Temporary, will be replaced by reservedDataTypes
[...new Set(keywords.concat(dataTypes))],
reservedFunctionNames: functions,
extraParens: ['[]'],
stringTypes: ['""-bs', "''-bs"],
Expand Down
42 changes: 23 additions & 19 deletions src/languages/hive/hive.keywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ export const keywords: string[] = [
'STORED',
'STREAMTABLE',
'STRING',
'STRUCT',
'TABLES',
'TBLPROPERTIES',
'TEMPORARY',
Expand Down Expand Up @@ -186,18 +185,13 @@ export const keywords: string[] = [
'ALL',
'ALTER',
'AND',
'ARRAY',
'AS',
'AUTHORIZATION',
'BETWEEN',
'BIGINT',
'BINARY',
'BOOLEAN',
'BOTH',
'BY',
'CASE',
'CAST',
'CHAR',
'COLUMN',
'CONF',
'CREATE',
Expand All @@ -208,12 +202,9 @@ export const keywords: string[] = [
'CURRENT_TIMESTAMP',
'CURSOR',
'DATABASE',
'DATE',
'DECIMAL',
'DELETE',
'DESCRIBE',
'DISTINCT',
'DOUBLE',
'DROP',
'ELSE',
'END',
Expand All @@ -223,7 +214,6 @@ export const keywords: string[] = [
'EXTERNAL',
'FALSE',
'FETCH',
'FLOAT',
'FOLLOWING',
'FOR',
'FROM',
Expand All @@ -238,9 +228,7 @@ export const keywords: string[] = [
'IN',
'INNER',
'INSERT',
'INT',
'INTERSECT',
'INTERVAL',
'INTO',
'IS',
'JOIN',
Expand All @@ -250,7 +238,6 @@ export const keywords: string[] = [
'LIKE',
'LOCAL',
'MACRO',
'MAP',
'MORE',
'NONE',
'NOT',
Expand Down Expand Up @@ -278,11 +265,9 @@ export const keywords: string[] = [
'ROWS',
'SELECT',
'SET',
'SMALLINT',
'TABLE',
'TABLESAMPLE',
'THEN',
'TIMESTAMP',
'TO',
'TRANSFORM',
'TRIGGER',
Expand All @@ -296,7 +281,6 @@ export const keywords: string[] = [
'USING',
'UTC_TMESTAMP',
'VALUES',
'VARCHAR',
'WHEN',
'WHERE',
'WINDOW',
Expand All @@ -315,11 +299,8 @@ export const keywords: string[] = [
'DAYOFWEEK',
'EXTRACT',
'FLOOR',
'INTEGER',
'PRECISION',
'VIEWS',
'TIME',
'NUMERIC',
'SYNC',

// fileTypes
Expand All @@ -335,3 +316,26 @@ export const keywords: string[] = [
'INPUTFORMAT',
'OUTPUTFORMAT',
];

export const dataTypes: string[] = [
// https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types
'ARRAY',
'BIGINT',
'BINARY',
'BOOLEAN',
'CHAR',
'DATE',
'DECIMAL',
'DOUBLE',
'FLOAT',
'INT',
'INTEGER',
'INTERVAL',
'MAP',
'NUMERIC',
'PRECISION',
'SMALLINT',
'STRUCT',
'TIMESTAMP',
'VARCHAR',
];
6 changes: 4 additions & 2 deletions src/languages/mariadb/mariadb.formatter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DialectOptions } from '../../dialect.js';
import { expandPhrases } from '../../expandPhrases.js';
import { postProcess } from './likeMariaDb.js';
import { keywords } from './mariadb.keywords.js';
import { dataTypes, keywords } from './mariadb.keywords.js';
import { functions } from './mariadb.functions.js';

const reservedSelect = expandPhrases(['SELECT [ALL | DISTINCT | DISTINCTROW]']);
Expand Down Expand Up @@ -273,7 +273,9 @@ export const mariadb: DialectOptions = {
reservedJoins,
reservedPhrases,
supportsXor: true,
reservedKeywords: keywords,
reservedKeywords:
// Temporary, will be replaced by reservedDataTypes
[...new Set(keywords.concat(dataTypes))],
reservedFunctionNames: functions,
// TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc.
stringTypes: [
Expand Down
Loading

0 comments on commit 5cb6131

Please sign in to comment.