fix: #295 #297 optimize impala data types suggestion and create table (#296)

* fix: #295 impala data types suggestion

* fix: #297 impala create table with STRUCT
This commit is contained in:
琉易 2024-04-21 12:10:36 +08:00 committed by GitHub
parent fa30fe9253
commit 31b57a494b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 5738 additions and 5248 deletions

View File

@ -151,7 +151,6 @@ KW_LOAD : 'LOAD';
KW_LOCALTIME : 'LOCALTIME';
KW_LOCALTIMESTAMP : 'LOCALTIMESTAMP';
KW_METADATA : 'METADATA';
KW_MAP : 'MAP';
KW_MINUTE : 'MINUTE';
KW_MINUTES : 'MINUTES';
KW_MONTH : 'MONTH';
@ -213,7 +212,6 @@ KW_SHOW : 'SHOW';
KW_SHUTDOWN : 'SHUTDOWN';
KW_SOME : 'SOME';
KW_STATS : 'STATS';
KW_STRUCT : 'STRUCT';
KW_STRAIGHT_JOIN : 'STRAIGHT_JOIN';
KW_SUBSTRING : 'SUBSTRING';
KW_SYSTEM : 'SYSTEM';
@ -259,6 +257,26 @@ KW_REFERENCES : 'REFERENCES';
KW_NOVALIDATE : 'NOVALIDATE';
KW_RELY : 'RELY';
// dataType
KW_BINARY : 'BINARY';
KW_BIGINT : 'BIGINT';
KW_BOOLEAN : 'BOOLEAN';
KW_CHAR : 'CHAR';
KW_DATE : 'DATE';
KW_DECIMAL : 'DECIMAL';
KW_DOUBLE : 'DOUBLE';
KW_INT : 'INT';
KW_MAP : 'MAP';
KW_REAL : 'REAL';
KW_SMALLINT : 'SMALLINT';
KW_FLOAT : 'FLOAT';
KW_STRING : 'STRING';
KW_STRUCT : 'STRUCT';
KW_TIMESTAMP : 'TIMESTAMP';
KW_TINYINT : 'TINYINT';
KW_VARCHAR : 'VARCHAR';
KW_COMPLEX : 'COMPLEX';
STATS_NUMDVS : '\'NUMDVS\'';
STATS_NUMNULLS : '\'NUMNULLS\'';
STATS_AVGSIZE : '\'AVGSIZE\'';

View File

@ -265,7 +265,7 @@ computeStats
;
computeIncrementalStats
: KW_COMPUTE KW_INCREMENTAL KW_STATS tableNamePath (KW_PARTITION expression)?
: KW_COMPUTE KW_INCREMENTAL KW_STATS tableNamePath (KW_PARTITION LPAREN expression RPAREN)?
;
dropStatement
@ -1003,8 +1003,30 @@ type
: type KW_ARRAY
| KW_ARRAY LT type GT
| KW_MAP LT type COMMA type GT
| KW_STRUCT LT identifier COLON type (COMMA identifier COLON type)* GT
| baseType (LPAREN typeParameter (COMMA typeParameter)* RPAREN)?
| KW_STRUCT LT identifier type (COMMA identifier type)* GT
| (baseType | dataType) (LPAREN typeParameter (COMMA typeParameter)* RPAREN)?
;
dataType
: KW_ARRAY
| KW_BINARY
| KW_BIGINT
| KW_BOOLEAN
| KW_CHAR
| KW_DATE
| KW_DECIMAL
| KW_DOUBLE
| KW_FLOAT
| KW_INT
| KW_MAP
| KW_REAL
| KW_SMALLINT
| KW_STRING
| KW_STRUCT
| KW_TIMESTAMP
| KW_TINYINT
| KW_VARCHAR
| KW_COMPLEX
;
typeParameter
@ -1125,6 +1147,7 @@ nonReserved
// IMPORTANT: this rule must only contain tokens. Nested rules are not supported. See SqlParser.exitNonReserved
: KW_BERNOULLI
| KW_DAY
| KW_DATE
| KW_DAYS
| KW_EXCLUDING
| KW_HOUR

File diff suppressed because one or more lines are too long

View File

