Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/sqlparse/keywords.py: 92%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#
2# Copyright (C) 2009-2020 the sqlparse authors and contributors
3# <see AUTHORS file>
4#
5# This module is part of python-sqlparse and is released under
6# the BSD License: https://opensource.org/licenses/BSD-3-Clause
8from sqlparse import tokens
10# object() only supports "is" and is useful as a marker
11# use this marker to specify that the given regex in SQL_REGEX
12# shall be processed further through a lookup in the KEYWORDS dictionaries
13PROCESS_AS_KEYWORD = object()
16SQL_REGEX = [
17 (r'(--|# )\+.*?(\r\n|\r|\n|$)', tokens.Comment.Single.Hint),
18 (r'/\*\+[\s\S]*?\*/', tokens.Comment.Multiline.Hint),
20 (r'(--|# ).*?(\r\n|\r|\n|$)', tokens.Comment.Single),
21 (r'/\*[\s\S]*?\*/', tokens.Comment.Multiline),
23 (r'(\r\n|\r|\n)', tokens.Newline),
24 (r'\s+?', tokens.Whitespace),
26 (r':=', tokens.Assignment),
27 (r'::', tokens.Punctuation),
29 (r'\*', tokens.Wildcard),
31 (r"`(``|[^`])*`", tokens.Name),
32 (r"´(´´|[^´])*´", tokens.Name),
33 (r'((?<![\w\"\$])\$(?:[_A-ZÀ-Ü]\w*)?\$)[\s\S]*?\1', tokens.Literal),
35 (r'\?', tokens.Name.Placeholder),
36 (r'%(\(\w+\))?s', tokens.Name.Placeholder),
37 (r'(?<!\w)[$:?]\w+', tokens.Name.Placeholder),
39 (r'\\\w+', tokens.Command),
41 # FIXME(andi): VALUES shouldn't be listed here
42 # see https://github.com/andialbrecht/sqlparse/pull/64
43 # AS and IN are special, it may be followed by a parenthesis, but
44 # are never functions, see issue183 and issue507
45 (r'(CASE|IN|VALUES|USING|FROM|AS)\b', tokens.Keyword),
47 (r'(@|##|#)[A-ZÀ-Ü]\w+', tokens.Name),
49 # see issue #39
50 # Spaces around period `schema . name` are valid identifier
51 # TODO: Spaces before period not implemented
52 (r'[A-ZÀ-Ü]\w*(?=\s*\.)', tokens.Name), # 'Name'.
53 # FIXME(atronah): never match,
54 # because `re.match` doesn't work with look-behind regexp feature
55 (r'(?<=\.)[A-ZÀ-Ü]\w*', tokens.Name), # .'Name'
56 (r'[A-ZÀ-Ü]\w*(?=\()', tokens.Name), # side effect: change kw to func
57 (r'-?0x[\dA-F]+', tokens.Number.Hexadecimal),
58 (r'-?\d+(\.\d+)?E-?\d+', tokens.Number.Float),
59 (r'(?![_A-ZÀ-Ü])-?(\d+(\.\d*)|\.\d+)(?![_A-ZÀ-Ü])',
60 tokens.Number.Float),
61 (r'(?![_A-ZÀ-Ü])-?\d+(?![_A-ZÀ-Ü])', tokens.Number.Integer),
62 (r"'(''|\\'|[^'])*'", tokens.String.Single),
63 # not a real string literal in ANSI SQL:
64 (r'"(""|\\"|[^"])*"', tokens.String.Symbol),
65 (r'(""|".*?[^\\]")', tokens.String.Symbol),
66 # sqlite names can be escaped with [square brackets]. left bracket
67 # cannot be preceded by word character or a right bracket --
68 # otherwise it's probably an array index
69 (r'(?<![\w\])])(\[[^\]\[]+\])', tokens.Name),
70 (r'((LEFT\s+|RIGHT\s+|FULL\s+)?(INNER\s+|OUTER\s+|STRAIGHT\s+)?'
71 r'|(CROSS\s+|NATURAL\s+)?)?JOIN\b', tokens.Keyword),
72 (r'END(\s+IF|\s+LOOP|\s+WHILE)?\b', tokens.Keyword),
73 (r'IF\s+(NOT\s+)?EXISTS\b', tokens.Keyword),
74 (r'NOT\s+NULL\b', tokens.Keyword),
75 (r'(ASC|DESC)(\s+NULLS\s+(FIRST|LAST))?\b', tokens.Keyword.Order),
76 (r'(ASC|DESC)\b', tokens.Keyword.Order),
77 (r'NULLS\s+(FIRST|LAST)\b', tokens.Keyword.Order),
78 (r'UNION\s+ALL\b', tokens.Keyword),
79 (r'CREATE(\s+OR\s+REPLACE)?\b', tokens.Keyword.DDL),
80 (r'DOUBLE\s+PRECISION\b', tokens.Name.Builtin),
81 (r'GROUP\s+BY\b', tokens.Keyword),
82 (r'ORDER\s+BY\b', tokens.Keyword),
83 (r'PRIMARY\s+KEY\b', tokens.Keyword),
84 (r'HANDLER\s+FOR\b', tokens.Keyword),
85 (r'GO(\s\d+)\b', tokens.Keyword),
86 (r'(LATERAL\s+VIEW\s+)'
87 r'(EXPLODE|INLINE|PARSE_URL_TUPLE|POSEXPLODE|STACK)\b',
88 tokens.Keyword),
89 (r"(AT|WITH')\s+TIME\s+ZONE\s+'[^']+'", tokens.Keyword.TZCast),
90 (r'(NOT\s+)?(LIKE|ILIKE|RLIKE)\b', tokens.Operator.Comparison),
91 (r'(NOT\s+)?(REGEXP)(\s+(BINARY))?\b', tokens.Operator.Comparison),
92 # Check for keywords, also returns tokens.Name if regex matches
93 # but the match isn't a keyword.
94 (r'\w[$#\w]*', PROCESS_AS_KEYWORD),
95 (r'[;:()\[\],\.]', tokens.Punctuation),
96 # JSON operators
97 (r'(\->>?|#>>?|@>|<@|\?\|?|\?&|\-|#\-)', tokens.Operator),
98 (r'[<>=~!]+', tokens.Operator.Comparison),
99 (r'[+/@#%^&|^-]+', tokens.Operator),
100]
102KEYWORDS = {
103 'ABORT': tokens.Keyword,
104 'ABS': tokens.Keyword,
105 'ABSOLUTE': tokens.Keyword,
106 'ACCESS': tokens.Keyword,
107 'ADA': tokens.Keyword,
108 'ADD': tokens.Keyword,
109 'ADMIN': tokens.Keyword,
110 'AFTER': tokens.Keyword,
111 'AGGREGATE': tokens.Keyword,
112 'ALIAS': tokens.Keyword,
113 'ALL': tokens.Keyword,
114 'ALLOCATE': tokens.Keyword,
115 'ANALYSE': tokens.Keyword,
116 'ANALYZE': tokens.Keyword,
117 'ANY': tokens.Keyword,
118 'ARRAYLEN': tokens.Keyword,
119 'ARE': tokens.Keyword,
120 'ASENSITIVE': tokens.Keyword,
121 'ASSERTION': tokens.Keyword,
122 'ASSIGNMENT': tokens.Keyword,
123 'ASYMMETRIC': tokens.Keyword,
124 'AT': tokens.Keyword,
125 'ATOMIC': tokens.Keyword,
126 'AUDIT': tokens.Keyword,
127 'AUTHORIZATION': tokens.Keyword,
128 'AUTO_INCREMENT': tokens.Keyword,
129 'AVG': tokens.Keyword,
131 'BACKWARD': tokens.Keyword,
132 'BEFORE': tokens.Keyword,
133 'BEGIN': tokens.Keyword,
134 'BETWEEN': tokens.Keyword,
135 'BITVAR': tokens.Keyword,
136 'BIT_LENGTH': tokens.Keyword,
137 'BOTH': tokens.Keyword,
138 'BREADTH': tokens.Keyword,
140 # 'C': tokens.Keyword, # most likely this is an alias
141 'CACHE': tokens.Keyword,
142 'CALL': tokens.Keyword,
143 'CALLED': tokens.Keyword,
144 'CARDINALITY': tokens.Keyword,
145 'CASCADE': tokens.Keyword,
146 'CASCADED': tokens.Keyword,
147 'CAST': tokens.Keyword,
148 'CATALOG': tokens.Keyword,
149 'CATALOG_NAME': tokens.Keyword,
150 'CHAIN': tokens.Keyword,
151 'CHARACTERISTICS': tokens.Keyword,
152 'CHARACTER_LENGTH': tokens.Keyword,
153 'CHARACTER_SET_CATALOG': tokens.Keyword,
154 'CHARACTER_SET_NAME': tokens.Keyword,
155 'CHARACTER_SET_SCHEMA': tokens.Keyword,
156 'CHAR_LENGTH': tokens.Keyword,
157 'CHARSET': tokens.Keyword,
158 'CHECK': tokens.Keyword,
159 'CHECKED': tokens.Keyword,
160 'CHECKPOINT': tokens.Keyword,
161 'CLASS': tokens.Keyword,
162 'CLASS_ORIGIN': tokens.Keyword,
163 'CLOB': tokens.Keyword,
164 'CLOSE': tokens.Keyword,
165 'CLUSTER': tokens.Keyword,
166 'COALESCE': tokens.Keyword,
167 'COBOL': tokens.Keyword,
168 'COLLATE': tokens.Keyword,
169 'COLLATION': tokens.Keyword,
170 'COLLATION_CATALOG': tokens.Keyword,
171 'COLLATION_NAME': tokens.Keyword,
172 'COLLATION_SCHEMA': tokens.Keyword,
173 'COLLECT': tokens.Keyword,
174 'COLUMN': tokens.Keyword,
175 'COLUMN_NAME': tokens.Keyword,
176 'COMPRESS': tokens.Keyword,
177 'COMMAND_FUNCTION': tokens.Keyword,
178 'COMMAND_FUNCTION_CODE': tokens.Keyword,
179 'COMMENT': tokens.Keyword,
180 'COMMIT': tokens.Keyword.DML,
181 'COMMITTED': tokens.Keyword,
182 'COMPLETION': tokens.Keyword,
183 'CONCURRENTLY': tokens.Keyword,
184 'CONDITION_NUMBER': tokens.Keyword,
185 'CONNECT': tokens.Keyword,
186 'CONNECTION': tokens.Keyword,
187 'CONNECTION_NAME': tokens.Keyword,
188 'CONSTRAINT': tokens.Keyword,
189 'CONSTRAINTS': tokens.Keyword,
190 'CONSTRAINT_CATALOG': tokens.Keyword,
191 'CONSTRAINT_NAME': tokens.Keyword,
192 'CONSTRAINT_SCHEMA': tokens.Keyword,
193 'CONSTRUCTOR': tokens.Keyword,
194 'CONTAINS': tokens.Keyword,
195 'CONTINUE': tokens.Keyword,
196 'CONVERSION': tokens.Keyword,
197 'CONVERT': tokens.Keyword,
198 'COPY': tokens.Keyword,
199 'CORRESPONDING': tokens.Keyword,
200 'COUNT': tokens.Keyword,
201 'CREATEDB': tokens.Keyword,
202 'CREATEUSER': tokens.Keyword,
203 'CROSS': tokens.Keyword,
204 'CUBE': tokens.Keyword,
205 'CURRENT': tokens.Keyword,
206 'CURRENT_DATE': tokens.Keyword,
207 'CURRENT_PATH': tokens.Keyword,
208 'CURRENT_ROLE': tokens.Keyword,
209 'CURRENT_TIME': tokens.Keyword,
210 'CURRENT_TIMESTAMP': tokens.Keyword,
211 'CURRENT_USER': tokens.Keyword,
212 'CURSOR': tokens.Keyword,
213 'CURSOR_NAME': tokens.Keyword,
214 'CYCLE': tokens.Keyword,
216 'DATA': tokens.Keyword,
217 'DATABASE': tokens.Keyword,
218 'DATETIME_INTERVAL_CODE': tokens.Keyword,
219 'DATETIME_INTERVAL_PRECISION': tokens.Keyword,
220 'DAY': tokens.Keyword,
221 'DEALLOCATE': tokens.Keyword,
222 'DECLARE': tokens.Keyword,
223 'DEFAULT': tokens.Keyword,
224 'DEFAULTS': tokens.Keyword,
225 'DEFERRABLE': tokens.Keyword,
226 'DEFERRED': tokens.Keyword,
227 'DEFINED': tokens.Keyword,
228 'DEFINER': tokens.Keyword,
229 'DELIMITER': tokens.Keyword,
230 'DELIMITERS': tokens.Keyword,
231 'DEREF': tokens.Keyword,
232 'DESCRIBE': tokens.Keyword,
233 'DESCRIPTOR': tokens.Keyword,
234 'DESTROY': tokens.Keyword,
235 'DESTRUCTOR': tokens.Keyword,
236 'DETERMINISTIC': tokens.Keyword,
237 'DIAGNOSTICS': tokens.Keyword,
238 'DICTIONARY': tokens.Keyword,
239 'DISABLE': tokens.Keyword,
240 'DISCONNECT': tokens.Keyword,
241 'DISPATCH': tokens.Keyword,
242 'DIV': tokens.Operator,
243 'DO': tokens.Keyword,
244 'DOMAIN': tokens.Keyword,
245 'DYNAMIC': tokens.Keyword,
246 'DYNAMIC_FUNCTION': tokens.Keyword,
247 'DYNAMIC_FUNCTION_CODE': tokens.Keyword,
249 'EACH': tokens.Keyword,
250 'ENABLE': tokens.Keyword,
251 'ENCODING': tokens.Keyword,
252 'ENCRYPTED': tokens.Keyword,
253 'END-EXEC': tokens.Keyword,
254 'ENGINE': tokens.Keyword,
255 'EQUALS': tokens.Keyword,
256 'ESCAPE': tokens.Keyword,
257 'EVERY': tokens.Keyword,
258 'EXCEPT': tokens.Keyword,
259 'EXCEPTION': tokens.Keyword,
260 'EXCLUDING': tokens.Keyword,
261 'EXCLUSIVE': tokens.Keyword,
262 'EXEC': tokens.Keyword,
263 'EXECUTE': tokens.Keyword,
264 'EXISTING': tokens.Keyword,
265 'EXISTS': tokens.Keyword,
266 'EXPLAIN': tokens.Keyword,
267 'EXTERNAL': tokens.Keyword,
268 'EXTRACT': tokens.Keyword,
270 'FALSE': tokens.Keyword,
271 'FETCH': tokens.Keyword,
272 'FILE': tokens.Keyword,
273 'FINAL': tokens.Keyword,
274 'FIRST': tokens.Keyword,
275 'FORCE': tokens.Keyword,
276 'FOREACH': tokens.Keyword,
277 'FOREIGN': tokens.Keyword,
278 'FORTRAN': tokens.Keyword,
279 'FORWARD': tokens.Keyword,
280 'FOUND': tokens.Keyword,
281 'FREE': tokens.Keyword,
282 'FREEZE': tokens.Keyword,
283 'FULL': tokens.Keyword,
284 'FUNCTION': tokens.Keyword,
286 # 'G': tokens.Keyword,
287 'GENERAL': tokens.Keyword,
288 'GENERATED': tokens.Keyword,
289 'GET': tokens.Keyword,
290 'GLOBAL': tokens.Keyword,
291 'GO': tokens.Keyword,
292 'GOTO': tokens.Keyword,
293 'GRANTED': tokens.Keyword,
294 'GROUPING': tokens.Keyword,
296 'HAVING': tokens.Keyword,
297 'HIERARCHY': tokens.Keyword,
298 'HOLD': tokens.Keyword,
299 'HOUR': tokens.Keyword,
300 'HOST': tokens.Keyword,
302 'IDENTIFIED': tokens.Keyword,
303 'IDENTITY': tokens.Keyword,
304 'IGNORE': tokens.Keyword,
305 'ILIKE': tokens.Keyword,
306 'IMMEDIATE': tokens.Keyword,
307 'IMMUTABLE': tokens.Keyword,
309 'IMPLEMENTATION': tokens.Keyword,
310 'IMPLICIT': tokens.Keyword,
311 'INCLUDING': tokens.Keyword,
312 'INCREMENT': tokens.Keyword,
313 'INDEX': tokens.Keyword,
315 'INDICATOR': tokens.Keyword,
316 'INFIX': tokens.Keyword,
317 'INHERITS': tokens.Keyword,
318 'INITIAL': tokens.Keyword,
319 'INITIALIZE': tokens.Keyword,
320 'INITIALLY': tokens.Keyword,
321 'INOUT': tokens.Keyword,
322 'INPUT': tokens.Keyword,
323 'INSENSITIVE': tokens.Keyword,
324 'INSTANTIABLE': tokens.Keyword,
325 'INSTEAD': tokens.Keyword,
326 'INTERSECT': tokens.Keyword,
327 'INTO': tokens.Keyword,
328 'INVOKER': tokens.Keyword,
329 'IS': tokens.Keyword,
330 'ISNULL': tokens.Keyword,
331 'ISOLATION': tokens.Keyword,
332 'ITERATE': tokens.Keyword,
334 # 'K': tokens.Keyword,
335 'KEY': tokens.Keyword,
336 'KEY_MEMBER': tokens.Keyword,
337 'KEY_TYPE': tokens.Keyword,
339 'LANCOMPILER': tokens.Keyword,
340 'LANGUAGE': tokens.Keyword,
341 'LARGE': tokens.Keyword,
342 'LAST': tokens.Keyword,
343 'LATERAL': tokens.Keyword,
344 'LEADING': tokens.Keyword,
345 'LENGTH': tokens.Keyword,
346 'LESS': tokens.Keyword,
347 'LEVEL': tokens.Keyword,
348 'LIMIT': tokens.Keyword,
349 'LISTEN': tokens.Keyword,
350 'LOAD': tokens.Keyword,
351 'LOCAL': tokens.Keyword,
352 'LOCALTIME': tokens.Keyword,
353 'LOCALTIMESTAMP': tokens.Keyword,
354 'LOCATION': tokens.Keyword,
355 'LOCATOR': tokens.Keyword,
356 'LOCK': tokens.Keyword,
357 'LOWER': tokens.Keyword,
359 # 'M': tokens.Keyword,
360 'MAP': tokens.Keyword,
361 'MATCH': tokens.Keyword,
362 'MAXEXTENTS': tokens.Keyword,
363 'MAXVALUE': tokens.Keyword,
364 'MESSAGE_LENGTH': tokens.Keyword,
365 'MESSAGE_OCTET_LENGTH': tokens.Keyword,
366 'MESSAGE_TEXT': tokens.Keyword,
367 'METHOD': tokens.Keyword,
368 'MINUTE': tokens.Keyword,
369 'MINUS': tokens.Keyword,
370 'MINVALUE': tokens.Keyword,
371 'MOD': tokens.Keyword,
372 'MODE': tokens.Keyword,
373 'MODIFIES': tokens.Keyword,
374 'MODIFY': tokens.Keyword,
375 'MONTH': tokens.Keyword,
376 'MORE': tokens.Keyword,
377 'MOVE': tokens.Keyword,
378 'MUMPS': tokens.Keyword,
380 'NAMES': tokens.Keyword,
381 'NATIONAL': tokens.Keyword,
382 'NATURAL': tokens.Keyword,
383 'NCHAR': tokens.Keyword,
384 'NCLOB': tokens.Keyword,
385 'NEW': tokens.Keyword,
386 'NEXT': tokens.Keyword,
387 'NO': tokens.Keyword,
388 'NOAUDIT': tokens.Keyword,
389 'NOCOMPRESS': tokens.Keyword,
390 'NOCREATEDB': tokens.Keyword,
391 'NOCREATEUSER': tokens.Keyword,
392 'NONE': tokens.Keyword,
393 'NOT': tokens.Keyword,
394 'NOTFOUND': tokens.Keyword,
395 'NOTHING': tokens.Keyword,
396 'NOTIFY': tokens.Keyword,
397 'NOTNULL': tokens.Keyword,
398 'NOWAIT': tokens.Keyword,
399 'NULL': tokens.Keyword,
400 'NULLABLE': tokens.Keyword,
401 'NULLIF': tokens.Keyword,
403 'OBJECT': tokens.Keyword,
404 'OCTET_LENGTH': tokens.Keyword,
405 'OF': tokens.Keyword,
406 'OFF': tokens.Keyword,
407 'OFFLINE': tokens.Keyword,
408 'OFFSET': tokens.Keyword,
409 'OIDS': tokens.Keyword,
410 'OLD': tokens.Keyword,
411 'ONLINE': tokens.Keyword,
412 'ONLY': tokens.Keyword,
413 'OPEN': tokens.Keyword,
414 'OPERATION': tokens.Keyword,
415 'OPERATOR': tokens.Keyword,
416 'OPTION': tokens.Keyword,
417 'OPTIONS': tokens.Keyword,
418 'ORDINALITY': tokens.Keyword,
419 'OUT': tokens.Keyword,
420 'OUTPUT': tokens.Keyword,
421 'OVERLAPS': tokens.Keyword,
422 'OVERLAY': tokens.Keyword,
423 'OVERRIDING': tokens.Keyword,
424 'OWNER': tokens.Keyword,
426 'QUARTER': tokens.Keyword,
428 'PAD': tokens.Keyword,
429 'PARAMETER': tokens.Keyword,
430 'PARAMETERS': tokens.Keyword,
431 'PARAMETER_MODE': tokens.Keyword,
432 'PARAMETER_NAME': tokens.Keyword,
433 'PARAMETER_ORDINAL_POSITION': tokens.Keyword,
434 'PARAMETER_SPECIFIC_CATALOG': tokens.Keyword,
435 'PARAMETER_SPECIFIC_NAME': tokens.Keyword,
436 'PARAMETER_SPECIFIC_SCHEMA': tokens.Keyword,
437 'PARTIAL': tokens.Keyword,
438 'PASCAL': tokens.Keyword,
439 'PCTFREE': tokens.Keyword,
440 'PENDANT': tokens.Keyword,
441 'PLACING': tokens.Keyword,
442 'PLI': tokens.Keyword,
443 'POSITION': tokens.Keyword,
444 'POSTFIX': tokens.Keyword,
445 'PRECISION': tokens.Keyword,
446 'PREFIX': tokens.Keyword,
447 'PREORDER': tokens.Keyword,
448 'PREPARE': tokens.Keyword,
449 'PRESERVE': tokens.Keyword,
450 'PRIMARY': tokens.Keyword,
451 'PRIOR': tokens.Keyword,
452 'PRIVILEGES': tokens.Keyword,
453 'PROCEDURAL': tokens.Keyword,
454 'PROCEDURE': tokens.Keyword,
455 'PUBLIC': tokens.Keyword,
457 'RAISE': tokens.Keyword,
458 'RAW': tokens.Keyword,
459 'READ': tokens.Keyword,
460 'READS': tokens.Keyword,
461 'RECHECK': tokens.Keyword,
462 'RECURSIVE': tokens.Keyword,
463 'REF': tokens.Keyword,
464 'REFERENCES': tokens.Keyword,
465 'REFERENCING': tokens.Keyword,
466 'REINDEX': tokens.Keyword,
467 'RELATIVE': tokens.Keyword,
468 'RENAME': tokens.Keyword,
469 'REPEATABLE': tokens.Keyword,
470 'RESET': tokens.Keyword,
471 'RESOURCE': tokens.Keyword,
472 'RESTART': tokens.Keyword,
473 'RESTRICT': tokens.Keyword,
474 'RESULT': tokens.Keyword,
475 'RETURN': tokens.Keyword,
476 'RETURNED_LENGTH': tokens.Keyword,
477 'RETURNED_OCTET_LENGTH': tokens.Keyword,
478 'RETURNED_SQLSTATE': tokens.Keyword,
479 'RETURNING': tokens.Keyword,
480 'RETURNS': tokens.Keyword,
481 'RIGHT': tokens.Keyword,
482 'ROLE': tokens.Keyword,
483 'ROLLBACK': tokens.Keyword.DML,
484 'ROLLUP': tokens.Keyword,
485 'ROUTINE': tokens.Keyword,
486 'ROUTINE_CATALOG': tokens.Keyword,
487 'ROUTINE_NAME': tokens.Keyword,
488 'ROUTINE_SCHEMA': tokens.Keyword,
489 'ROWS': tokens.Keyword,
490 'ROW_COUNT': tokens.Keyword,
491 'RULE': tokens.Keyword,
493 'SAVE_POINT': tokens.Keyword,
494 'SCALE': tokens.Keyword,
495 'SCHEMA': tokens.Keyword,
496 'SCHEMA_NAME': tokens.Keyword,
497 'SCOPE': tokens.Keyword,
498 'SCROLL': tokens.Keyword,
499 'SEARCH': tokens.Keyword,
500 'SECOND': tokens.Keyword,
501 'SECURITY': tokens.Keyword,
502 'SELF': tokens.Keyword,
503 'SENSITIVE': tokens.Keyword,
504 'SEQUENCE': tokens.Keyword,
505 'SERIALIZABLE': tokens.Keyword,
506 'SERVER_NAME': tokens.Keyword,
507 'SESSION': tokens.Keyword,
508 'SESSION_USER': tokens.Keyword,
509 'SETOF': tokens.Keyword,
510 'SETS': tokens.Keyword,
511 'SHARE': tokens.Keyword,
512 'SHOW': tokens.Keyword,
513 'SIMILAR': tokens.Keyword,
514 'SIMPLE': tokens.Keyword,
515 'SIZE': tokens.Keyword,
516 'SOME': tokens.Keyword,
517 'SOURCE': tokens.Keyword,
518 'SPACE': tokens.Keyword,
519 'SPECIFIC': tokens.Keyword,
520 'SPECIFICTYPE': tokens.Keyword,
521 'SPECIFIC_NAME': tokens.Keyword,
522 'SQL': tokens.Keyword,
523 'SQLBUF': tokens.Keyword,
524 'SQLCODE': tokens.Keyword,
525 'SQLERROR': tokens.Keyword,
526 'SQLEXCEPTION': tokens.Keyword,
527 'SQLSTATE': tokens.Keyword,
528 'SQLWARNING': tokens.Keyword,
529 'STABLE': tokens.Keyword,
530 'START': tokens.Keyword.DML,
531 # 'STATE': tokens.Keyword,
532 'STATEMENT': tokens.Keyword,
533 'STATIC': tokens.Keyword,
534 'STATISTICS': tokens.Keyword,
535 'STDIN': tokens.Keyword,
536 'STDOUT': tokens.Keyword,
537 'STORAGE': tokens.Keyword,
538 'STRICT': tokens.Keyword,
539 'STRUCTURE': tokens.Keyword,
540 'STYPE': tokens.Keyword,
541 'SUBCLASS_ORIGIN': tokens.Keyword,
542 'SUBLIST': tokens.Keyword,
543 'SUBSTRING': tokens.Keyword,
544 'SUCCESSFUL': tokens.Keyword,
545 'SUM': tokens.Keyword,
546 'SYMMETRIC': tokens.Keyword,
547 'SYNONYM': tokens.Keyword,
548 'SYSID': tokens.Keyword,
549 'SYSTEM': tokens.Keyword,
550 'SYSTEM_USER': tokens.Keyword,
552 'TABLE': tokens.Keyword,
553 'TABLE_NAME': tokens.Keyword,
554 'TEMP': tokens.Keyword,
555 'TEMPLATE': tokens.Keyword,
556 'TEMPORARY': tokens.Keyword,
557 'TERMINATE': tokens.Keyword,
558 'THAN': tokens.Keyword,
559 'TIMESTAMP': tokens.Keyword,
560 'TIMEZONE_HOUR': tokens.Keyword,
561 'TIMEZONE_MINUTE': tokens.Keyword,
562 'TO': tokens.Keyword,
563 'TOAST': tokens.Keyword,
564 'TRAILING': tokens.Keyword,
565 'TRANSATION': tokens.Keyword,
566 'TRANSACTIONS_COMMITTED': tokens.Keyword,
567 'TRANSACTIONS_ROLLED_BACK': tokens.Keyword,
568 'TRANSATION_ACTIVE': tokens.Keyword,
569 'TRANSFORM': tokens.Keyword,
570 'TRANSFORMS': tokens.Keyword,
571 'TRANSLATE': tokens.Keyword,
572 'TRANSLATION': tokens.Keyword,
573 'TREAT': tokens.Keyword,
574 'TRIGGER': tokens.Keyword,
575 'TRIGGER_CATALOG': tokens.Keyword,
576 'TRIGGER_NAME': tokens.Keyword,
577 'TRIGGER_SCHEMA': tokens.Keyword,
578 'TRIM': tokens.Keyword,
579 'TRUE': tokens.Keyword,
580 'TRUSTED': tokens.Keyword,
581 'TYPE': tokens.Keyword,
583 'UID': tokens.Keyword,
584 'UNCOMMITTED': tokens.Keyword,
585 'UNDER': tokens.Keyword,
586 'UNENCRYPTED': tokens.Keyword,
587 'UNION': tokens.Keyword,
588 'UNIQUE': tokens.Keyword,
589 'UNKNOWN': tokens.Keyword,
590 'UNLISTEN': tokens.Keyword,
591 'UNNAMED': tokens.Keyword,
592 'UNNEST': tokens.Keyword,
593 'UNTIL': tokens.Keyword,
594 'UPPER': tokens.Keyword,
595 'USAGE': tokens.Keyword,
596 'USE': tokens.Keyword,
597 'USER': tokens.Keyword,
598 'USER_DEFINED_TYPE_CATALOG': tokens.Keyword,
599 'USER_DEFINED_TYPE_NAME': tokens.Keyword,
600 'USER_DEFINED_TYPE_SCHEMA': tokens.Keyword,
601 'USING': tokens.Keyword,
603 'VACUUM': tokens.Keyword,
604 'VALID': tokens.Keyword,
605 'VALIDATE': tokens.Keyword,
606 'VALIDATOR': tokens.Keyword,
607 'VALUES': tokens.Keyword,
608 'VARIABLE': tokens.Keyword,
609 'VERBOSE': tokens.Keyword,
610 'VERSION': tokens.Keyword,
611 'VIEW': tokens.Keyword,
612 'VOLATILE': tokens.Keyword,
614 'WEEK': tokens.Keyword,
615 'WHENEVER': tokens.Keyword,
616 'WITH': tokens.Keyword.CTE,
617 'WITHOUT': tokens.Keyword,
618 'WORK': tokens.Keyword,
619 'WRITE': tokens.Keyword,
621 'YEAR': tokens.Keyword,
623 'ZONE': tokens.Keyword,
625 # Name.Builtin
626 'ARRAY': tokens.Name.Builtin,
627 'BIGINT': tokens.Name.Builtin,
628 'BINARY': tokens.Name.Builtin,
629 'BIT': tokens.Name.Builtin,
630 'BLOB': tokens.Name.Builtin,
631 'BOOLEAN': tokens.Name.Builtin,
632 'CHAR': tokens.Name.Builtin,
633 'CHARACTER': tokens.Name.Builtin,
634 'DATE': tokens.Name.Builtin,
635 'DEC': tokens.Name.Builtin,
636 'DECIMAL': tokens.Name.Builtin,
637 'FILE_TYPE': tokens.Name.Builtin,
638 'FLOAT': tokens.Name.Builtin,
639 'INT': tokens.Name.Builtin,
640 'INT8': tokens.Name.Builtin,
641 'INTEGER': tokens.Name.Builtin,
642 'INTERVAL': tokens.Name.Builtin,
643 'LONG': tokens.Name.Builtin,
644 'NATURALN': tokens.Name.Builtin,
645 'NVARCHAR': tokens.Name.Builtin,
646 'NUMBER': tokens.Name.Builtin,
647 'NUMERIC': tokens.Name.Builtin,
648 'PLS_INTEGER': tokens.Name.Builtin,
649 'POSITIVE': tokens.Name.Builtin,
650 'POSITIVEN': tokens.Name.Builtin,
651 'REAL': tokens.Name.Builtin,
652 'ROWID': tokens.Name.Builtin,
653 'ROWLABEL': tokens.Name.Builtin,
654 'ROWNUM': tokens.Name.Builtin,
655 'SERIAL': tokens.Name.Builtin,
656 'SERIAL8': tokens.Name.Builtin,
657 'SIGNED': tokens.Name.Builtin,
658 'SIGNTYPE': tokens.Name.Builtin,
659 'SIMPLE_DOUBLE': tokens.Name.Builtin,
660 'SIMPLE_FLOAT': tokens.Name.Builtin,
661 'SIMPLE_INTEGER': tokens.Name.Builtin,
662 'SMALLINT': tokens.Name.Builtin,
663 'SYS_REFCURSOR': tokens.Name.Builtin,
664 'SYSDATE': tokens.Name,
665 'TEXT': tokens.Name.Builtin,
666 'TINYINT': tokens.Name.Builtin,
667 'UNSIGNED': tokens.Name.Builtin,
668 'UROWID': tokens.Name.Builtin,
669 'UTL_FILE': tokens.Name.Builtin,
670 'VARCHAR': tokens.Name.Builtin,
671 'VARCHAR2': tokens.Name.Builtin,
672 'VARYING': tokens.Name.Builtin,
673}
675KEYWORDS_COMMON = {
676 'SELECT': tokens.Keyword.DML,
677 'INSERT': tokens.Keyword.DML,
678 'DELETE': tokens.Keyword.DML,
679 'UPDATE': tokens.Keyword.DML,
680 'UPSERT': tokens.Keyword.DML,
681 'REPLACE': tokens.Keyword.DML,
682 'MERGE': tokens.Keyword.DML,
683 'DROP': tokens.Keyword.DDL,
684 'CREATE': tokens.Keyword.DDL,
685 'ALTER': tokens.Keyword.DDL,
686 'TRUNCATE': tokens.Keyword.DDL,
687 'GRANT': tokens.Keyword.DCL,
688 'REVOKE': tokens.Keyword.DCL,
690 'WHERE': tokens.Keyword,
691 'FROM': tokens.Keyword,
692 'INNER': tokens.Keyword,
693 'JOIN': tokens.Keyword,
694 'STRAIGHT_JOIN': tokens.Keyword,
695 'AND': tokens.Keyword,
696 'OR': tokens.Keyword,
697 'LIKE': tokens.Keyword,
698 'ON': tokens.Keyword,
699 'IN': tokens.Keyword,
700 'SET': tokens.Keyword,
702 'BY': tokens.Keyword,
703 'GROUP': tokens.Keyword,
704 'ORDER': tokens.Keyword,
705 'LEFT': tokens.Keyword,
706 'OUTER': tokens.Keyword,
707 'FULL': tokens.Keyword,
709 'IF': tokens.Keyword,
710 'END': tokens.Keyword,
711 'THEN': tokens.Keyword,
712 'LOOP': tokens.Keyword,
713 'AS': tokens.Keyword,
714 'ELSE': tokens.Keyword,
715 'FOR': tokens.Keyword,
716 'WHILE': tokens.Keyword,
718 'CASE': tokens.Keyword,
719 'WHEN': tokens.Keyword,
720 'MIN': tokens.Keyword,
721 'MAX': tokens.Keyword,
722 'DISTINCT': tokens.Keyword,
723}
725KEYWORDS_ORACLE = {
726 'ARCHIVE': tokens.Keyword,
727 'ARCHIVELOG': tokens.Keyword,
729 'BACKUP': tokens.Keyword,
730 'BECOME': tokens.Keyword,
731 'BLOCK': tokens.Keyword,
732 'BODY': tokens.Keyword,
734 'CANCEL': tokens.Keyword,
735 'CHANGE': tokens.Keyword,
736 'COMPILE': tokens.Keyword,
737 'CONTENTS': tokens.Keyword,
738 'CONTROLFILE': tokens.Keyword,
740 'DATAFILE': tokens.Keyword,
741 'DBA': tokens.Keyword,
742 'DISMOUNT': tokens.Keyword,
743 'DOUBLE': tokens.Keyword,
744 'DUMP': tokens.Keyword,
746 'ELSIF': tokens.Keyword,
747 'EVENTS': tokens.Keyword,
748 'EXCEPTIONS': tokens.Keyword,
749 'EXPLAIN': tokens.Keyword,
750 'EXTENT': tokens.Keyword,
751 'EXTERNALLY': tokens.Keyword,
753 'FLUSH': tokens.Keyword,
754 'FREELIST': tokens.Keyword,
755 'FREELISTS': tokens.Keyword,
757 # groups seems too common as table name
758 # 'GROUPS': tokens.Keyword,
760 'INDICATOR': tokens.Keyword,
761 'INITRANS': tokens.Keyword,
762 'INSTANCE': tokens.Keyword,
764 'LAYER': tokens.Keyword,
765 'LINK': tokens.Keyword,
766 'LISTS': tokens.Keyword,
767 'LOGFILE': tokens.Keyword,
769 'MANAGE': tokens.Keyword,
770 'MANUAL': tokens.Keyword,
771 'MAXDATAFILES': tokens.Keyword,
772 'MAXINSTANCES': tokens.Keyword,
773 'MAXLOGFILES': tokens.Keyword,
774 'MAXLOGHISTORY': tokens.Keyword,
775 'MAXLOGMEMBERS': tokens.Keyword,
776 'MAXTRANS': tokens.Keyword,
777 'MINEXTENTS': tokens.Keyword,
778 'MODULE': tokens.Keyword,
779 'MOUNT': tokens.Keyword,
781 'NOARCHIVELOG': tokens.Keyword,
782 'NOCACHE': tokens.Keyword,
783 'NOCYCLE': tokens.Keyword,
784 'NOMAXVALUE': tokens.Keyword,
785 'NOMINVALUE': tokens.Keyword,
786 'NOORDER': tokens.Keyword,
787 'NORESETLOGS': tokens.Keyword,
788 'NORMAL': tokens.Keyword,
789 'NOSORT': tokens.Keyword,
791 'OPTIMAL': tokens.Keyword,
792 'OWN': tokens.Keyword,
794 'PACKAGE': tokens.Keyword,
795 'PARALLEL': tokens.Keyword,
796 'PCTINCREASE': tokens.Keyword,
797 'PCTUSED': tokens.Keyword,
798 'PLAN': tokens.Keyword,
799 'PRIVATE': tokens.Keyword,
800 'PROFILE': tokens.Keyword,
802 'QUOTA': tokens.Keyword,
804 'RECOVER': tokens.Keyword,
805 'RESETLOGS': tokens.Keyword,
806 'RESTRICTED': tokens.Keyword,
807 'REUSE': tokens.Keyword,
808 'ROLES': tokens.Keyword,
810 'SAVEPOINT': tokens.Keyword,
811 'SCN': tokens.Keyword,
812 'SECTION': tokens.Keyword,
813 'SEGMENT': tokens.Keyword,
814 'SHARED': tokens.Keyword,
815 'SNAPSHOT': tokens.Keyword,
816 'SORT': tokens.Keyword,
817 'STATEMENT_ID': tokens.Keyword,
818 'STOP': tokens.Keyword,
819 'SWITCH': tokens.Keyword,
821 'TABLES': tokens.Keyword,
822 'TABLESPACE': tokens.Keyword,
823 'THREAD': tokens.Keyword,
824 'TIME': tokens.Keyword,
825 'TRACING': tokens.Keyword,
826 'TRANSACTION': tokens.Keyword,
827 'TRIGGERS': tokens.Keyword,
829 'UNLIMITED': tokens.Keyword,
830 'UNLOCK': tokens.Keyword,
831}
833# MySQL
834KEYWORDS_MYSQL = {
835 'ROW': tokens.Keyword,
836}
838# PostgreSQL Syntax
839KEYWORDS_PLPGSQL = {
840 'CONFLICT': tokens.Keyword,
841 'WINDOW': tokens.Keyword,
842 'PARTITION': tokens.Keyword,
843 'ATTACH': tokens.Keyword,
844 'DETACH': tokens.Keyword,
845 'OVER': tokens.Keyword,
846 'PERFORM': tokens.Keyword,
847 'NOTICE': tokens.Keyword,
848 'PLPGSQL': tokens.Keyword,
849 'INHERIT': tokens.Keyword,
850 'INDEXES': tokens.Keyword,
851 'ON_ERROR_STOP': tokens.Keyword,
852 'EXTENSION': tokens.Keyword,
854 'BYTEA': tokens.Keyword,
855 'BIGSERIAL': tokens.Keyword,
856 'BIT VARYING': tokens.Keyword,
857 'BOX': tokens.Keyword,
858 'CHARACTER': tokens.Keyword,
859 'CHARACTER VARYING': tokens.Keyword,
860 'CIDR': tokens.Keyword,
861 'CIRCLE': tokens.Keyword,
862 'DOUBLE PRECISION': tokens.Keyword,
863 'INET': tokens.Keyword,
864 'JSON': tokens.Keyword,
865 'JSONB': tokens.Keyword,
866 'LINE': tokens.Keyword,
867 'LSEG': tokens.Keyword,
868 'MACADDR': tokens.Keyword,
869 'MONEY': tokens.Keyword,
870 'PATH': tokens.Keyword,
871 'PG_LSN': tokens.Keyword,
872 'POINT': tokens.Keyword,
873 'POLYGON': tokens.Keyword,
874 'SMALLSERIAL': tokens.Keyword,
875 'TSQUERY': tokens.Keyword,
876 'TSVECTOR': tokens.Keyword,
877 'TXID_SNAPSHOT': tokens.Keyword,
878 'UUID': tokens.Keyword,
879 'XML': tokens.Keyword,
881 'FOR': tokens.Keyword,
882 'IN': tokens.Keyword,
883 'LOOP': tokens.Keyword,
884}
886# Hive Syntax
887KEYWORDS_HQL = {
888 'EXPLODE': tokens.Keyword,
889 'DIRECTORY': tokens.Keyword,
890 'DISTRIBUTE': tokens.Keyword,
891 'INCLUDE': tokens.Keyword,
892 'LOCATE': tokens.Keyword,
893 'OVERWRITE': tokens.Keyword,
894 'POSEXPLODE': tokens.Keyword,
896 'ARRAY_CONTAINS': tokens.Keyword,
897 'CMP': tokens.Keyword,
898 'COLLECT_LIST': tokens.Keyword,
899 'CONCAT': tokens.Keyword,
900 'CONDITION': tokens.Keyword,
901 'DATE_ADD': tokens.Keyword,
902 'DATE_SUB': tokens.Keyword,
903 'DECODE': tokens.Keyword,
904 'DBMS_OUTPUT': tokens.Keyword,
905 'ELEMENTS': tokens.Keyword,
906 'EXCHANGE': tokens.Keyword,
907 'EXTENDED': tokens.Keyword,
908 'FLOOR': tokens.Keyword,
909 'FOLLOWING': tokens.Keyword,
910 'FROM_UNIXTIME': tokens.Keyword,
911 'FTP': tokens.Keyword,
912 'HOUR': tokens.Keyword,
913 'INLINE': tokens.Keyword,
914 'INSTR': tokens.Keyword,
915 'LEN': tokens.Keyword,
916 'MAP': tokens.Name.Builtin,
917 'MAXELEMENT': tokens.Keyword,
918 'MAXINDEX': tokens.Keyword,
919 'MAX_PART_DATE': tokens.Keyword,
920 'MAX_PART_INT': tokens.Keyword,
921 'MAX_PART_STRING': tokens.Keyword,
922 'MINELEMENT': tokens.Keyword,
923 'MININDEX': tokens.Keyword,
924 'MIN_PART_DATE': tokens.Keyword,
925 'MIN_PART_INT': tokens.Keyword,
926 'MIN_PART_STRING': tokens.Keyword,
927 'NOW': tokens.Keyword,
928 'NVL': tokens.Keyword,
929 'NVL2': tokens.Keyword,
930 'PARSE_URL_TUPLE': tokens.Keyword,
931 'PART_LOC': tokens.Keyword,
932 'PART_COUNT': tokens.Keyword,
933 'PART_COUNT_BY': tokens.Keyword,
934 'PRINT': tokens.Keyword,
935 'PUT_LINE': tokens.Keyword,
936 'RANGE': tokens.Keyword,
937 'REDUCE': tokens.Keyword,
938 'REGEXP_REPLACE': tokens.Keyword,
939 'RESIGNAL': tokens.Keyword,
940 'RTRIM': tokens.Keyword,
941 'SIGN': tokens.Keyword,
942 'SIGNAL': tokens.Keyword,
943 'SIN': tokens.Keyword,
944 'SPLIT': tokens.Keyword,
945 'SQRT': tokens.Keyword,
946 'STACK': tokens.Keyword,
947 'STR': tokens.Keyword,
948 'STRING': tokens.Name.Builtin,
949 'STRUCT': tokens.Name.Builtin,
950 'SUBSTR': tokens.Keyword,
951 'SUMMARY': tokens.Keyword,
952 'TBLPROPERTIES': tokens.Keyword,
953 'TIMESTAMP': tokens.Name.Builtin,
954 'TIMESTAMP_ISO': tokens.Keyword,
955 'TO_CHAR': tokens.Keyword,
956 'TO_DATE': tokens.Keyword,
957 'TO_TIMESTAMP': tokens.Keyword,
958 'TRUNC': tokens.Keyword,
959 'UNBOUNDED': tokens.Keyword,
960 'UNIQUEJOIN': tokens.Keyword,
961 'UNIX_TIMESTAMP': tokens.Keyword,
962 'UTC_TIMESTAMP': tokens.Keyword,
963 'VIEWS': tokens.Keyword,
965 'EXIT': tokens.Keyword,
966 'BREAK': tokens.Keyword,
967 'LEAVE': tokens.Keyword,
968}
971KEYWORDS_MSACCESS = {
972 'DISTINCTROW': tokens.Keyword,
973}
976KEYWORDS_SNOWFLAKE = {
977 'ACCOUNT': tokens.Keyword,
978 'GSCLUSTER': tokens.Keyword,
979 'ISSUE': tokens.Keyword,
980 'ORGANIZATION': tokens.Keyword,
981 'PIVOT': tokens.Keyword,
982 'QUALIFY': tokens.Keyword,
983 'REGEXP': tokens.Keyword,
984 'RLIKE': tokens.Keyword,
985 'SAMPLE': tokens.Keyword,
986 'TRY_CAST': tokens.Keyword,
987 'UNPIVOT': tokens.Keyword,
989 'VARIANT': tokens.Name.Builtin,
990}
993KEYWORDS_BIGQUERY = {
994 'ASSERT_ROWS_MODIFIED': tokens.Keyword,
995 'DEFINE': tokens.Keyword,
996 'ENUM': tokens.Keyword,
997 'HASH': tokens.Keyword,
998 'LOOKUP': tokens.Keyword,
999 'PRECEDING': tokens.Keyword,
1000 'PROTO': tokens.Keyword,
1001 'RESPECT': tokens.Keyword,
1002 'TABLESAMPLE': tokens.Keyword,
1004 'BIGNUMERIC': tokens.Name.Builtin,
1005}