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