Skip to content

Commit

Permalink
Added support for additional snowflake types
Browse files Browse the repository at this point in the history
  • Loading branch information
create-new-entity committed May 20, 2024
1 parent 57e6346 commit f3c560b
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions pegjs/snowflake.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -4333,22 +4333,28 @@ KW_END = "END"i !ident_start

KW_CAST = "CAST"i !ident_start { return 'CAST' }

KW_BINARY = "BINARY"i !ident_start { return 'BINARY'; }
KW_VARBINARY = "VARBINARY"i !ident_start { return 'VARBINARY'; }

KW_BOOL = "BOOL"i !ident_start { return 'BOOL'; }
KW_BOOLEAN = "BOOLEAN"i !ident_start { return 'BOOLEAN'; }
KW_CHAR = "CHAR"i !ident_start { return 'CHAR'; }
KW_CHARACTER = "CHARACTER"i !ident_start { return 'CHARACTER'; }
KW_VARCHAR = "VARCHAR"i !ident_start { return 'VARCHAR';}
KW_NUMBER = "NUMBER"i !ident_start { return 'NUMBER'; }
KW_NUMERIC = "NUMERIC"i !ident_start { return 'NUMERIC'; }
KW_DECIMAL = "DECIMAL"i !ident_start { return 'DECIMAL'; }
KW_STRING = "STRING"i !ident_start { return 'STRING'; }
KW_SIGNED = "SIGNED"i !ident_start { return 'SIGNED'; }
KW_UNSIGNED = "UNSIGNED"i !ident_start { return 'UNSIGNED'; }
KW_INT = "INT"i !ident_start { return 'INT'; }
KW_BYTEINT = "BYTEINT"i !ident_start { return 'BYTEINT'; }
KW_ZEROFILL = "ZEROFILL"i !ident_start { return 'ZEROFILL'; }
KW_INTEGER = "INTEGER"i !ident_start { return 'INTEGER'; }
KW_JSON = "JSON"i !ident_start { return 'JSON'; }
KW_JSONB = "JSONB"i !ident_start { return 'JSONB'; }
KW_GEOMETRY = "GEOMETRY"i !ident_start { return 'GEOMETRY'; }
KW_GEOGRAPHY = "GEOGRAPHY"i !ident_start { return 'GEOGRAPHY'; }
KW_SMALLINT = "SMALLINT"i !ident_start { return 'SMALLINT'; }
KW_SERIAL = "SERIAL"i !ident_start { return 'SERIAL'; }
KW_TINYINT = "TINYINT"i !ident_start { return 'TINYINT'; }
Expand All @@ -4367,6 +4373,7 @@ KW_DATETIME = "DATETIME"i !ident_start { return 'DATETIME'; }
KW_ROWS = "ROWS"i !ident_start { return 'ROWS'; }
KW_TIME = "TIME"i !ident_start { return 'TIME'; }
KW_TIMESTAMP= "TIMESTAMP"i!ident_start { return 'TIMESTAMP'; }
KW_TIMESTAMP_TZ = "TIMESTAMP_TZ"i !ident_start { return 'TIMESTAMP_TZ'; }
KW_TRUNCATE = "TRUNCATE"i !ident_start { return 'TRUNCATE'; }
KW_USER = "USER"i !ident_start { return 'USER'; }
KW_UUID = "UUID"i !ident_start { return 'UUID'; }
Expand Down Expand Up @@ -4717,6 +4724,7 @@ data_type
/ enum_type
/ serial_interval_type
/ binary_type
/ geography_type
/ oid_type


Expand All @@ -4734,7 +4742,7 @@ boolean_type
= t:(KW_BOOL / KW_BOOLEAN) { /* => data_type */ return { dataType: t }}

binary_type
= 'bytea'i { /* => data_type */ return { dataType: 'BYTEA' }; }
= t:(KW_BINARY / KW_VARBINARY) { /* => data_type */ return { dataType: t }; }