@ -119,158 +119,174 @@ KW_LOAD=118
KW_LOCALTIME=119
KW_LOCALTIMESTAMP=120
KW_METADATA=121
KW_MAP=122
KW_MINUTE=123
KW_MINUTES=124
KW_MONTH=125
KW_MONTHS=126
KW_MERGE_FN=127
KW_NFC=128
KW_NFD=129
KW_NFKC=130
KW_NFKD=131
KW_NORMALIZE=132
KW_NOT=133
KW_NULL=134
KW_NULLS=135
KW_OFFSET=136
KW_ON=137
KW_OPTION=138
KW_OR=139
KW_ORDER=140
KW_ORDINALITY=141
KW_OUTER=142
KW_OWNER=143
KW_OVER=144
KW_OVERWRITE=145
KW_PARTITION=146
KW_PARTITIONS=147
KW_PARQUET=148
KW_POSITION=149
KW_PRECEDING=150
KW_PRIMARY=151
KW_REPLICATION=152
KW_PRIVILEGES=153
KW_PROPERTIES=154
KW_RANGE=155
KW_RECOVER=156
KW_RENAME=157
KW_REPEATABLE=158
KW_REPLACE=159
KW_RESTRICT=160
KW_RETURNS=161
KW_REVOKE=162
KW_REFRESH=163
KW_REGEXP=164
KW_RLIKE=165
KW_RIGHT=166
KW_ROLE=167
KW_ROLES=168
KW_ROW=169
KW_ROWS=170
KW_SCHEMA=171
KW_SCHEMAS=172
KW_SECOND=173
KW_SECONDS=174
KW_SELECT=175
KW_SERDEPROPERTIES=176
KW_SET=177
KW_SEMI=178
KW_SERVER=179
KW_SHOW=180
KW_SHUTDOWN=181
KW_SOME=182
KW_STATS=183
KW_STRUCT=184
KW_STRAIGHT_JOIN=185
KW_SUBSTRING=186
KW_SYSTEM=187
KW_SYMBOL=188
KW_SERIALIZE_FN=189
KW_TABLE=190
KW_TABLES=191
KW_TABLESAMPLE=192
KW_TERMINATED=193
KW_THEN=194
KW_TO=195
KW_TRUE=196
KW_TRY_CAST=197
KW_TRUNCATE=198
KW_UNCACHED=199
KW_UESCAPE=200
KW_UNBOUNDED=201
KW_UNION=202
KW_UNNEST=203
KW_UNSET=204
KW_USE=205
KW_USER=206
KW_USING=207
KW_UPDATE_FN=208
KW_UPSERT=209
KW_UNKNOWN=210
KW_URI=211
KW_VALUE=212
KW_VALUES=213
KW_VIEW=214
KW_VIEWS=215
KW_WHEN=216
KW_WHERE=217
KW_WITH=218
KW_YEAR=219
KW_YEARS=220
KW_TEXTFILE=221
KW_ORC=222
KW_AVRO=223
KW_SEQUENCEFILE=224
KW_RCFILE=225
KW_REFERENCES=226
KW_NOVALIDATE=227
KW_RELY=228
STATS_NUMDVS=229
STATS_NUMNULLS=230
STATS_AVGSIZE=231
STATS_MAXSIZE=232
EQ=233
NEQ=234
LT=235
LTE=236
GT=237
GTE=238
PLUS=239
MINUS=240
ASTERISK=241
SLASH=242
PERCENT=243
CONCAT=244
DOT=245
SEMICOLON=246
COMMA=247
COLON=248
LPAREN=249
RPAREN=250
LSQUARE=251
RSQUARE=252
LCURLY=253
RCURLY=254
BITWISEOR=255
QUESTION=256
RIGHT_ARROW=257
STRING=258
UNICODE_STRING=259
BINARY_LITERAL=260
INTEGER_VALUE=261
DECIMAL_VALUE=262
DOUBLE_VALUE=263
IDENTIFIER=264
DIGIT_IDENTIFIER=265
QUOTED_IDENTIFIER=266
BACKQUOTED_IDENTIFIER=267
TIME_WITH_TIME_ZONE=268
TIMESTAMP_WITH_TIME_ZONE=269
DOUBLE_PRECISION=270
SIMPLE_COMMENT=271
BRACKETED_COMMENT=272
WS=273
KW_MINUTE=122
KW_MINUTES=123
KW_MONTH=124
KW_MONTHS=125
KW_MERGE_FN=126
KW_NFC=127
KW_NFD=128
KW_NFKC=129
KW_NFKD=130
KW_NORMALIZE=131
KW_NOT=132
KW_NULL=133
KW_NULLS=134
KW_OFFSET=135
KW_ON=136
KW_OPTION=137
KW_OR=138
KW_ORDER=139
KW_ORDINALITY=140
KW_OUTER=141
KW_OWNER=142
KW_OVER=143
KW_OVERWRITE=144
KW_PARTITION=145
KW_PARTITIONS=146
KW_PARQUET=147
KW_POSITION=148
KW_PRECEDING=149
KW_PRIMARY=150
KW_REPLICATION=151
KW_PRIVILEGES=152
KW_PROPERTIES=153
KW_RANGE=154
KW_RECOVER=155
KW_RENAME=156
KW_REPEATABLE=157
KW_REPLACE=158
KW_RESTRICT=159
KW_RETURNS=160
KW_REVOKE=161
KW_REFRESH=162
KW_REGEXP=163
KW_RLIKE=164
KW_RIGHT=165
KW_ROLE=166
KW_ROLES=167
KW_ROW=168
KW_ROWS=169
KW_SCHEMA=170
KW_SCHEMAS=171
KW_SECOND=172
KW_SECONDS=173
KW_SELECT=174
KW_SERDEPROPERTIES=175
KW_SET=176
KW_SEMI=177
KW_SERVER=178
KW_SHOW=179
KW_SHUTDOWN=180
KW_SOME=181
KW_STATS=182
KW_STRAIGHT_JOIN=183
KW_SUBSTRING=184
KW_SYSTEM=185
KW_SYMBOL=186
KW_SERIALIZE_FN=187
KW_TABLE=188
KW_TABLES=189
KW_TABLESAMPLE=190
KW_TERMINATED=191
KW_THEN=192
KW_TO=193
KW_TRUE=194
KW_TRY_CAST=195
KW_TRUNCATE=196
KW_UNCACHED=197
KW_UESCAPE=198
KW_UNBOUNDED=199
KW_UNION=200
KW_UNNEST=201
KW_UNSET=202
KW_USE=203
KW_USER=204
KW_USING=205
KW_UPDATE_FN=206
KW_UPSERT=207
KW_UNKNOWN=208
KW_URI=209
KW_VALUE=210
KW_VALUES=211
KW_VIEW=212
KW_VIEWS=213
KW_WHEN=214
KW_WHERE=215
KW_WITH=216
KW_YEAR=217
KW_YEARS=218
KW_TEXTFILE=219
KW_ORC=220
KW_AVRO=221
KW_SEQUENCEFILE=222
KW_RCFILE=223
KW_REFERENCES=224
KW_NOVALIDATE=225
KW_RELY=226
KW_BINARY=227
KW_BIGINT=228
KW_BOOLEAN=229
KW_CHAR=230
KW_DATE=231
KW_DECIMAL=232
KW_DOUBLE=233
KW_INT=234
KW_MAP=235
KW_REAL=236
KW_SMALLINT=237
KW_FLOAT=238
KW_STRING=239
KW_STRUCT=240
KW_TIMESTAMP=241
KW_TINYINT=242
KW_VARCHAR=243
KW_COMPLEX=244
STATS_NUMDVS=245
STATS_NUMNULLS=246
STATS_AVGSIZE=247
STATS_MAXSIZE=248
EQ=249
NEQ=250
LT=251
LTE=252
GT=253
GTE=254
PLUS=255
MINUS=256
ASTERISK=257
SLASH=258
PERCENT=259
CONCAT=260
DOT=261
SEMICOLON=262
COMMA=263
COLON=264
LPAREN=265
RPAREN=266
LSQUARE=267
RSQUARE=268
LCURLY=269
RCURLY=270
BITWISEOR=271
QUESTION=272
RIGHT_ARROW=273
STRING=274
UNICODE_STRING=275
BINARY_LITERAL=276
INTEGER_VALUE=277
DECIMAL_VALUE=278
DOUBLE_VALUE=279
IDENTIFIER=280
DIGIT_IDENTIFIER=281
QUOTED_IDENTIFIER=282
BACKQUOTED_IDENTIFIER=283
TIME_WITH_TIME_ZONE=284
TIMESTAMP_WITH_TIME_ZONE=285
DOUBLE_PRECISION=286
SIMPLE_COMMENT=287
BRACKETED_COMMENT=288
WS=289
'ADD'=1
'ALL'=2
'ANALYTIC'=3
@ -392,138 +408,154 @@ WS=273
'LOCALTIME'=119
'LOCALTIMESTAMP'=120
'METADATA'=121
'MAP'=122
'MINUTE'=123
'MINUTES'=124
'MONTH'=125
'MONTHS'=126
'MERGE_FN'=127
'NFC'=128
'NFD'=129
'NFKC'=130
'NFKD'=131
'NORMALIZE'=132
'NOT'=133
'NULL'=134
'NULLS'=135
'OFFSET'=136
'ON'=137
'OPTION'=138
'OR'=139
'ORDER'=140
'ORDINALITY'=141
'OUTER'=142
'OWNER'=143
'OVER'=144
'OVERWRITE'=145
'PARTITION'=146
'PARTITIONS'=147
'PARQUET'=148
'POSITION'=149
'PRECEDING'=150
'PRIMARY'=151
'REPLICATION'=152
'PRIVILEGES'=153
'PROPERTIES'=154
'RANGE'=155
'RECOVER'=156
'RENAME'=157
'REPEATABLE'=158
'REPLACE'=159
'RESTRICT'=160
'RETURNS'=161
'REVOKE'=162
'REFRESH'=163
'REGEXP'=164
'RLIKE'=165
'RIGHT'=166
'ROLE'=167
'ROLES'=168
'ROW'=169
'ROWS'=170
'SCHEMA'=171
'SCHEMAS'=172
'SECOND'=173
'SECONDS'=174
'SELECT'=175
'SERDEPROPERTIES'=176
'SET'=177
'SEMI'=178
'SERVER'=179
'SHOW'=180
'SHUTDOWN'=181
'SOME'=182
'STATS'=183
'STRUCT'=184
'STRAIGHT_JOIN'=185
'SUBSTRING'=186
'SYSTEM'=187
'SYMBOL'=188
'SERIALIZE_FN'=189
'TABLE'=190
'TABLES'=191
'TABLESAMPLE'=192
'TERMINATED '=193
'THEN'=194
'TO'=195
'TRUE'=196
'TRY_CAST'=197
'TRUNCATE'=198
'UNCACHED'=199
'UESCAPE'=200
'UNBOUNDED'=201
'UNION'=202
'UNNEST'=203
'UNSET'=204
'USE'=205
'USER'=206
'USING'=207
'UPDATE_FN'=208
'UPSERT'=209
'UNKNOWN'=210
'URI'=211
'VALUE'=212
'VALUES'=213
'VIEW'=214
'VIEWS'=215
'WHEN'=216
'WHERE'=217
'WITH'=218
'YEAR'=219
'YEARS'=220
'TEXTFILE'=221
'ORC'=222
'AVRO'=223
'SEQUENCEFILE'=224
'RCFILE'=225
'REFERENCES'=226
'NOVALIDATE'=227
'RELY'=228
'\'NUMDVS\''=229
'\'NUMNULLS\''=230
'\'AVGSIZE\''=231
'\'MAXSIZE\''=232
'='=233
'<'=235
'<='=236
'>'=237
'>='=238
'+'=239
'-'=240
'*'=241
'/'=242
'%'=243
'||'=244
'.'=245
';'=246
','=247
':'=248
'('=249
')'=250
'['=251
']'=252
'{'=253
'}'=254
'|'=255
'?'=256
'->'=257
'MINUTE'=122
'MINUTES'=123
'MONTH'=124
'MONTHS'=125
'MERGE_FN'=126
'NFC'=127
'NFD'=128
'NFKC'=129
'NFKD'=130
'NORMALIZE'=131
'NOT'=132
'NULL'=133
'NULLS'=134
'OFFSET'=135
'ON'=136
'OPTION'=137
'OR'=138
'ORDER'=139
'ORDINALITY'=140
'OUTER'=141
'OWNER'=142
'OVER'=143
'OVERWRITE'=144
'PARTITION'=145
'PARTITIONS'=146
'PARQUET'=147
'POSITION'=148
'PRECEDING'=149
'PRIMARY'=150
'REPLICATION'=151
'PRIVILEGES'=152
'PROPERTIES'=153
'RANGE'=154
'RECOVER'=155
'RENAME'=156
'REPEATABLE'=157
'REPLACE'=158
'RESTRICT'=159
'RETURNS'=160
'REVOKE'=161
'REFRESH'=162
'REGEXP'=163
'RLIKE'=164
'RIGHT'=165
'ROLE'=166
'ROLES'=167
'ROW'=168
'ROWS'=169
'SCHEMA'=170
'SCHEMAS'=171
'SECOND'=172
'SECONDS'=173
'SELECT'=174
'SERDEPROPERTIES'=175
'SET'=176
'SEMI'=177
'SERVER'=178
'SHOW'=179
'SHUTDOWN'=180
'SOME'=181
'STATS'=182
'STRAIGHT_JOIN'=183
'SUBSTRING'=184
'SYSTEM'=185
'SYMBOL'=186
'SERIALIZE_FN'=187
'TABLE'=188
'TABLES'=189
'TABLESAMPLE'=190
'TERMINATED '=191
'THEN'=192
'TO'=193
'TRUE'=194
'TRY_CAST'=195
'TRUNCATE'=196
'UNCACHED'=197
'UESCAPE'=198
'UNBOUNDED'=199
'UNION'=200
'UNNEST'=201
'UNSET'=202
'USE'=203
'USER'=204
'USING'=205
'UPDATE_FN'=206
'UPSERT'=207
'UNKNOWN'=208
'URI'=209
'VALUE'=210
'VALUES'=211
'VIEW'=212
'VIEWS'=213
'WHEN'=214
'WHERE'=215
'WITH'=216
'YEAR'=217
'YEARS'=218
'TEXTFILE'=219
'ORC'=220
'AVRO'=221
'SEQUENCEFILE'=222
'RCFILE'=223
'REFERENCES'=224
'NOVALIDATE'=225
'RELY'=226
'BINARY'=227
'BIGINT'=228
'BOOLEAN'=229
'CHAR'=230
'DATE'=231
'DECIMAL'=232
'DOUBLE'=233
'INT'=234
'MAP'=235
'REAL'=236
'SMALLINT'=237
'FLOAT'=238
'STRING'=239
'STRUCT'=240
'TIMESTAMP'=241
'TINYINT'=242
'VARCHAR'=243
'COMPLEX'=244
'\'NUMDVS\''=245
'\'NUMNULLS\''=246
'\'AVGSIZE\''=247
'\'MAXSIZE\''=248
'='=249
'<'=251
'<='=252
'>'=253
'>='=254
'+'=255
'-'=256
'*'=257
'/'=258
'%'=259
'||'=260
'.'=261
';'=262
','=263
':'=264
'('=265
')'=266
'['=267
']'=268
'{'=269
'}'=270
'|'=271
'?'=272
'->'=273

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -119,158 +119,174 @@ KW_LOAD=118
KW_LOCALTIME=119
KW_LOCALTIMESTAMP=120
KW_METADATA=121
KW_MAP=122
KW_MINUTE=123
KW_MINUTES=124
KW_MONTH=125
KW_MONTHS=126
KW_MERGE_FN=127
KW_NFC=128
KW_NFD=129
KW_NFKC=130
KW_NFKD=131
KW_NORMALIZE=132
KW_NOT=133
KW_NULL=134
KW_NULLS=135
KW_OFFSET=136
KW_ON=137
KW_OPTION=138
KW_OR=139
KW_ORDER=140
KW_ORDINALITY=141
KW_OUTER=142
KW_OWNER=143
KW_OVER=144
KW_OVERWRITE=145
KW_PARTITION=146
KW_PARTITIONS=147
KW_PARQUET=148
KW_POSITION=149
KW_PRECEDING=150
KW_PRIMARY=151
KW_REPLICATION=152
KW_PRIVILEGES=153
KW_PROPERTIES=154
KW_RANGE=155
KW_RECOVER=156
KW_RENAME=157
KW_REPEATABLE=158
KW_REPLACE=159
KW_RESTRICT=160
KW_RETURNS=161
KW_REVOKE=162
KW_REFRESH=163
KW_REGEXP=164
KW_RLIKE=165
KW_RIGHT=166
KW_ROLE=167
KW_ROLES=168
KW_ROW=169
KW_ROWS=170
KW_SCHEMA=171
KW_SCHEMAS=172
KW_SECOND=173
KW_SECONDS=174
KW_SELECT=175
KW_SERDEPROPERTIES=176
KW_SET=177
KW_SEMI=178
KW_SERVER=179
KW_SHOW=180
KW_SHUTDOWN=181
KW_SOME=182
KW_STATS=183
KW_STRUCT=184
KW_STRAIGHT_JOIN=185
KW_SUBSTRING=186
KW_SYSTEM=187
KW_SYMBOL=188
KW_SERIALIZE_FN=189
KW_TABLE=190
KW_TABLES=191
KW_TABLESAMPLE=192
KW_TERMINATED=193
KW_THEN=194
KW_TO=195
KW_TRUE=196
KW_TRY_CAST=197
KW_TRUNCATE=198
KW_UNCACHED=199
KW_UESCAPE=200
KW_UNBOUNDED=201
KW_UNION=202
KW_UNNEST=203
KW_UNSET=204
KW_USE=205
KW_USER=206
KW_USING=207
KW_UPDATE_FN=208
KW_UPSERT=209
KW_UNKNOWN=210
KW_URI=211
KW_VALUE=212
KW_VALUES=213
KW_VIEW=214
KW_VIEWS=215
KW_WHEN=216
KW_WHERE=217
KW_WITH=218
KW_YEAR=219
KW_YEARS=220
KW_TEXTFILE=221
KW_ORC=222
KW_AVRO=223
KW_SEQUENCEFILE=224
KW_RCFILE=225
KW_REFERENCES=226
KW_NOVALIDATE=227
KW_RELY=228
STATS_NUMDVS=229
STATS_NUMNULLS=230
STATS_AVGSIZE=231
STATS_MAXSIZE=232
EQ=233
NEQ=234
LT=235
LTE=236
GT=237
GTE=238
PLUS=239
MINUS=240
ASTERISK=241
SLASH=242
PERCENT=243
CONCAT=244
DOT=245
SEMICOLON=246
COMMA=247
COLON=248
LPAREN=249
RPAREN=250
LSQUARE=251
RSQUARE=252
LCURLY=253
RCURLY=254
BITWISEOR=255
QUESTION=256
RIGHT_ARROW=257
STRING=258
UNICODE_STRING=259
BINARY_LITERAL=260
INTEGER_VALUE=261
DECIMAL_VALUE=262
DOUBLE_VALUE=263
IDENTIFIER=264
DIGIT_IDENTIFIER=265
QUOTED_IDENTIFIER=266
BACKQUOTED_IDENTIFIER=267
TIME_WITH_TIME_ZONE=268
TIMESTAMP_WITH_TIME_ZONE=269
DOUBLE_PRECISION=270
SIMPLE_COMMENT=271
BRACKETED_COMMENT=272
WS=273
KW_MINUTE=122
KW_MINUTES=123
KW_MONTH=124
KW_MONTHS=125
KW_MERGE_FN=126
KW_NFC=127
KW_NFD=128
KW_NFKC=129
KW_NFKD=130
KW_NORMALIZE=131
KW_NOT=132
KW_NULL=133
KW_NULLS=134
KW_OFFSET=135
KW_ON=136
KW_OPTION=137
KW_OR=138
KW_ORDER=139
KW_ORDINALITY=140
KW_OUTER=141
KW_OWNER=142
KW_OVER=143
KW_OVERWRITE=144
KW_PARTITION=145
KW_PARTITIONS=146
KW_PARQUET=147
KW_POSITION=148
KW_PRECEDING=149
KW_PRIMARY=150
KW_REPLICATION=151
KW_PRIVILEGES=152
KW_PROPERTIES=153
KW_RANGE=154
KW_RECOVER=155
KW_RENAME=156
KW_REPEATABLE=157
KW_REPLACE=158
KW_RESTRICT=159
KW_RETURNS=160
KW_REVOKE=161
KW_REFRESH=162
KW_REGEXP=163
KW_RLIKE=164
KW_RIGHT=165
KW_ROLE=166
KW_ROLES=167
KW_ROW=168
KW_ROWS=169
KW_SCHEMA=170
KW_SCHEMAS=171
KW_SECOND=172
KW_SECONDS=173
KW_SELECT=174
KW_SERDEPROPERTIES=175
KW_SET=176
KW_SEMI=177
KW_SERVER=178
KW_SHOW=179
KW_SHUTDOWN=180
KW_SOME=181
KW_STATS=182
KW_STRAIGHT_JOIN=183
KW_SUBSTRING=184
KW_SYSTEM=185
KW_SYMBOL=186
KW_SERIALIZE_FN=187
KW_TABLE=188
KW_TABLES=189
KW_TABLESAMPLE=190
KW_TERMINATED=191
KW_THEN=192
KW_TO=193
KW_TRUE=194
KW_TRY_CAST=195
KW_TRUNCATE=196
KW_UNCACHED=197
KW_UESCAPE=198
KW_UNBOUNDED=199
KW_UNION=200
KW_UNNEST=201
KW_UNSET=202
KW_USE=203
KW_USER=204
KW_USING=205
KW_UPDATE_FN=206
KW_UPSERT=207
KW_UNKNOWN=208
KW_URI=209
KW_VALUE=210
KW_VALUES=211
KW_VIEW=212
KW_VIEWS=213
KW_WHEN=214
KW_WHERE=215
KW_WITH=216
KW_YEAR=217
KW_YEARS=218
KW_TEXTFILE=219
KW_ORC=220
KW_AVRO=221
KW_SEQUENCEFILE=222
KW_RCFILE=223
KW_REFERENCES=224
KW_NOVALIDATE=225
KW_RELY=226
KW_BINARY=227
KW_BIGINT=228
KW_BOOLEAN=229
KW_CHAR=230
KW_DATE=231
KW_DECIMAL=232
KW_DOUBLE=233
KW_INT=234
KW_MAP=235
KW_REAL=236
KW_SMALLINT=237
KW_FLOAT=238
KW_STRING=239
KW_STRUCT=240
KW_TIMESTAMP=241
KW_TINYINT=242
KW_VARCHAR=243
KW_COMPLEX=244
STATS_NUMDVS=245
STATS_NUMNULLS=246
STATS_AVGSIZE=247
STATS_MAXSIZE=248
EQ=249
NEQ=250
LT=251
LTE=252
GT=253
GTE=254
PLUS=255
MINUS=256
ASTERISK=257
SLASH=258
PERCENT=259
CONCAT=260
DOT=261
SEMICOLON=262
COMMA=263
COLON=264
LPAREN=265
RPAREN=266
LSQUARE=267
RSQUARE=268
LCURLY=269
RCURLY=270
BITWISEOR=271
QUESTION=272
RIGHT_ARROW=273
STRING=274
UNICODE_STRING=275
BINARY_LITERAL=276
INTEGER_VALUE=277
DECIMAL_VALUE=278
DOUBLE_VALUE=279
IDENTIFIER=280
DIGIT_IDENTIFIER=281
QUOTED_IDENTIFIER=282
BACKQUOTED_IDENTIFIER=283
TIME_WITH_TIME_ZONE=284
TIMESTAMP_WITH_TIME_ZONE=285
DOUBLE_PRECISION=286
SIMPLE_COMMENT=287
BRACKETED_COMMENT=288
WS=289
'ADD'=1
'ALL'=2
'ANALYTIC'=3
@ -392,138 +408,154 @@ WS=273
'LOCALTIME'=119
'LOCALTIMESTAMP'=120
'METADATA'=121
'MAP'=122
'MINUTE'=123
'MINUTES'=124
'MONTH'=125
'MONTHS'=126
'MERGE_FN'=127
'NFC'=128
'NFD'=129
'NFKC'=130
'NFKD'=131
'NORMALIZE'=132
'NOT'=133
'NULL'=134
'NULLS'=135
'OFFSET'=136
'ON'=137
'OPTION'=138
'OR'=139
'ORDER'=140
'ORDINALITY'=141
'OUTER'=142
'OWNER'=143
'OVER'=144
'OVERWRITE'=145
'PARTITION'=146
'PARTITIONS'=147
'PARQUET'=148
'POSITION'=149
'PRECEDING'=150
'PRIMARY'=151
'REPLICATION'=152
'PRIVILEGES'=153
'PROPERTIES'=154
'RANGE'=155
'RECOVER'=156
'RENAME'=157
'REPEATABLE'=158
'REPLACE'=159
'RESTRICT'=160
'RETURNS'=161
'REVOKE'=162
'REFRESH'=163
'REGEXP'=164
'RLIKE'=165
'RIGHT'=166
'ROLE'=167
'ROLES'=168
'ROW'=169
'ROWS'=170
'SCHEMA'=171
'SCHEMAS'=172
'SECOND'=173
'SECONDS'=174
'SELECT'=175
'SERDEPROPERTIES'=176
'SET'=177
'SEMI'=178
'SERVER'=179
'SHOW'=180
'SHUTDOWN'=181
'SOME'=182
'STATS'=183
'STRUCT'=184
'STRAIGHT_JOIN'=185
'SUBSTRING'=186
'SYSTEM'=187
'SYMBOL'=188
'SERIALIZE_FN'=189
'TABLE'=190
'TABLES'=191
'TABLESAMPLE'=192
'TERMINATED '=193
'THEN'=194
'TO'=195
'TRUE'=196
'TRY_CAST'=197
'TRUNCATE'=198
'UNCACHED'=199
'UESCAPE'=200
'UNBOUNDED'=201
'UNION'=202
'UNNEST'=203
'UNSET'=204
'USE'=205
'USER'=206
'USING'=207
'UPDATE_FN'=208
'UPSERT'=209
'UNKNOWN'=210
'URI'=211
'VALUE'=212
'VALUES'=213
'VIEW'=214
'VIEWS'=215
'WHEN'=216
'WHERE'=217
'WITH'=218
'YEAR'=219
'YEARS'=220
'TEXTFILE'=221
'ORC'=222
'AVRO'=223
'SEQUENCEFILE'=224
'RCFILE'=225
'REFERENCES'=226
'NOVALIDATE'=227
'RELY'=228
'\'NUMDVS\''=229
'\'NUMNULLS\''=230
'\'AVGSIZE\''=231
'\'MAXSIZE\''=232
'='=233
'<'=235
'<='=236
'>'=237
'>='=238
'+'=239
'-'=240
'*'=241
'/'=242
'%'=243
'||'=244
'.'=245
';'=246
','=247
':'=248
'('=249
')'=250
'['=251
']'=252
'{'=253
'}'=254
'|'=255
'?'=256
'->'=257
'MINUTE'=122
'MINUTES'=123
'MONTH'=124
'MONTHS'=125
'MERGE_FN'=126
'NFC'=127
'NFD'=128
'NFKC'=129
'NFKD'=130
'NORMALIZE'=131
'NOT'=132
'NULL'=133
'NULLS'=134
'OFFSET'=135
'ON'=136
'OPTION'=137
'OR'=138
'ORDER'=139
'ORDINALITY'=140
'OUTER'=141
'OWNER'=142
'OVER'=143
'OVERWRITE'=144
'PARTITION'=145
'PARTITIONS'=146
'PARQUET'=147
'POSITION'=148
'PRECEDING'=149
'PRIMARY'=150
'REPLICATION'=151
'PRIVILEGES'=152
'PROPERTIES'=153
'RANGE'=154
'RECOVER'=155
'RENAME'=156
'REPEATABLE'=157
'REPLACE'=158
'RESTRICT'=159
'RETURNS'=160
'REVOKE'=161
'REFRESH'=162
'REGEXP'=163
'RLIKE'=164
'RIGHT'=165
'ROLE'=166
'ROLES'=167
'ROW'=168
'ROWS'=169
'SCHEMA'=170
'SCHEMAS'=171
'SECOND'=172
'SECONDS'=173
'SELECT'=174
'SERDEPROPERTIES'=175
'SET'=176
'SEMI'=177
'SERVER'=178
'SHOW'=179
'SHUTDOWN'=180
'SOME'=181
'STATS'=182
'STRAIGHT_JOIN'=183
'SUBSTRING'=184
'SYSTEM'=185
'SYMBOL'=186
'SERIALIZE_FN'=187
'TABLE'=188
'TABLES'=189
'TABLESAMPLE'=190
'TERMINATED '=191
'THEN'=192
'TO'=193
'TRUE'=194
'TRY_CAST'=195
'TRUNCATE'=196
'UNCACHED'=197
'UESCAPE'=198
'UNBOUNDED'=199
'UNION'=200
'UNNEST'=201
'UNSET'=202
'USE'=203
'USER'=204
'USING'=205
'UPDATE_FN'=206
'UPSERT'=207
'UNKNOWN'=208
'URI'=209
'VALUE'=210
'VALUES'=211
'VIEW'=212
'VIEWS'=213
'WHEN'=214
'WHERE'=215
'WITH'=216
'YEAR'=217
'YEARS'=218
'TEXTFILE'=219
'ORC'=220
'AVRO'=221
'SEQUENCEFILE'=222
'RCFILE'=223
'REFERENCES'=224
'NOVALIDATE'=225
'RELY'=226
'BINARY'=227
'BIGINT'=228
'BOOLEAN'=229
'CHAR'=230
'DATE'=231
'DECIMAL'=232
'DOUBLE'=233
'INT'=234
'MAP'=235
'REAL'=236
'SMALLINT'=237
'FLOAT'=238
'STRING'=239
'STRUCT'=240
'TIMESTAMP'=241
'TINYINT'=242
'VARCHAR'=243
'COMPLEX'=244
'\'NUMDVS\''=245
'\'NUMNULLS\''=246
'\'AVGSIZE\''=247
'\'MAXSIZE\''=248
'='=249
'<'=251
'<='=252
'>'=253
'>='=254
'+'=255
'-'=256
'*'=257
'/'=258
'%'=259
'||'=260
'.'=261
';'=262
','=263
':'=264
'('=265
')'=266
'['=267
']'=268
'{'=269
'}'=270
'|'=271
'?'=272
'->'=273