character_string_type
= t:(KW_CHAR / KW_VARCHAR) __ LPAREN __ l:[0-9]+ __ RPAREN {
Expand All @@ -4752,9 +4760,9 @@ numeric_type_suffix
return result
}
numeric_type
= t:(KW_NUMBER / KW_DECIMAL / KW_INT / KW_INTEGER / KW_SMALLINT / KW_TINYINT / KW_BIGINT / KW_FLOAT / KW_DOUBLE / KW_SERIAL / KW_BIGSERIAL / KW_REAL) __ LPAREN __ l:[0-9]+ __ r:(COMMA __ [0-9]+)? __ RPAREN __ s:numeric_type_suffix? { /* => data_type */ return { dataType: t, length: parseInt(l.join(''), 10), scale: r && parseInt(r[2].join(''), 10), parentheses: true, suffix: s }; }
/ t:(KW_NUMBER / KW_DECIMAL / KW_INT / KW_INTEGER / KW_SMALLINT / KW_TINYINT / KW_BIGINT / KW_FLOAT / KW_DOUBLE / KW_SERIAL / KW_BIGSERIAL / KW_REAL)l:[0-9]+ __ s:numeric_type_suffix? { /* => data_type */ return { dataType: t, length: parseInt(l.join(''), 10), suffix: s }; }
/ t:(KW_NUMBER / KW_DECIMAL / KW_INT / KW_INTEGER / KW_SMALLINT / KW_TINYINT / KW_BIGINT / KW_FLOAT / KW_DOUBLE / KW_SERIAL / KW_BIGSERIAL / KW_REAL) __ s:numeric_type_suffix? __{ /* => data_type */ return { dataType: t, suffix: s }; }
= t:(KW_NUMBER / KW_DECIMAL / KW_INT / KW_BYTEINT / KW_INTEGER / KW_NUMERIC / KW_SMALLINT / KW_TINYINT / KW_BIGINT / KW_FLOAT / KW_DOUBLE / KW_SERIAL / KW_BIGSERIAL / KW_REAL) __ LPAREN __ l:[0-9]+ __ r:(COMMA __ [0-9]+)? __ RPAREN __ s:numeric_type_suffix? { /* => data_type */ return { dataType: t, length: parseInt(l.join(''), 10), scale: r && parseInt(r[2].join(''), 10), parentheses: true, suffix: s }; }
/ t:(KW_NUMBER / KW_DECIMAL / KW_INT / KW_BYTEINT / KW_INTEGER / KW_NUMERIC / KW_SMALLINT / KW_TINYINT / KW_BIGINT / KW_FLOAT / KW_DOUBLE / KW_SERIAL / KW_BIGSERIAL / KW_REAL)l:[0-9]+ __ s:numeric_type_suffix? { /* => data_type */ return { dataType: t, length: parseInt(l.join(''), 10), suffix: s }; }
/ t:(KW_NUMBER / KW_DECIMAL / KW_INT / KW_BYTEINT / KW_INTEGER / KW_NUMERIC / KW_SMALLINT / KW_TINYINT / KW_BIGINT / KW_FLOAT / KW_DOUBLE / KW_SERIAL / KW_BIGSERIAL / KW_REAL) __ s:numeric_type_suffix? __{ /* => data_type */ return { dataType: t, suffix: s }; }

oid_type
= t:(KW_OID / KW_REGCLASS / KW_REGCOLLATION / KW_REGCONFIG / KW_REGDICTIONARY / KW_REGNAMESPACE / KW_REGOPER / KW_REGOPERATOR / KW_REGPROC / KW_REGPROCEDURE / KW_REGROLE / KW_REGTYPE) { /* => data_type */ return { dataType: t }}
Expand All @@ -4771,7 +4779,7 @@ time_type

datetime_type
= t:(KW_DATE / KW_DATETIME) __ LPAREN __ l:[0-9]+ __ RPAREN { /* => data_type */ return { dataType: t, length: parseInt(l.join(''), 10), parentheses: true }; }
/ t:(KW_DATE / KW_DATETIME) { /* => data_type */ return { dataType: t }; }
/ t:(KW_DATE / KW_DATETIME / KW_TIMESTAMP_TZ) { /* => data_type */ return { dataType: t }; }
/ time_type

enum_type
Expand All @@ -4790,6 +4798,9 @@ json_type
geometry_type
= t:KW_GEOMETRY {/* => data_type */ return { dataType: t }; }

geography_type
= t:KW_GEOGRAPHY {/* => data_type */ return { dataType: t }; }

serial_interval_type
= t:(KW_SERIAL / KW_INTERVAL) { /* => data_type */ return { dataType: t }; }

Expand Down

0 comments on commit f3c560b

Please sign in to comment.