File diff suppressed because it is too large Load Diff

View File

@ -221,6 +221,7 @@ import { IntervalContext } from "./ImpalaSqlParser.js";
import { IntervalFieldContext } from "./ImpalaSqlParser.js";
import { NormalFormContext } from "./ImpalaSqlParser.js";
import { TypeContext } from "./ImpalaSqlParser.js";
import { DataTypeContext } from "./ImpalaSqlParser.js";
import { TypeParameterContext } from "./ImpalaSqlParser.js";
import { BaseTypeContext } from "./ImpalaSqlParser.js";
import { WhenClauseContext } from "./ImpalaSqlParser.js";
@ -2501,6 +2502,16 @@ export class ImpalaSqlParserListener implements ParseTreeListener {
* @param ctx the parse tree
*/
exitType?: (ctx: TypeContext) => void;
/**
* Enter a parse tree produced by `ImpalaSqlParser.dataType`.
* @param ctx the parse tree
*/
enterDataType?: (ctx: DataTypeContext) => void;
/**
* Exit a parse tree produced by `ImpalaSqlParser.dataType`.
* @param ctx the parse tree
*/
exitDataType?: (ctx: DataTypeContext) => void;
/**
* Enter a parse tree produced by `ImpalaSqlParser.typeParameter`.
* @param ctx the parse tree

View File

@ -221,6 +221,7 @@ import { IntervalContext } from "./ImpalaSqlParser.js";
import { IntervalFieldContext } from "./ImpalaSqlParser.js";
import { NormalFormContext } from "./ImpalaSqlParser.js";
import { TypeContext } from "./ImpalaSqlParser.js";
import { DataTypeContext } from "./ImpalaSqlParser.js";
import { TypeParameterContext } from "./ImpalaSqlParser.js";
import { BaseTypeContext } from "./ImpalaSqlParser.js";
import { WhenClauseContext } from "./ImpalaSqlParser.js";
@ -1594,6 +1595,12 @@ export class ImpalaSqlParserVisitor<Result> extends AbstractParseTreeVisitor<Res
* @return the visitor result
*/
visitType?: (ctx: TypeContext) => Result;
/**
* Visit a parse tree produced by `ImpalaSqlParser.dataType`.
* @param ctx the parse tree
* @return the visitor result
*/
visitDataType?: (ctx: DataTypeContext) => Result;
/**
* Visit a parse tree produced by `ImpalaSqlParser.typeParameter`.
* @param ctx the parse tree

View File

@ -7,3 +7,5 @@ DROP ;
INSERT ;
SHOW ;
CREATE TABLE t1 (id );

View File

@ -109,4 +109,38 @@ describe('Impala SQL Token Suggestion', () => {
'CURRENT',
]);
});
test('Create table with column dataType', () => {
const pos: CaretPosition = {
lineNumber: 11,
column: 21,
};
const suggestion = impala.getSuggestionAtCaretPosition(
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
const dataTypes = [
'INT',
'BINARY',
'BIGINT',
'BOOLEAN',
'CHAR',
'DATE',
'DECIMAL',
'DOUBLE',
'INT',
'MAP',
'REAL',
'SMALLINT',
'FLOAT',
'STRING',
'STRUCT',
'TIMESTAMP',
'TINYINT',
'VARCHAR',
'COMPLEX',
];
expect(dataTypes.every((dataType) => suggestion.includes(dataType))).toBe(true);
});
});

View File

@ -183,3 +183,32 @@ CREATE TABLE fk(id INT, col1 INT, col2 STRING, PRIMARY KEY(id),
CREATE TABLE new_Table like old_table;
CREATE TABLE new_Table like old_table partitioned by (year int) SORT BY (last_name, state);
CREATE TABLE IF NOT EXISTS t1 (id INT);
CREATE TABLE IF NOT EXISTS t1 (
id1 INT,
id2 BINARY,
id3 BIGINT,
id4 BOOLEAN,
id5 CHAR(4),
id6 DATE,
id7 DECIMAL(38, 0),
id8 DOUBLE,
id9 INT,
id10 MAP<INT, DOUBLE>,
id11 REAL,
id12 SMALLINT,
id13 FLOAT,
id14 STRING,
id15 STRUCT,
id16 TIMESTAMP,
id17 TINYINT,
id18 VARCHAR(256),
id19 COMPLEX,
id19 ARRAY<INT>
);
CREATE TABLE IF NOT EXISTS t1 (
id INT,
person STRUCT<first_name: STRING, last_name: VARCHAR(256)>
) PARTITIONED BY (student STRUCT<id: INT, name: VARCHAR(256), height: STRING, cost: DECIMAL(38, 0)>);