Edit on GitHub

# sqlglot.dialects.oracle

View Source

      1from __future__ import annotations
      2
      3import typing as t
      4
      5from sqlglot import exp, generator, parser, tokens, transforms
      6from sqlglot.dialects.dialect import Dialect, no_ilike_sql, rename_func, trim_sql
      7from sqlglot.helper import seq_get
      8from sqlglot.tokens import TokenType
      9
     10if t.TYPE_CHECKING:
     11    from sqlglot._typing import E
     12
     13
     14def _parse_xml_table(self: Oracle.Parser) -> exp.XMLTable:
     15    this = self._parse_string()
     16
     17    passing = None
     18    columns = None
     19
     20    if self._match_text_seq("PASSING"):
     21        # The BY VALUE keywords are optional and are provided for semantic clarity
     22        self._match_text_seq("BY", "VALUE")
     23        passing = self._parse_csv(self._parse_column)
     24
     25    by_ref = self._match_text_seq("RETURNING", "SEQUENCE", "BY", "REF")
     26
     27    if self._match_text_seq("COLUMNS"):
     28        columns = self._parse_csv(self._parse_field_def)
     29
     30    return self.expression(exp.XMLTable, this=this, passing=passing, columns=columns, by_ref=by_ref)
     31
     32
     33class Oracle(Dialect):
     34    ALIAS_POST_TABLESAMPLE = True
     35    LOCKING_READS_SUPPORTED = True
     36
     37    # See section 8: https://docs.oracle.com/cd/A97630_01/server.920/a96540/sql_elements9a.htm
     38    RESOLVES_IDENTIFIERS_AS_UPPERCASE = True
     39
     40    # https://docs.oracle.com/database/121/SQLRF/sql_elements004.htm#SQLRF00212
     41    # https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes
     42    TIME_MAPPING = {
     43        "AM": "%p",  # Meridian indicator with or without periods
     44        "A.M.": "%p",  # Meridian indicator with or without periods
     45        "PM": "%p",  # Meridian indicator with or without periods
     46        "P.M.": "%p",  # Meridian indicator with or without periods
     47        "D": "%u",  # Day of week (1-7)
     48        "DAY": "%A",  # name of day
     49        "DD": "%d",  # day of month (1-31)
     50        "DDD": "%j",  # day of year (1-366)
     51        "DY": "%a",  # abbreviated name of day
     52        "HH": "%I",  # Hour of day (1-12)
     53        "HH12": "%I",  # alias for HH
     54        "HH24": "%H",  # Hour of day (0-23)
     55        "IW": "%V",  # Calendar week of year (1-52 or 1-53), as defined by the ISO 8601 standard
     56        "MI": "%M",  # Minute (0-59)
     57        "MM": "%m",  # Month (01-12; January = 01)
     58        "MON": "%b",  # Abbreviated name of month
     59        "MONTH": "%B",  # Name of month
     60        "SS": "%S",  # Second (0-59)
     61        "WW": "%W",  # Week of year (1-53)
     62        "YY": "%y",  # 15
     63        "YYYY": "%Y",  # 2015
     64    }
     65
     66    class Parser(parser.Parser):
     67        WINDOW_BEFORE_PAREN_TOKENS = {TokenType.OVER, TokenType.KEEP}
     68
     69        FUNCTIONS = {
     70            **parser.Parser.FUNCTIONS,
     71            "SQUARE": lambda args: exp.Pow(this=seq_get(args, 0), expression=exp.Literal.number(2)),
     72        }
     73
     74        FUNCTION_PARSERS: t.Dict[str, t.Callable] = {
     75            **parser.Parser.FUNCTION_PARSERS,
     76            "JSON_ARRAY": lambda self: self._parse_json_array(
     77                exp.JSONArray,
     78                expressions=self._parse_csv(lambda: self._parse_format_json(self._parse_bitwise())),
     79            ),
     80            "JSON_ARRAYAGG": lambda self: self._parse_json_array(
     81                exp.JSONArrayAgg,
     82                this=self._parse_format_json(self._parse_bitwise()),
     83                order=self._parse_order(),
     84            ),
     85            "JSON_TABLE": lambda self: self._parse_json_table(),
     86            "XMLTABLE": _parse_xml_table,
     87        }
     88
     89        TYPE_LITERAL_PARSERS = {
     90            exp.DataType.Type.DATE: lambda self, this, _: self.expression(
     91                exp.DateStrToDate, this=this
     92            )
     93        }
     94
     95        # SELECT UNIQUE .. is old-style Oracle syntax for SELECT DISTINCT ..
     96        # Reference: https://stackoverflow.com/a/336455
     97        DISTINCT_TOKENS = {TokenType.DISTINCT, TokenType.UNIQUE}
     98
     99        # Note: this is currently incomplete; it only implements the "JSON_value_column" part
    100        def _parse_json_column_def(self) -> exp.JSONColumnDef:
    101            this = self._parse_id_var()
    102            kind = self._parse_types(allow_identifiers=False)
    103            path = self._match_text_seq("PATH") and self._parse_string()
    104            return self.expression(exp.JSONColumnDef, this=this, kind=kind, path=path)
    105
    106        def _parse_json_table(self) -> exp.JSONTable:
    107            this = self._parse_format_json(self._parse_bitwise())
    108            path = self._match(TokenType.COMMA) and self._parse_string()
    109            error_handling = self._parse_on_handling("ERROR", "ERROR", "NULL")
    110            empty_handling = self._parse_on_handling("EMPTY", "ERROR", "NULL")
    111            self._match(TokenType.COLUMN)
    112            expressions = self._parse_wrapped_csv(self._parse_json_column_def, optional=True)
    113
    114            return exp.JSONTable(
    115                this=this,
    116                expressions=expressions,
    117                path=path,
    118                error_handling=error_handling,
    119                empty_handling=empty_handling,
    120            )
    121
    122        def _parse_json_array(self, expr_type: t.Type[E], **kwargs) -> E:
    123            return self.expression(
    124                expr_type,
    125                null_handling=self._parse_on_handling("NULL", "NULL", "ABSENT"),
    126                return_type=self._match_text_seq("RETURNING") and self._parse_type(),
    127                strict=self._match_text_seq("STRICT"),
    128                **kwargs,
    129            )
    130
    131        def _parse_column(self) -> t.Optional[exp.Expression]:
    132            column = super()._parse_column()
    133            if column:
    134                column.set("join_mark", self._match(TokenType.JOIN_MARKER))
    135            return column
    136
    137        def _parse_hint(self) -> t.Optional[exp.Hint]:
    138            if self._match(TokenType.HINT):
    139                start = self._curr
    140                while self._curr and not self._match_pair(TokenType.STAR, TokenType.SLASH):
    141                    self._advance()
    142
    143                if not self._curr:
    144                    self.raise_error("Expected */ after HINT")
    145
    146                end = self._tokens[self._index - 3]
    147                return exp.Hint(expressions=[self._find_sql(start, end)])
    148
    149            return None
    150
    151    class Generator(generator.Generator):
    152        LOCKING_READS_SUPPORTED = True
    153        JOIN_HINTS = False
    154        TABLE_HINTS = False
    155        COLUMN_JOIN_MARKS_SUPPORTED = True
    156        DATA_TYPE_SPECIFIERS_ALLOWED = True
    157
    158        LIMIT_FETCH = "FETCH"
    159
    160        TYPE_MAPPING = {
    161            **generator.Generator.TYPE_MAPPING,
    162            exp.DataType.Type.TINYINT: "NUMBER",
    163            exp.DataType.Type.SMALLINT: "NUMBER",
    164            exp.DataType.Type.INT: "NUMBER",
    165            exp.DataType.Type.BIGINT: "NUMBER",
    166            exp.DataType.Type.DECIMAL: "NUMBER",
    167            exp.DataType.Type.DOUBLE: "DOUBLE PRECISION",
    168            exp.DataType.Type.VARCHAR: "VARCHAR2",
    169            exp.DataType.Type.NVARCHAR: "NVARCHAR2",
    170            exp.DataType.Type.NCHAR: "NCHAR",
    171            exp.DataType.Type.TEXT: "CLOB",
    172            exp.DataType.Type.BINARY: "BLOB",
    173            exp.DataType.Type.VARBINARY: "BLOB",
    174        }
    175
    176        TRANSFORMS = {
    177            **generator.Generator.TRANSFORMS,
    178            exp.DateStrToDate: lambda self, e: self.func(
    179                "TO_DATE", e.this, exp.Literal.string("YYYY-MM-DD")
    180            ),
    181            exp.Group: transforms.preprocess([transforms.unalias_group]),
    182            exp.ILike: no_ilike_sql,
    183            exp.Select: transforms.preprocess(
    184                [
    185                    transforms.eliminate_distinct_on,
    186                    transforms.eliminate_qualify,
    187                ]
    188            ),
    189            exp.StrToTime: lambda self, e: f"TO_TIMESTAMP({self.sql(e, 'this')}, {self.format_time(e)})",
    190            exp.Subquery: lambda self, e: self.subquery_sql(e, sep=" "),
    191            exp.Substring: rename_func("SUBSTR"),
    192            exp.Table: lambda self, e: self.table_sql(e, sep=" "),
    193            exp.TableSample: lambda self, e: self.tablesample_sql(e, sep=" "),
    194            exp.TimeToStr: lambda self, e: f"TO_CHAR({self.sql(e, 'this')}, {self.format_time(e)})",
    195            exp.ToChar: lambda self, e: self.function_fallback_sql(e),
    196            exp.Trim: trim_sql,
    197            exp.UnixToTime: lambda self, e: f"TO_DATE('1970-01-01','YYYY-MM-DD') + ({self.sql(e, 'this')} / 86400)",
    198        }
    199
    200        PROPERTIES_LOCATION = {
    201            **generator.Generator.PROPERTIES_LOCATION,
    202            exp.VolatileProperty: exp.Properties.Location.UNSUPPORTED,
    203        }
    204
    205        def offset_sql(self, expression: exp.Offset) -> str:
    206            return f"{super().offset_sql(expression)} ROWS"
    207
    208        def xmltable_sql(self, expression: exp.XMLTable) -> str:
    209            this = self.sql(expression, "this")
    210            passing = self.expressions(expression, key="passing")
    211            passing = f"{self.sep()}PASSING{self.seg(passing)}" if passing else ""
    212            columns = self.expressions(expression, key="columns")
    213            columns = f"{self.sep()}COLUMNS{self.seg(columns)}" if columns else ""
    214            by_ref = (
    215                f"{self.sep()}RETURNING SEQUENCE BY REF" if expression.args.get("by_ref") else ""
    216            )
    217            return f"XMLTABLE({self.sep('')}{self.indent(this + passing + by_ref + columns)}{self.seg(')', sep='')}"
    218
    219    class Tokenizer(tokens.Tokenizer):
    220        VAR_SINGLE_TOKENS = {"@", "$", "#"}
    221
    222        KEYWORDS = {
    223            **tokens.Tokenizer.KEYWORDS,
    224            "(+)": TokenType.JOIN_MARKER,
    225            "BINARY_DOUBLE": TokenType.DOUBLE,
    226            "BINARY_FLOAT": TokenType.FLOAT,
    227            "COLUMNS": TokenType.COLUMN,
    228            "MATCH_RECOGNIZE": TokenType.MATCH_RECOGNIZE,
    229            "MINUS": TokenType.EXCEPT,
    230            "NVARCHAR2": TokenType.NVARCHAR,
    231            "SAMPLE": TokenType.TABLE_SAMPLE,
    232            "START": TokenType.BEGIN,
    233            "TOP": TokenType.TOP,
    234            "VARCHAR2": TokenType.VARCHAR,
    235        }

class Oracle(sqlglot.dialects.dialect.Dialect): View Source

     34class Oracle(Dialect):
     35    ALIAS_POST_TABLESAMPLE = True
     36    LOCKING_READS_SUPPORTED = True
     37
     38    # See section 8: https://docs.oracle.com/cd/A97630_01/server.920/a96540/sql_elements9a.htm
     39    RESOLVES_IDENTIFIERS_AS_UPPERCASE = True
     40
     41    # https://docs.oracle.com/database/121/SQLRF/sql_elements004.htm#SQLRF00212
     42    # https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes
     43    TIME_MAPPING = {
     44        "AM": "%p",  # Meridian indicator with or without periods
     45        "A.M.": "%p",  # Meridian indicator with or without periods
     46        "PM": "%p",  # Meridian indicator with or without periods
     47        "P.M.": "%p",  # Meridian indicator with or without periods
     48        "D": "%u",  # Day of week (1-7)
     49        "DAY": "%A",  # name of day
     50        "DD": "%d",  # day of month (1-31)
     51        "DDD": "%j",  # day of year (1-366)
     52        "DY": "%a",  # abbreviated name of day
     53        "HH": "%I",  # Hour of day (1-12)
     54        "HH12": "%I",  # alias for HH
     55        "HH24": "%H",  # Hour of day (0-23)
     56        "IW": "%V",  # Calendar week of year (1-52 or 1-53), as defined by the ISO 8601 standard
     57        "MI": "%M",  # Minute (0-59)
     58        "MM": "%m",  # Month (01-12; January = 01)
     59        "MON": "%b",  # Abbreviated name of month
     60        "MONTH": "%B",  # Name of month
     61        "SS": "%S",  # Second (0-59)
     62        "WW": "%W",  # Week of year (1-53)
     63        "YY": "%y",  # 15
     64        "YYYY": "%Y",  # 2015
     65    }
     66
     67    class Parser(parser.Parser):
     68        WINDOW_BEFORE_PAREN_TOKENS = {TokenType.OVER, TokenType.KEEP}
     69
     70        FUNCTIONS = {
     71            **parser.Parser.FUNCTIONS,
     72            "SQUARE": lambda args: exp.Pow(this=seq_get(args, 0), expression=exp.Literal.number(2)),
     73        }
     74
     75        FUNCTION_PARSERS: t.Dict[str, t.Callable] = {
     76            **parser.Parser.FUNCTION_PARSERS,
     77            "JSON_ARRAY": lambda self: self._parse_json_array(
     78                exp.JSONArray,
     79                expressions=self._parse_csv(lambda: self._parse_format_json(self._parse_bitwise())),
     80            ),
     81            "JSON_ARRAYAGG": lambda self: self._parse_json_array(
     82                exp.JSONArrayAgg,
     83                this=self._parse_format_json(self._parse_bitwise()),
     84                order=self._parse_order(),
     85            ),
     86            "JSON_TABLE": lambda self: self._parse_json_table(),
     87            "XMLTABLE": _parse_xml_table,
     88        }
     89
     90        TYPE_LITERAL_PARSERS = {
     91            exp.DataType.Type.DATE: lambda self, this, _: self.expression(
     92                exp.DateStrToDate, this=this
     93            )
     94        }
     95
     96        # SELECT UNIQUE .. is old-style Oracle syntax for SELECT DISTINCT ..
     97        # Reference: https://stackoverflow.com/a/336455
     98        DISTINCT_TOKENS = {TokenType.DISTINCT, TokenType.UNIQUE}
     99
    100        # Note: this is currently incomplete; it only implements the "JSON_value_column" part
    101        def _parse_json_column_def(self) -> exp.JSONColumnDef:
    102            this = self._parse_id_var()
    103            kind = self._parse_types(allow_identifiers=False)
    104            path = self._match_text_seq("PATH") and self._parse_string()
    105            return self.expression(exp.JSONColumnDef, this=this, kind=kind, path=path)
    106
    107        def _parse_json_table(self) -> exp.JSONTable:
    108            this = self._parse_format_json(self._parse_bitwise())
    109            path = self._match(TokenType.COMMA) and self._parse_string()
    110            error_handling = self._parse_on_handling("ERROR", "ERROR", "NULL")
    111            empty_handling = self._parse_on_handling("EMPTY", "ERROR", "NULL")
    112            self._match(TokenType.COLUMN)
    113            expressions = self._parse_wrapped_csv(self._parse_json_column_def, optional=True)
    114
    115            return exp.JSONTable(
    116                this=this,
    117                expressions=expressions,
    118                path=path,
    119                error_handling=error_handling,
    120                empty_handling=empty_handling,
    121            )
    122
    123        def _parse_json_array(self, expr_type: t.Type[E], **kwargs) -> E:
    124            return self.expression(
    125                expr_type,
    126                null_handling=self._parse_on_handling("NULL", "NULL", "ABSENT"),
    127                return_type=self._match_text_seq("RETURNING") and self._parse_type(),
    128                strict=self._match_text_seq("STRICT"),
    129                **kwargs,
    130            )
    131
    132        def _parse_column(self) -> t.Optional[exp.Expression]:
    133            column = super()._parse_column()
    134            if column:
    135                column.set("join_mark", self._match(TokenType.JOIN_MARKER))
    136            return column
    137
    138        def _parse_hint(self) -> t.Optional[exp.Hint]:
    139            if self._match(TokenType.HINT):
    140                start = self._curr
    141                while self._curr and not self._match_pair(TokenType.STAR, TokenType.SLASH):
    142                    self._advance()
    143
    144                if not self._curr:
    145                    self.raise_error("Expected */ after HINT")
    146
    147                end = self._tokens[self._index - 3]
    148                return exp.Hint(expressions=[self._find_sql(start, end)])
    149
    150            return None
    151
    152    class Generator(generator.Generator):
    153        LOCKING_READS_SUPPORTED = True
    154        JOIN_HINTS = False
    155        TABLE_HINTS = False
    156        COLUMN_JOIN_MARKS_SUPPORTED = True
    157        DATA_TYPE_SPECIFIERS_ALLOWED = True
    158
    159        LIMIT_FETCH = "FETCH"
    160
    161        TYPE_MAPPING = {
    162            **generator.Generator.TYPE_MAPPING,
    163            exp.DataType.Type.TINYINT: "NUMBER",
    164            exp.DataType.Type.SMALLINT: "NUMBER",
    165            exp.DataType.Type.INT: "NUMBER",
    166            exp.DataType.Type.BIGINT: "NUMBER",
    167            exp.DataType.Type.DECIMAL: "NUMBER",
    168            exp.DataType.Type.DOUBLE: "DOUBLE PRECISION",
    169            exp.DataType.Type.VARCHAR: "VARCHAR2",
    170            exp.DataType.Type.NVARCHAR: "NVARCHAR2",
    171            exp.DataType.Type.NCHAR: "NCHAR",
    172            exp.DataType.Type.TEXT: "CLOB",
    173            exp.DataType.Type.BINARY: "BLOB",
    174            exp.DataType.Type.VARBINARY: "BLOB",
    175        }
    176
    177        TRANSFORMS = {
    178            **generator.Generator.TRANSFORMS,
    179            exp.DateStrToDate: lambda self, e: self.func(
    180                "TO_DATE", e.this, exp.Literal.string("YYYY-MM-DD")
    181            ),
    182            exp.Group: transforms.preprocess([transforms.unalias_group]),
    183            exp.ILike: no_ilike_sql,
    184            exp.Select: transforms.preprocess(
    185                [
    186                    transforms.eliminate_distinct_on,
    187                    transforms.eliminate_qualify,
    188                ]
    189            ),
    190            exp.StrToTime: lambda self, e: f"TO_TIMESTAMP({self.sql(e, 'this')}, {self.format_time(e)})",
    191            exp.Subquery: lambda self, e: self.subquery_sql(e, sep=" "),
    192            exp.Substring: rename_func("SUBSTR"),
    193            exp.Table: lambda self, e: self.table_sql(e, sep=" "),
    194            exp.TableSample: lambda self, e: self.tablesample_sql(e, sep=" "),
    195            exp.TimeToStr: lambda self, e: f"TO_CHAR({self.sql(e, 'this')}, {self.format_time(e)})",
    196            exp.ToChar: lambda self, e: self.function_fallback_sql(e),
    197            exp.Trim: trim_sql,
    198            exp.UnixToTime: lambda self, e: f"TO_DATE('1970-01-01','YYYY-MM-DD') + ({self.sql(e, 'this')} / 86400)",
    199        }
    200
    201        PROPERTIES_LOCATION = {
    202            **generator.Generator.PROPERTIES_LOCATION,
    203            exp.VolatileProperty: exp.Properties.Location.UNSUPPORTED,
    204        }
    205
    206        def offset_sql(self, expression: exp.Offset) -> str:
    207            return f"{super().offset_sql(expression)} ROWS"
    208
    209        def xmltable_sql(self, expression: exp.XMLTable) -> str:
    210            this = self.sql(expression, "this")
    211            passing = self.expressions(expression, key="passing")
    212            passing = f"{self.sep()}PASSING{self.seg(passing)}" if passing else ""
    213            columns = self.expressions(expression, key="columns")
    214            columns = f"{self.sep()}COLUMNS{self.seg(columns)}" if columns else ""
    215            by_ref = (
    216                f"{self.sep()}RETURNING SEQUENCE BY REF" if expression.args.get("by_ref") else ""
    217            )
    218            return f"XMLTABLE({self.sep('')}{self.indent(this + passing + by_ref + columns)}{self.seg(')', sep='')}"
    219
    220    class Tokenizer(tokens.Tokenizer):
    221        VAR_SINGLE_TOKENS = {"@", "$", "#"}
    222
    223        KEYWORDS = {
    224            **tokens.Tokenizer.KEYWORDS,
    225            "(+)": TokenType.JOIN_MARKER,
    226            "BINARY_DOUBLE": TokenType.DOUBLE,
    227            "BINARY_FLOAT": TokenType.FLOAT,
    228            "COLUMNS": TokenType.COLUMN,
    229            "MATCH_RECOGNIZE": TokenType.MATCH_RECOGNIZE,
    230            "MINUS": TokenType.EXCEPT,
    231            "NVARCHAR2": TokenType.NVARCHAR,
    232            "SAMPLE": TokenType.TABLE_SAMPLE,
    233            "START": TokenType.BEGIN,
    234            "TOP": TokenType.TOP,
    235            "VARCHAR2": TokenType.VARCHAR,
    236        }

ALIAS_POST_TABLESAMPLE = True
LOCKING_READS_SUPPORTED = True
RESOLVES_IDENTIFIERS_AS_UPPERCASE: Optional[bool] = True
TIME_MAPPING: Dict[str, str] = {'AM': '%p', 'A.M.': '%p', 'PM': '%p', 'P.M.': '%p', 'D': '%u', 'DAY': '%A', 'DD': '%d', 'DDD': '%j', 'DY': '%a', 'HH': '%I', 'HH12': '%I', 'HH24': '%H', 'IW': '%V', 'MI': '%M', 'MM': '%m', 'MON': '%b', 'MONTH': '%B', 'SS': '%S', 'WW': '%W', 'YY': '%y', 'YYYY': '%Y'}
tokenizer_class = <class 'Oracle.Tokenizer'>
parser_class = <class 'Oracle.Parser'>
generator_class = <class 'Oracle.Generator'>
TIME_TRIE: Dict = {'A': {'M': {0: True}, '.': {'M': {'.': {0: True}}}}, 'P': {'M': {0: True}, '.': {'M': {'.': {0: True}}}}, 'D': {0: True, 'A': {'Y': {0: True}}, 'D': {0: True, 'D': {0: True}}, 'Y': {0: True}}, 'H': {'H': {0: True, '1': {'2': {0: True}}, '2': {'4': {0: True}}}}, 'I': {'W': {0: True}}, 'M': {'I': {0: True}, 'M': {0: True}, 'O': {'N': {0: True, 'T': {'H': {0: True}}}}}, 'S': {'S': {0: True}}, 'W': {'W': {0: True}}, 'Y': {'Y': {0: True, 'Y': {'Y': {0: True}}}}}
FORMAT_TRIE: Dict = {'A': {'M': {0: True}, '.': {'M': {'.': {0: True}}}}, 'P': {'M': {0: True}, '.': {'M': {'.': {0: True}}}}, 'D': {0: True, 'A': {'Y': {0: True}}, 'D': {0: True, 'D': {0: True}}, 'Y': {0: True}}, 'H': {'H': {0: True, '1': {'2': {0: True}}, '2': {'4': {0: True}}}}, 'I': {'W': {0: True}}, 'M': {'I': {0: True}, 'M': {0: True}, 'O': {'N': {0: True, 'T': {'H': {0: True}}}}}, 'S': {'S': {0: True}}, 'W': {'W': {0: True}}, 'Y': {'Y': {0: True, 'Y': {'Y': {0: True}}}}}
INVERSE_TIME_MAPPING: Dict[str, str] = {'%p': 'P.M.', '%u': 'D', '%A': 'DAY', '%d': 'DD', '%j': 'DDD', '%a': 'DY', '%I': 'HH12', '%H': 'HH24', '%V': 'IW', '%M': 'MI', '%m': 'MM', '%b': 'MON', '%B': 'MONTH', '%S': 'SS', '%W': 'WW', '%y': 'YY', '%Y': 'YYYY'}
INVERSE_TIME_TRIE: Dict = {'%': {'p': {0: True}, 'u': {0: True}, 'A': {0: True}, 'd': {0: True}, 'j': {0: True}, 'a': {0: True}, 'I': {0: True}, 'H': {0: True}, 'V': {0: True}, 'M': {0: True}, 'm': {0: True}, 'b': {0: True}, 'B': {0: True}, 'S': {0: True}, 'W': {0: True}, 'y': {0: True}, 'Y': {0: True}}}
INVERSE_ESCAPE_SEQUENCES: Dict[str, str] = {}
QUOTE_START = "'"
QUOTE_END = "'"
IDENTIFIER_START = '"'
IDENTIFIER_END = '"'
BIT_START = None
BIT_END = None
HEX_START = None
HEX_END = None
BYTE_START = None
BYTE_END = None

##### Inherited Members

sqlglot.dialects.dialect.Dialect
  INDEX_OFFSET
  UNNEST_COLUMN_ONLY
  IDENTIFIERS_CAN_START_WITH_DIGIT
  DPIPE_IS_STRING_CONCAT
  STRICT_STRING_CONCAT
  SUPPORTS_USER_DEFINED_TYPES
  SUPPORTS_SEMI_ANTI_JOIN
  NORMALIZE_FUNCTIONS
  LOG_BASE_FIRST
  NULL_ORDERING
  DATE_FORMAT
  DATEINT_FORMAT
  TIME_FORMAT
  FORMAT_MAPPING
  ESCAPE_SEQUENCES
  PSEUDOCOLUMNS
  get_or_raise
  format_time
  normalize_identifier
  case_sensitive
  can_identify
  quote_identifier
  parse
  parse_into
  generate
  transpile
  tokenize
  tokenizer
  parser
  generator

class Oracle.Parser(sqlglot.parser.Parser): View Source

     67    class Parser(parser.Parser):
     68        WINDOW_BEFORE_PAREN_TOKENS = {TokenType.OVER, TokenType.KEEP}
     69
     70        FUNCTIONS = {
     71            **parser.Parser.FUNCTIONS,
     72            "SQUARE": lambda args: exp.Pow(this=seq_get(args, 0), expression=exp.Literal.number(2)),
     73        }
     74
     75        FUNCTION_PARSERS: t.Dict[str, t.Callable] = {
     76            **parser.Parser.FUNCTION_PARSERS,
     77            "JSON_ARRAY": lambda self: self._parse_json_array(
     78                exp.JSONArray,
     79                expressions=self._parse_csv(lambda: self._parse_format_json(self._parse_bitwise())),
     80            ),
     81            "JSON_ARRAYAGG": lambda self: self._parse_json_array(
     82                exp.JSONArrayAgg,
     83                this=self._parse_format_json(self._parse_bitwise()),
     84                order=self._parse_order(),
     85            ),
     86            "JSON_TABLE": lambda self: self._parse_json_table(),
     87            "XMLTABLE": _parse_xml_table,
     88        }
     89
     90        TYPE_LITERAL_PARSERS = {
     91            exp.DataType.Type.DATE: lambda self, this, _: self.expression(
     92                exp.DateStrToDate, this=this
     93            )
     94        }
     95
     96        # SELECT UNIQUE .. is old-style Oracle syntax for SELECT DISTINCT ..
     97        # Reference: https://stackoverflow.com/a/336455
     98        DISTINCT_TOKENS = {TokenType.DISTINCT, TokenType.UNIQUE}
     99
    100        # Note: this is currently incomplete; it only implements the "JSON_value_column" part
    101        def _parse_json_column_def(self) -> exp.JSONColumnDef:
    102            this = self._parse_id_var()
    103            kind = self._parse_types(allow_identifiers=False)
    104            path = self._match_text_seq("PATH") and self._parse_string()
    105            return self.expression(exp.JSONColumnDef, this=this, kind=kind, path=path)
    106
    107        def _parse_json_table(self) -> exp.JSONTable:
    108            this = self._parse_format_json(self._parse_bitwise())
    109            path = self._match(TokenType.COMMA) and self._parse_string()
    110            error_handling = self._parse_on_handling("ERROR", "ERROR", "NULL")
    111            empty_handling = self._parse_on_handling("EMPTY", "ERROR", "NULL")
    112            self._match(TokenType.COLUMN)
    113            expressions = self._parse_wrapped_csv(self._parse_json_column_def, optional=True)
    114
    115            return exp.JSONTable(
    116                this=this,
    117                expressions=expressions,
    118                path=path,
    119                error_handling=error_handling,
    120                empty_handling=empty_handling,
    121            )
    122
    123        def _parse_json_array(self, expr_type: t.Type[E], **kwargs) -> E:
    124            return self.expression(
    125                expr_type,
    126                null_handling=self._parse_on_handling("NULL", "NULL", "ABSENT"),
    127                return_type=self._match_text_seq("RETURNING") and self._parse_type(),
    128                strict=self._match_text_seq("STRICT"),
    129                **kwargs,
    130            )
    131
    132        def _parse_column(self) -> t.Optional[exp.Expression]:
    133            column = super()._parse_column()
    134            if column:
    135                column.set("join_mark", self._match(TokenType.JOIN_MARKER))
    136            return column
    137
    138        def _parse_hint(self) -> t.Optional[exp.Hint]:
    139            if self._match(TokenType.HINT):
    140                start = self._curr
    141                while self._curr and not self._match_pair(TokenType.STAR, TokenType.SLASH):
    142                    self._advance()
    143
    144                if not self._curr:
    145                    self.raise_error("Expected */ after HINT")
    146
    147                end = self._tokens[self._index - 3]
    148                return exp.Hint(expressions=[self._find_sql(start, end)])
    149
    150            return None

Parser consumes a list of tokens produced by the Tokenizer and produces a parsed syntax tree.

###### Arguments:

- error_level: The desired error level. Default: ErrorLevel.IMMEDIATE
- error_message_context: Determines the amount of context to capture from a query string when displaying the error message (in number of characters). Default: 100
- max_errors: Maximum number of error messages to include in a raised ParseError. This is only relevant if error_level is ErrorLevel.RAISE. Default: 3

WINDOW_BEFORE_PAREN_TOKENS = {<TokenType.KEEP: 'KEEP'>, <TokenType.OVER: 'OVER'>}
FUNCTIONS = {'ABS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Abs'>>, 'ANY_VALUE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.AnyValue'>>, 'APPROX_DISTINCT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ApproxDistinct'>>, 'APPROX_COUNT_DISTINCT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ApproxDistinct'>>, 'APPROX_QUANTILE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ApproxQuantile'>>, 'ARRAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Array'>>, 'ARRAY_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayAgg'>>, 'ARRAY_ALL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayAll'>>, 'ARRAY_ANY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayAny'>>, 'ARRAY_CONCAT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayConcat'>>, 'ARRAY_CAT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayConcat'>>, 'ARRAY_CONTAINS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayContains'>>, 'FILTER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayFilter'>>, 'ARRAY_FILTER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayFilter'>>, 'ARRAY_JOIN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayJoin'>>, 'ARRAY_SIZE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArraySize'>>, 'ARRAY_SORT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArraySort'>>, 'ARRAY_SUM': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArraySum'>>, 'ARRAY_UNION_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayUnionAgg'>>, 'AVG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Avg'>>, 'CASE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Case'>>, 'CAST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Cast'>>, 'CAST_TO_STR_TYPE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CastToStrType'>>, 'CEIL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Ceil'>>, 'CEILING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Ceil'>>, 'CHR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Chr'>>, 'CHAR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Chr'>>, 'COALESCE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Coalesce'>>, 'IFNULL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Coalesce'>>, 'NVL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Coalesce'>>, 'COLLATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Collate'>>, 'CONCAT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Concat'>>, 'CONCAT_WS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ConcatWs'>>, 'COUNT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Count'>>, 'COUNT_IF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CountIf'>>, 'CURRENT_DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CurrentDate'>>, 'CURRENT_DATETIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CurrentDatetime'>>, 'CURRENT_TIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CurrentTime'>>, 'CURRENT_TIMESTAMP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CurrentTimestamp'>>, 'CURRENT_USER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CurrentUser'>>, 'DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Date'>>, 'DATE_ADD': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateAdd'>>, 'DATEDIFF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateDiff'>>, 'DATE_DIFF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateDiff'>>, 'DATEFROMPARTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateFromParts'>>, 'DATE_STR_TO_DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateStrToDate'>>, 'DATE_SUB': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateSub'>>, 'DATE_TO_DATE_STR': <function Parser.<lambda>>, 'DATE_TO_DI': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateToDi'>>, 'DATE_TRUNC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateTrunc'>>, 'DATETIME_ADD': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DatetimeAdd'>>, 'DATETIME_DIFF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DatetimeDiff'>>, 'DATETIME_SUB': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DatetimeSub'>>, 'DATETIME_TRUNC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DatetimeTrunc'>>, 'DAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Day'>>, 'DAY_OF_MONTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DayOfMonth'>>, 'DAYOFMONTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DayOfMonth'>>, 'DAY_OF_WEEK': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DayOfWeek'>>, 'DAYOFWEEK': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DayOfWeek'>>, 'DAY_OF_YEAR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DayOfYear'>>, 'DAYOFYEAR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DayOfYear'>>, 'DECODE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Decode'>>, 'DI_TO_DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DiToDate'>>, 'ENCODE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Encode'>>, 'EXP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Exp'>>, 'EXPLODE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Explode'>>, 'EXTRACT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Extract'>>, 'FIRST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.First'>>, 'FLOOR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Floor'>>, 'FROM_BASE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.FromBase'>>, 'FROM_BASE64': <bound method Func.from_arg_list of <class 'sqlglot.expressions.FromBase64'>>, 'GENERATE_SERIES': <bound method Func.from_arg_list of <class 'sqlglot.expressions.GenerateSeries'>>, 'GREATEST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Greatest'>>, 'GROUP_CONCAT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.GroupConcat'>>, 'HEX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Hex'>>, 'HLL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Hll'>>, 'IF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.If'>>, 'INITCAP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Initcap'>>, 'IS_NAN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.IsNan'>>, 'ISNAN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.IsNan'>>, 'J_S_O_N_ARRAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONArray'>>, 'J_S_O_N_ARRAY_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONArrayAgg'>>, 'JSON_ARRAY_CONTAINS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONArrayContains'>>, 'JSONB_EXTRACT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONBExtract'>>, 'JSONB_EXTRACT_SCALAR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONBExtractScalar'>>, 'JSON_EXTRACT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONExtract'>>, 'JSON_EXTRACT_SCALAR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONExtractScalar'>>, 'JSON_FORMAT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONFormat'>>, 'J_S_O_N_OBJECT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONObject'>>, 'J_S_O_N_TABLE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONTable'>>, 'LAST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Last'>>, 'LAST_DATE_OF_MONTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LastDateOfMonth'>>, 'LEAST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Least'>>, 'LEFT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Left'>>, 'LENGTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Length'>>, 'LEN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Length'>>, 'LEVENSHTEIN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Levenshtein'>>, 'LN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Ln'>>, 'LOG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Log'>>, 'LOG10': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Log10'>>, 'LOG2': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Log2'>>, 'LOGICAL_AND': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LogicalAnd'>>, 'BOOL_AND': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LogicalAnd'>>, 'BOOLAND_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LogicalAnd'>>, 'LOGICAL_OR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LogicalOr'>>, 'BOOL_OR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LogicalOr'>>, 'BOOLOR_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LogicalOr'>>, 'LOWER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Lower'>>, 'LCASE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Lower'>>, 'MD5': <bound method Func.from_arg_list of <class 'sqlglot.expressions.MD5'>>, 'MD5_DIGEST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.MD5Digest'>>, 'MAP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Map'>>, 'MAP_FROM_ENTRIES': <bound method Func.from_arg_list of <class 'sqlglot.expressions.MapFromEntries'>>, 'MATCH_AGAINST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.MatchAgainst'>>, 'MAX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Max'>>, 'MIN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Min'>>, 'MONTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Month'>>, 'MONTHS_BETWEEN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.MonthsBetween'>>, 'NEXT_VALUE_FOR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.NextValueFor'>>, 'NUMBER_TO_STR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.NumberToStr'>>, 'NVL2': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Nvl2'>>, 'OPEN_J_S_O_N': <bound method Func.from_arg_list of <class 'sqlglot.expressions.OpenJSON'>>, 'PARAMETERIZED_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ParameterizedAgg'>>, 'PARSE_JSON': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ParseJSON'>>, 'JSON_PARSE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ParseJSON'>>, 'PERCENTILE_CONT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.PercentileCont'>>, 'PERCENTILE_DISC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.PercentileDisc'>>, 'POSEXPLODE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Posexplode'>>, 'POWER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Pow'>>, 'POW': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Pow'>>, 'QUANTILE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Quantile'>>, 'RANGE_N': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RangeN'>>, 'READ_CSV': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ReadCSV'>>, 'REDUCE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Reduce'>>, 'REGEXP_EXTRACT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpExtract'>>, 'REGEXP_I_LIKE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpILike'>>, 'REGEXP_LIKE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpLike'>>, 'REGEXP_REPLACE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpReplace'>>, 'REGEXP_SPLIT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpSplit'>>, 'REPEAT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Repeat'>>, 'RIGHT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Right'>>, 'ROUND': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Round'>>, 'ROW_NUMBER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RowNumber'>>, 'SHA': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SHA'>>, 'SHA1': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SHA'>>, 'SHA2': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SHA2'>>, 'SAFE_CONCAT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SafeConcat'>>, 'SAFE_DIVIDE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SafeDivide'>>, 'SET_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SetAgg'>>, 'SORT_ARRAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SortArray'>>, 'SPLIT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Split'>>, 'SQRT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Sqrt'>>, 'STANDARD_HASH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StandardHash'>>, 'STAR_MAP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StarMap'>>, 'STARTS_WITH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StartsWith'>>, 'STARTSWITH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StartsWith'>>, 'STDDEV': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Stddev'>>, 'STDDEV_POP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StddevPop'>>, 'STDDEV_SAMP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StddevSamp'>>, 'STR_POSITION': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StrPosition'>>, 'STR_TO_DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StrToDate'>>, 'STR_TO_MAP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StrToMap'>>, 'STR_TO_TIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StrToTime'>>, 'STR_TO_UNIX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StrToUnix'>>, 'STRUCT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Struct'>>, 'STRUCT_EXTRACT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StructExtract'>>, 'STUFF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Stuff'>>, 'INSERT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Stuff'>>, 'SUBSTRING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Substring'>>, 'SUM': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Sum'>>, 'TIME_ADD': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeAdd'>>, 'TIME_DIFF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeDiff'>>, 'TIME_STR_TO_DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeStrToDate'>>, 'TIME_STR_TO_TIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeStrToTime'>>, 'TIME_STR_TO_UNIX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeStrToUnix'>>, 'TIME_SUB': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeSub'>>, 'TIME_TO_STR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeToStr'>>, 'TIME_TO_TIME_STR': <function Parser.<lambda>>, 'TIME_TO_UNIX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeToUnix'>>, 'TIME_TRUNC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeTrunc'>>, 'TIMESTAMP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Timestamp'>>, 'TIMESTAMP_ADD': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimestampAdd'>>, 'TIMESTAMP_DIFF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimestampDiff'>>, 'TIMESTAMP_SUB': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimestampSub'>>, 'TIMESTAMP_TRUNC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimestampTrunc'>>, 'TO_BASE64': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ToBase64'>>, 'TO_CHAR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ToChar'>>, 'TO_DAYS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ToDays'>>, 'TRANSFORM': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Transform'>>, 'TRIM': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Trim'>>, 'TRY_CAST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TryCast'>>, 'TS_OR_DI_TO_DI': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TsOrDiToDi'>>, 'TS_OR_DS_ADD': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TsOrDsAdd'>>, 'TS_OR_DS_TO_DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TsOrDsToDate'>>, 'TS_OR_DS_TO_DATE_STR': <function Parser.<lambda>>, 'UNHEX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Unhex'>>, 'UNIX_TO_STR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.UnixToStr'>>, 'UNIX_TO_TIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.UnixToTime'>>, 'UNIX_TO_TIME_STR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.UnixToTimeStr'>>, 'UPPER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Upper'>>, 'UCASE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Upper'>>, 'VAR_MAP': <function parse_var_map>, 'VARIANCE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Variance'>>, 'VARIANCE_SAMP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Variance'>>, 'VAR_SAMP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Variance'>>, 'VARIANCE_POP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.VariancePop'>>, 'VAR_POP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.VariancePop'>>, 'WEEK': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Week'>>, 'WEEK_OF_YEAR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.WeekOfYear'>>, 'WEEKOFYEAR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.WeekOfYear'>>, 'WHEN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.When'>>, 'X_M_L_TABLE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.XMLTable'>>, 'XOR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Xor'>>, 'YEAR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Year'>>, 'GLOB': <function Parser.<lambda>>, 'LIKE': <function parse_like>, 'SQUARE': <function Oracle.Parser.<lambda>>}
FUNCTION_PARSERS: Dict[str, Callable] = {'ANY_VALUE': <function Parser.<lambda>>, 'CAST': <function Parser.<lambda>>, 'CONCAT': <function Parser.<lambda>>, 'CONCAT_WS': <function Parser.<lambda>>, 'CONVERT': <function Parser.<lambda>>, 'DECODE': <function Parser.<lambda>>, 'EXTRACT': <function Parser.<lambda>>, 'JSON_OBJECT': <function Parser.<lambda>>, 'LOG': <function Parser.<lambda>>, 'MATCH': <function Parser.<lambda>>, 'OPENJSON': <function Parser.<lambda>>, 'POSITION': <function Parser.<lambda>>, 'SAFE_CAST': <function Parser.<lambda>>, 'STRING_AGG': <function Parser.<lambda>>, 'SUBSTRING': <function Parser.<lambda>>, 'TRIM': <function Parser.<lambda>>, 'TRY_CAST': <function Parser.<lambda>>, 'TRY_CONVERT': <function Parser.<lambda>>, 'JSON_ARRAY': <function Oracle.Parser.<lambda>>, 'JSON_ARRAYAGG': <function Oracle.Parser.<lambda>>, 'JSON_TABLE': <function Oracle.Parser.<lambda>>, 'XMLTABLE': <function _parse_xml_table>}
TYPE_LITERAL_PARSERS = {<Type.DATE: 'DATE'>: <function Oracle.Parser.<lambda>>}
DISTINCT_TOKENS = {<TokenType.DISTINCT: 'DISTINCT'>, <TokenType.UNIQUE: 'UNIQUE'>}
TOKENIZER_CLASS: Type[sqlglot.tokens.Tokenizer] = <class 'Oracle.Tokenizer'>
ALIAS_POST_TABLESAMPLE: bool = True
SHOW_TRIE: Dict = {}
SET_TRIE: Dict = {'GLOBAL': {0: True}, 'LOCAL': {0: True}, 'SESSION': {0: True}, 'TRANSACTION': {0: True}}
FORMAT_TRIE: Dict = {'A': {'M': {0: True}, '.': {'M': {'.': {0: True}}}}, 'P': {'M': {0: True}, '.': {'M': {'.': {0: True}}}}, 'D': {0: True, 'A': {'Y': {0: True}}, 'D': {0: True, 'D': {0: True}}, 'Y': {0: True}}, 'H': {'H': {0: True, '1': {'2': {0: True}}, '2': {'4': {0: True}}}}, 'I': {'W': {0: True}}, 'M': {'I': {0: True}, 'M': {0: True}, 'O': {'N': {0: True, 'T': {'H': {0: True}}}}}, 'S': {'S': {0: True}}, 'W': {'W': {0: True}}, 'Y': {'Y': {0: True, 'Y': {'Y': {0: True}}}}}
TIME_MAPPING: Dict[str, str] = {'AM': '%p', 'A.M.': '%p', 'PM': '%p', 'P.M.': '%p', 'D': '%u', 'DAY': '%A', 'DD': '%d', 'DDD': '%j', 'DY': '%a', 'HH': '%I', 'HH12': '%I', 'HH24': '%H', 'IW': '%V', 'MI': '%M', 'MM': '%m', 'MON': '%b', 'MONTH': '%B', 'SS': '%S', 'WW': '%W', 'YY': '%y', 'YYYY': '%Y'}
TIME_TRIE: Dict = {'A': {'M': {0: True}, '.': {'M': {'.': {0: True}}}}, 'P': {'M': {0: True}, '.': {'M': {'.': {0: True}}}}, 'D': {0: True, 'A': {'Y': {0: True}}, 'D': {0: True, 'D': {0: True}}, 'Y': {0: True}}, 'H': {'H': {0: True, '1': {'2': {0: True}}, '2': {'4': {0: True}}}}, 'I': {'W': {0: True}}, 'M': {'I': {0: True}, 'M': {0: True}, 'O': {'N': {0: True, 'T': {'H': {0: True}}}}}, 'S': {'S': {0: True}}, 'W': {'W': {0: True}}, 'Y': {'Y': {0: True, 'Y': {'Y': {0: True}}}}}

##### Inherited Members

sqlglot.parser.Parser
  Parser
  NO_PAREN_FUNCTIONS
  STRUCT_TYPE_TOKENS
  NESTED_TYPE_TOKENS
  ENUM_TYPE_TOKENS
  TYPE_TOKENS
  SIGNED_TO_UNSIGNED_TYPE_TOKEN
  SUBQUERY_PREDICATES
  RESERVED_KEYWORDS
  DB_CREATABLES
  CREATABLES
  ID_VAR_TOKENS
  INTERVAL_VARS
  TABLE_ALIAS_TOKENS
  COMMENT_TABLE_ALIAS_TOKENS
  UPDATE_ALIAS_TOKENS
  TRIM_TYPES
  FUNC_TOKENS
  CONJUNCTION
  EQUALITY
  COMPARISON
  BITWISE
  TERM
  FACTOR
  TIMES
  TIMESTAMPS
  SET_OPERATIONS
  JOIN_METHODS
  JOIN_SIDES
  JOIN_KINDS
  JOIN_HINTS
  LAMBDAS
  COLUMN_OPERATORS
  EXPRESSION_PARSERS
  STATEMENT_PARSERS
  UNARY_PARSERS
  PRIMARY_PARSERS
  PLACEHOLDER_PARSERS
  RANGE_PARSERS
  PROPERTY_PARSERS
  CONSTRAINT_PARSERS
  ALTER_PARSERS
  SCHEMA_UNNAMED_CONSTRAINTS
  NO_PAREN_FUNCTION_PARSERS
  INVALID_FUNC_NAME_TOKENS
  FUNCTIONS_WITH_ALIASED_ARGS
  QUERY_MODIFIER_PARSERS
  SET_PARSERS
  SHOW_PARSERS
  MODIFIABLES
  DDL_SELECT_TOKENS
  PRE_VOLATILE_TOKENS
  TRANSACTION_KIND
  TRANSACTION_CHARACTERISTICS
  INSERT_ALTERNATIVES
  CLONE_KEYWORDS
  CLONE_KINDS
  OPCLASS_FOLLOW_KEYWORDS
  TABLE_INDEX_HINT_TOKENS
  WINDOW_ALIAS_TOKENS
  WINDOW_SIDES
  FETCH_TOKENS
  ADD_CONSTRAINT_TOKENS
  NULL_TOKENS
  UNNEST_OFFSET_ALIAS_TOKENS
  STRICT_CAST
  CONCAT_NULL_OUTPUTS_STRING
  PREFIXED_PIVOT_COLUMNS
  IDENTIFY_PIVOT_STRINGS
  LOG_BASE_FIRST
  LOG_DEFAULTS_TO_LN
  ALTER_TABLE_ADD_COLUMN_KEYWORD
  TABLESAMPLE_CSV
  SET_REQUIRES_ASSIGNMENT_DELIMITER
  TRIM_PATTERN_FIRST
  INDEX_OFFSET
  UNNEST_COLUMN_ONLY
  STRICT_STRING_CONCAT
  SUPPORTS_USER_DEFINED_TYPES
  NORMALIZE_FUNCTIONS
  NULL_ORDERING
  FORMAT_MAPPING
  error_level
  error_message_context
  max_errors
  reset
  parse
  parse_into
  check_errors
  raise_error
  expression
  validate_expression
  errors
  sql

class Oracle.Generator(sqlglot.generator.Generator): View Source

    152    class Generator(generator.Generator):
    153        LOCKING_READS_SUPPORTED = True
    154        JOIN_HINTS = False
    155        TABLE_HINTS = False
    156        COLUMN_JOIN_MARKS_SUPPORTED = True
    157        DATA_TYPE_SPECIFIERS_ALLOWED = True
    158
    159        LIMIT_FETCH = "FETCH"
    160
    161        TYPE_MAPPING = {
    162            **generator.Generator.TYPE_MAPPING,
    163            exp.DataType.Type.TINYINT: "NUMBER",
    164            exp.DataType.Type.SMALLINT: "NUMBER",
    165            exp.DataType.Type.INT: "NUMBER",
    166            exp.DataType.Type.BIGINT: "NUMBER",
    167            exp.DataType.Type.DECIMAL: "NUMBER",
    168            exp.DataType.Type.DOUBLE: "DOUBLE PRECISION",
    169            exp.DataType.Type.VARCHAR: "VARCHAR2",
    170            exp.DataType.Type.NVARCHAR: "NVARCHAR2",
    171            exp.DataType.Type.NCHAR: "NCHAR",
    172            exp.DataType.Type.TEXT: "CLOB",
    173            exp.DataType.Type.BINARY: "BLOB",
    174            exp.DataType.Type.VARBINARY: "BLOB",
    175        }
    176
    177        TRANSFORMS = {
    178            **generator.Generator.TRANSFORMS,
    179            exp.DateStrToDate: lambda self, e: self.func(
    180                "TO_DATE", e.this, exp.Literal.string("YYYY-MM-DD")
    181            ),
    182            exp.Group: transforms.preprocess([transforms.unalias_group]),
    183            exp.ILike: no_ilike_sql,
    184            exp.Select: transforms.preprocess(
    185                [
    186                    transforms.eliminate_distinct_on,
    187                    transforms.eliminate_qualify,
    188                ]
    189            ),
    190            exp.StrToTime: lambda self, e: f"TO_TIMESTAMP({self.sql(e, 'this')}, {self.format_time(e)})",
    191            exp.Subquery: lambda self, e: self.subquery_sql(e, sep=" "),
    192            exp.Substring: rename_func("SUBSTR"),
    193            exp.Table: lambda self, e: self.table_sql(e, sep=" "),
    194            exp.TableSample: lambda self, e: self.tablesample_sql(e, sep=" "),
    195            exp.TimeToStr: lambda self, e: f"TO_CHAR({self.sql(e, 'this')}, {self.format_time(e)})",
    196            exp.ToChar: lambda self, e: self.function_fallback_sql(e),
    197            exp.Trim: trim_sql,
    198            exp.UnixToTime: lambda self, e: f"TO_DATE('1970-01-01','YYYY-MM-DD') + ({self.sql(e, 'this')} / 86400)",
    199        }
    200
    201        PROPERTIES_LOCATION = {
    202            **generator.Generator.PROPERTIES_LOCATION,
    203            exp.VolatileProperty: exp.Properties.Location.UNSUPPORTED,
    204        }
    205
    206        def offset_sql(self, expression: exp.Offset) -> str:
    207            return f"{super().offset_sql(expression)} ROWS"
    208
    209        def xmltable_sql(self, expression: exp.XMLTable) -> str:
    210            this = self.sql(expression, "this")
    211            passing = self.expressions(expression, key="passing")
    212            passing = f"{self.sep()}PASSING{self.seg(passing)}" if passing else ""
    213            columns = self.expressions(expression, key="columns")
    214            columns = f"{self.sep()}COLUMNS{self.seg(columns)}" if columns else ""
    215            by_ref = (
    216                f"{self.sep()}RETURNING SEQUENCE BY REF" if expression.args.get("by_ref") else ""
    217            )
    218            return f"XMLTABLE({self.sep('')}{self.indent(this + passing + by_ref + columns)}{self.seg(')', sep='')}"

Generator converts a given syntax tree to the corresponding SQL string.

###### Arguments:

- pretty: Whether or not to format the produced SQL string. Default: False.
- identify: Determines when an identifier should be quoted. Possible values are: False (default): Never quote, except in cases where it's mandatory by the dialect. True or 'always': Always quote. 'safe': Only quote identifiers that are case insensitive.
- normalize: Whether or not to normalize identifiers to lowercase. Default: False.
- pad: Determines the pad size in a formatted string. Default: 2.
- indent: Determines the indentation size in a formatted string. Default: 2.
- normalize_functions: Whether or not to normalize all function names. Possible values are: "upper" or True (default): Convert names to uppercase. "lower": Convert names to lowercase. False: Disables function name normalization.
- unsupported_level: Determines the generator's behavior when it encounters unsupported expressions. Default ErrorLevel.WARN.
- max_unsupported: Maximum number of unsupported messages to include in a raised UnsupportedError. This is only relevant if unsupported_level is ErrorLevel.RAISE. Default: 3
- leading_comma: Determines whether or not the comma is leading or trailing in select expressions. This is only relevant when generating in pretty mode. Default: False
- max_text_width: The max number of characters in a segment before creating new lines in pretty mode. The default is on the smaller end because the length only represents a segment and not the true line length. Default: 80
- comments: Whether or not to preserve comments in the output SQL code. Default: True

LOCKING_READS_SUPPORTED = True
JOIN_HINTS = False
TABLE_HINTS = False
COLUMN_JOIN_MARKS_SUPPORTED = True
DATA_TYPE_SPECIFIERS_ALLOWED = True
LIMIT_FETCH = 'FETCH'
TYPE_MAPPING = {<Type.NCHAR: 'NCHAR'>: 'NCHAR', <Type.NVARCHAR: 'NVARCHAR'>: 'NVARCHAR2', <Type.MEDIUMTEXT: 'MEDIUMTEXT'>: 'TEXT', <Type.LONGTEXT: 'LONGTEXT'>: 'TEXT', <Type.TINYTEXT: 'TINYTEXT'>: 'TEXT', <Type.MEDIUMBLOB: 'MEDIUMBLOB'>: 'BLOB', <Type.LONGBLOB: 'LONGBLOB'>: 'BLOB', <Type.TINYBLOB: 'TINYBLOB'>: 'BLOB', <Type.INET: 'INET'>: 'INET', <Type.TINYINT: 'TINYINT'>: 'NUMBER', <Type.SMALLINT: 'SMALLINT'>: 'NUMBER', <Type.INT: 'INT'>: 'NUMBER', <Type.BIGINT: 'BIGINT'>: 'NUMBER', <Type.DECIMAL: 'DECIMAL'>: 'NUMBER', <Type.DOUBLE: 'DOUBLE'>: 'DOUBLE PRECISION', <Type.VARCHAR: 'VARCHAR'>: 'VARCHAR2', <Type.TEXT: 'TEXT'>: 'CLOB', <Type.BINARY: 'BINARY'>: 'BLOB', <Type.VARBINARY: 'VARBINARY'>: 'BLOB'}
TRANSFORMS = {<class 'sqlglot.expressions.DateAdd'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.TsOrDsAdd'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CaseSpecificColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CharacterSetColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CharacterSetProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CheckColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ClusteredColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CollateColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CopyGrantsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CommentColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.DateFormatColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.DefaultColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.EncodeColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ExecuteAsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ExternalProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.HeapProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.InlineLengthColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.IntervalSpan'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.LanguageProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.LocationProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.LogProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.MaterializedProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.NoPrimaryIndexProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.NonClusteredColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.NotForReplicationColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.OnCommitProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.OnProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.OnUpdateColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.PathColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ReturnsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SampleProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SetProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SettingsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SqlSecurityProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.StabilityProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.TemporaryProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ToTableProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.TransientProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.TitleColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.UppercaseColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.VarMap'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.VolatileProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.WithJournalTableProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.DateStrToDate'>: <function Oracle.Generator.<lambda>>, <class 'sqlglot.expressions.Group'>: <function preprocess.<locals>._to_sql>, <class 'sqlglot.expressions.ILike'>: <function no_ilike_sql>, <class 'sqlglot.expressions.Select'>: <function preprocess.<locals>._to_sql>, <class 'sqlglot.expressions.StrToTime'>: <function Oracle.Generator.<lambda>>, <class 'sqlglot.expressions.Subquery'>: <function Oracle.Generator.<lambda>>, <class 'sqlglot.expressions.Substring'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.Table'>: <function Oracle.Generator.<lambda>>, <class 'sqlglot.expressions.TableSample'>: <function Oracle.Generator.<lambda>>, <class 'sqlglot.expressions.TimeToStr'>: <function Oracle.Generator.<lambda>>, <class 'sqlglot.expressions.ToChar'>: <function Oracle.Generator.<lambda>>, <class 'sqlglot.expressions.Trim'>: <function trim_sql>, <class 'sqlglot.expressions.UnixToTime'>: <function Oracle.Generator.<lambda>>}
PROPERTIES_LOCATION = {<class 'sqlglot.expressions.AlgorithmProperty'>: <Location.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.AutoIncrementProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.BlockCompressionProperty'>: <Location.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.CharacterSetProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.ChecksumProperty'>: <Location.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.CollateProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.CopyGrantsProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.Cluster'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.ClusteredByProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.DataBlocksizeProperty'>: <Location.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.DefinerProperty'>: <Location.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.DictRange'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.DictProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.DistKeyProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.DistStyleProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.EngineProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.ExecuteAsProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.ExternalProperty'>: <Location.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.FallbackProperty'>: <Location.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.FileFormatProperty'>: <Location.POST_WITH: 'POST_WITH'>, <class 'sqlglot.expressions.FreespaceProperty'>: <Location.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.HeapProperty'>: <Location.POST_WITH: 'POST_WITH'>, <class 'sqlglot.expressions.IsolatedLoadingProperty'>: <Location.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.JournalProperty'>: <Location.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.LanguageProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.LikeProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.LocationProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.LockingProperty'>: <Location.POST_ALIAS: 'POST_ALIAS'>, <class 'sqlglot.expressions.LogProperty'>: <Location.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.MaterializedProperty'>: <Location.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.MergeBlockRatioProperty'>: <Location.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.NoPrimaryIndexProperty'>: <Location.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.OnProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.OnCommitProperty'>: <Location.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.Order'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.PartitionedByProperty'>: <Location.POST_WITH: 'POST_WITH'>, <class 'sqlglot.expressions.PrimaryKey'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.Property'>: <Location.POST_WITH: 'POST_WITH'>, <class 'sqlglot.expressions.ReturnsProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.RowFormatProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.RowFormatDelimitedProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.RowFormatSerdeProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.SampleProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.SchemaCommentProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.SerdeProperties'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.Set'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.SettingsProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.SetProperty'>: <Location.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.SortKeyProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.SqlSecurityProperty'>: <Location.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.StabilityProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.TemporaryProperty'>: <Location.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.ToTableProperty'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.TransientProperty'>: <Location.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.MergeTreeTTL'>: <Location.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.VolatileProperty'>: <Location.UNSUPPORTED: 'UNSUPPORTED'>, <class 'sqlglot.expressions.WithDataProperty'>: <Location.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.WithJournalTableProperty'>: <Location.POST_NAME: 'POST_NAME'>}
def offset_sql(self, expression: sqlglot.expressions.Offset) -> str: View Source

    206        def offset_sql(self, expression: exp.Offset) -> str:
    207            return f"{super().offset_sql(expression)} ROWS"

def xmltable_sql(self, expression: sqlglot.expressions.XMLTable) -> str: View Source

    209        def xmltable_sql(self, expression: exp.XMLTable) -> str:
    210            this = self.sql(expression, "this")
    211            passing = self.expressions(expression, key="passing")
    212            passing = f"{self.sep()}PASSING{self.seg(passing)}" if passing else ""
    213            columns = self.expressions(expression, key="columns")
    214            columns = f"{self.sep()}COLUMNS{self.seg(columns)}" if columns else ""
    215            by_ref = (
    216                f"{self.sep()}RETURNING SEQUENCE BY REF" if expression.args.get("by_ref") else ""
    217            )
    218            return f"XMLTABLE({self.sep('')}{self.indent(this + passing + by_ref + columns)}{self.seg(')', sep='')}"

SELECT_KINDS: Tuple[str, ...] = ()
INVERSE_TIME_MAPPING: Dict[str, str] = {'%p': 'P.M.', '%u': 'D', '%A': 'DAY', '%d': 'DD', '%j': 'DDD', '%a': 'DY', '%I': 'HH12', '%H': 'HH24', '%V': 'IW', '%M': 'MI', '%m': 'MM', '%b': 'MON', '%B': 'MONTH', '%S': 'SS', '%W': 'WW', '%y': 'YY', '%Y': 'YYYY'}
INVERSE_TIME_TRIE: Dict = {'%': {'p': {0: True}, 'u': {0: True}, 'A': {0: True}, 'd': {0: True}, 'j': {0: True}, 'a': {0: True}, 'I': {0: True}, 'H': {0: True}, 'V': {0: True}, 'M': {0: True}, 'm': {0: True}, 'b': {0: True}, 'B': {0: True}, 'S': {0: True}, 'W': {0: True}, 'y': {0: True}, 'Y': {0: True}}}
INVERSE_ESCAPE_SEQUENCES: Dict[str, str] = {}
ALIAS_POST_TABLESAMPLE = True
@classmethod
def can_identify(text: str, identify: str | bool = 'safe') -> bool: View Source

    279    @classmethod
    280    def can_identify(cls, text: str, identify: str | bool = "safe") -> bool:
    281        """Checks if text can be identified given an identify option.
    282
    283        Args:
    284            text: The text to check.
    285            identify:
    286                "always" or `True`: Always returns true.
    287                "safe": True if the identifier is case-insensitive.
    288
    289        Returns:
    290            Whether or not the given text can be identified.
    291        """
    292        if identify is True or identify == "always":
    293            return True
    294
    295        if identify == "safe":
    296            return not cls.case_sensitive(text)
    297
    298        return False

Checks if text can be identified given an identify option.

###### Arguments:

- text: The text to check.
- identify: "always" or `True`: Always returns true. "safe": True if the identifier is case-insensitive.

###### Returns:

> Whether or not the given text can be identified.

QUOTE_START = "'"
QUOTE_END = "'"
IDENTIFIER_START = '"'
IDENTIFIER_END = '"'
TOKENIZER_CLASS = <class 'Oracle.Tokenizer'>
BIT_START: Optional[str] = None
BIT_END: Optional[str] = None
HEX_START: Optional[str] = None
HEX_END: Optional[str] = None
BYTE_START: Optional[str] = None
BYTE_END: Optional[str] = None

##### Inherited Members

sqlglot.generator.Generator
  Generator
  LOG_BASE_FIRST
  NULL_ORDERING_SUPPORTED
  EXPLICIT_UNION
  WRAP_DERIVED_VALUES
  CREATE_FUNCTION_RETURN_AS
  MATCHED_BY_SOURCE
  SINGLE_STRING_INTERVAL
  INTERVAL_ALLOWS_PLURAL_FORM
  TABLESAMPLE_WITH_METHOD
  TABLESAMPLE_SIZE_IS_PERCENT
  RENAME_TABLE_WITH_DB
  GROUPINGS_SEP
  INDEX_ON
  QUERY_HINTS
  QUERY_HINT_SEP
  IS_BOOL_ALLOWED
  DUPLICATE_KEY_UPDATE_WITH_SET
  LIMIT_IS_TOP
  RETURNING_END
  EXTRACT_ALLOWS_QUOTES
  TZ_TO_WITH_TIME_ZONE
  NVL2_SUPPORTED
  VALUES_AS_TABLE
  ALTER_TABLE_ADD_COLUMN_KEYWORD
  UNNEST_WITH_ORDINALITY
  AGGREGATE_FILTER_SUPPORTED
  SEMI_ANTI_JOIN_WITH_SIDE
  SUPPORTS_PARAMETERS
  COMPUTED_COLUMN_WITH_TYPE
  SUPPORTS_TABLE_COPY
  TABLESAMPLE_REQUIRES_PARENS
  COLLATE_IS_FUNC
  STAR_MAPPING
  TIME_PART_SINGULARS
  TOKEN_MAPPING
  STRUCT_DELIMITER
  PARAMETER_TOKEN
  RESERVED_KEYWORDS
  WITH_SEPARATED_COMMENTS
  UNWRAPPED_INTERVAL_VALUES
  SENTINEL_LINE_BREAK
  INDEX_OFFSET
  UNNEST_COLUMN_ONLY
  IDENTIFIERS_CAN_START_WITH_DIGIT
  STRICT_STRING_CONCAT
  NORMALIZE_FUNCTIONS
  NULL_ORDERING
  pretty
  identify
  normalize
  pad
  unsupported_level
  max_unsupported
  leading_comma
  max_text_width
  comments
  normalize_functions
  unsupported_messages
  generate
  unsupported
  sep
  seg
  pad_comment
  maybe_comment
  wrap
  no_identify
  normalize_func
  indent
  sql
  uncache_sql
  cache_sql
  characterset_sql
  column_sql
  columnposition_sql
  columndef_sql
  columnconstraint_sql
  computedcolumnconstraint_sql
  autoincrementcolumnconstraint_sql
  compresscolumnconstraint_sql
  generatedasidentitycolumnconstraint_sql
  notnullcolumnconstraint_sql
  primarykeycolumnconstraint_sql
  uniquecolumnconstraint_sql
  createable_sql
  create_sql
  clone_sql
  describe_sql
  prepend_ctes
  with_sql
  cte_sql
  tablealias_sql
  bitstring_sql
  hexstring_sql
  bytestring_sql
  rawstring_sql
  datatypeparam_sql
  datatype_sql
  directory_sql
  delete_sql
  drop_sql
  except_sql
  except_op
  fetch_sql
  filter_sql
  hint_sql
  index_sql
  identifier_sql
  inputoutputformat_sql
  national_sql
  partition_sql
  properties_sql
  root_properties
  properties
  with_properties
  locate_properties
  property_name
  property_sql
  likeproperty_sql
  fallbackproperty_sql
  journalproperty_sql
  freespaceproperty_sql
  checksumproperty_sql
  mergeblockratioproperty_sql
  datablocksizeproperty_sql
  blockcompressionproperty_sql
  isolatedloadingproperty_sql
  lockingproperty_sql
  withdataproperty_sql
  insert_sql
  intersect_sql
  intersect_op
  introducer_sql
  kill_sql
  pseudotype_sql
  objectidentifier_sql
  onconflict_sql
  returning_sql
  rowformatdelimitedproperty_sql
  withtablehint_sql
  indextablehint_sql
  table_sql
  tablesample_sql
  pivot_sql
  version_sql
  tuple_sql
  update_sql
  values_sql
  var_sql
  into_sql
  from_sql
  group_sql
  having_sql
  connect_sql
  prior_sql
  join_sql
  lambda_sql
  lateral_sql
  limit_sql
  setitem_sql
  set_sql
  pragma_sql
  lock_sql
  literal_sql
  escape_str
  loaddata_sql
  null_sql
  boolean_sql
  order_sql
  cluster_sql
  distribute_sql
  sort_sql
  ordered_sql
  matchrecognize_sql
  query_modifiers
  offset_limit_modifiers
  after_having_modifiers
  after_limit_modifiers
  select_sql
  schema_sql
  schema_columns_sql
  star_sql
  parameter_sql
  sessionparameter_sql
  placeholder_sql
  subquery_sql
  qualify_sql
  union_sql
  union_op
  unnest_sql
  where_sql
  window_sql
  partition_by_sql
  windowspec_sql
  withingroup_sql
  between_sql
  bracket_sql
  safebracket_sql
  all_sql
  any_sql
  exists_sql
  case_sql
  constraint_sql
  nextvaluefor_sql
  extract_sql
  trim_sql
  safeconcat_sql
  check_sql
  foreignkey_sql
  primarykey_sql
  if_sql
  matchagainst_sql
  jsonkeyvalue_sql
  formatjson_sql
  jsonobject_sql
  jsonarray_sql
  jsonarrayagg_sql
  jsoncolumndef_sql
  jsontable_sql
  openjsoncolumndef_sql
  openjson_sql
  in_sql
  in_unnest_op
  interval_sql
  return_sql
  reference_sql
  anonymous_sql
  paren_sql
  neg_sql
  not_sql
  alias_sql
  aliases_sql
  attimezone_sql
  add_sql
  and_sql
  xor_sql
  connector_sql
  bitwiseand_sql
  bitwiseleftshift_sql
  bitwisenot_sql
  bitwiseor_sql
  bitwiserightshift_sql
  bitwisexor_sql
  cast_sql
  currentdate_sql
  collate_sql
  command_sql
  comment_sql
  mergetreettlaction_sql
  mergetreettl_sql
  transaction_sql
  commit_sql
  rollback_sql
  altercolumn_sql
  renametable_sql
  altertable_sql
  droppartition_sql
  addconstraint_sql
  distinct_sql
  ignorenulls_sql
  respectnulls_sql
  intdiv_sql
  dpipe_sql
  safedpipe_sql
  div_sql
  overlaps_sql
  distance_sql
  dot_sql
  eq_sql
  escape_sql
  glob_sql
  gt_sql
  gte_sql
  ilike_sql
  ilikeany_sql
  is_sql
  like_sql
  likeany_sql
  similarto_sql
  lt_sql
  lte_sql
  mod_sql
  mul_sql
  neq_sql
  nullsafeeq_sql
  nullsafeneq_sql
  or_sql
  slice_sql
  sub_sql
  trycast_sql
  log_sql
  use_sql
  binary
  function_fallback_sql
  func
  format_args
  text_width
  format_time
  expressions
  op_expressions
  naked_property
  set_operation
  tag_sql
  token_sql
  userdefinedfunction_sql
  joinhint_sql
  kwarg_sql
  when_sql
  merge_sql
  tochar_sql
  dictproperty_sql
  dictrange_sql
  dictsubproperty_sql
  oncluster_sql
  clusteredbyproperty_sql
  anyvalue_sql
  querytransform_sql
  indexconstraintoption_sql
  indexcolumnconstraint_sql
  nvl2_sql
  comprehension_sql
  columnprefix_sql
  opclass_sql

class Oracle.Tokenizer(sqlglot.tokens.Tokenizer): View Source

    220    class Tokenizer(tokens.Tokenizer):
    221        VAR_SINGLE_TOKENS = {"@", "$", "#"}
    222
    223        KEYWORDS = {
    224            **tokens.Tokenizer.KEYWORDS,
    225            "(+)": TokenType.JOIN_MARKER,
    226            "BINARY_DOUBLE": TokenType.DOUBLE,
    227            "BINARY_FLOAT": TokenType.FLOAT,
    228            "COLUMNS": TokenType.COLUMN,
    229            "MATCH_RECOGNIZE": TokenType.MATCH_RECOGNIZE,
    230            "MINUS": TokenType.EXCEPT,
    231            "NVARCHAR2": TokenType.NVARCHAR,
    232            "SAMPLE": TokenType.TABLE_SAMPLE,
    233            "START": TokenType.BEGIN,
    234            "TOP": TokenType.TOP,
    235            "VARCHAR2": TokenType.VARCHAR,
    236        }

VAR_SINGLE_TOKENS = {'@', '#', '$'}
KEYWORDS = {'{%': <TokenType.BLOCK_START: 'BLOCK_START'>, '{%+': <TokenType.BLOCK_START: 'BLOCK_START'>, '{%-': <TokenType.BLOCK_START: 'BLOCK_START'>, '%}': <TokenType.BLOCK_END: 'BLOCK_END'>, '+%}': <TokenType.BLOCK_END: 'BLOCK_END'>, '-%}': <TokenType.BLOCK_END: 'BLOCK_END'>, '{{+': <TokenType.BLOCK_START: 'BLOCK_START'>, '{{-': <TokenType.BLOCK_START: 'BLOCK_START'>, '+}}': <TokenType.BLOCK_END: 'BLOCK_END'>, '-}}': <TokenType.BLOCK_END: 'BLOCK_END'>, '/*+': <TokenType.HINT: 'HINT'>, '==': <TokenType.EQ: 'EQ'>, '::': <TokenType.DCOLON: 'DCOLON'>, '||': <TokenType.DPIPE: 'DPIPE'>, '>=': <TokenType.GTE: 'GTE'>, '<=': <TokenType.LTE: 'LTE'>, '<>': <TokenType.NEQ: 'NEQ'>, '!=': <TokenType.NEQ: 'NEQ'>, '<=>': <TokenType.NULLSAFE_EQ: 'NULLSAFE_EQ'>, '->': <TokenType.ARROW: 'ARROW'>, '->>': <TokenType.DARROW: 'DARROW'>, '=>': <TokenType.FARROW: 'FARROW'>, '#>': <TokenType.HASH_ARROW: 'HASH_ARROW'>, '#>>': <TokenType.DHASH_ARROW: 'DHASH_ARROW'>, '<->': <TokenType.LR_ARROW: 'LR_ARROW'>, '&&': <TokenType.DAMP: 'DAMP'>, '??': <TokenType.DQMARK: 'DQMARK'>, 'ALL': <TokenType.ALL: 'ALL'>, 'ALWAYS': <TokenType.ALWAYS: 'ALWAYS'>, 'AND': <TokenType.AND: 'AND'>, 'ANTI': <TokenType.ANTI: 'ANTI'>, 'ANY': <TokenType.ANY: 'ANY'>, 'ASC': <TokenType.ASC: 'ASC'>, 'AS': <TokenType.ALIAS: 'ALIAS'>, 'ASOF': <TokenType.ASOF: 'ASOF'>, 'AUTOINCREMENT': <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, 'AUTO_INCREMENT': <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, 'BEGIN': <TokenType.BEGIN: 'BEGIN'>, 'BETWEEN': <TokenType.BETWEEN: 'BETWEEN'>, 'CACHE': <TokenType.CACHE: 'CACHE'>, 'UNCACHE': <TokenType.UNCACHE: 'UNCACHE'>, 'CASE': <TokenType.CASE: 'CASE'>, 'CHARACTER SET': <TokenType.CHARACTER_SET: 'CHARACTER_SET'>, 'CLUSTER BY': <TokenType.CLUSTER_BY: 'CLUSTER_BY'>, 'COLLATE': <TokenType.COLLATE: 'COLLATE'>, 'COLUMN': <TokenType.COLUMN: 'COLUMN'>, 'COMMIT': <TokenType.COMMIT: 'COMMIT'>, 'CONNECT BY': <TokenType.CONNECT_BY: 'CONNECT_BY'>, 'CONSTRAINT': <TokenType.CONSTRAINT: 'CONSTRAINT'>, 'CREATE': <TokenType.CREATE: 'CREATE'>, 'CROSS': <TokenType.CROSS: 'CROSS'>, 'CUBE': <TokenType.CUBE: 'CUBE'>, 'CURRENT_DATE': <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, 'CURRENT_TIME': <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, 'CURRENT_TIMESTAMP': <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, 'CURRENT_USER': <TokenType.CURRENT_USER: 'CURRENT_USER'>, 'DATABASE': <TokenType.DATABASE: 'DATABASE'>, 'DEFAULT': <TokenType.DEFAULT: 'DEFAULT'>, 'DELETE': <TokenType.DELETE: 'DELETE'>, 'DESC': <TokenType.DESC: 'DESC'>, 'DESCRIBE': <TokenType.DESCRIBE: 'DESCRIBE'>, 'DISTINCT': <TokenType.DISTINCT: 'DISTINCT'>, 'DISTRIBUTE BY': <TokenType.DISTRIBUTE_BY: 'DISTRIBUTE_BY'>, 'DIV': <TokenType.DIV: 'DIV'>, 'DROP': <TokenType.DROP: 'DROP'>, 'ELSE': <TokenType.ELSE: 'ELSE'>, 'END': <TokenType.END: 'END'>, 'ESCAPE': <TokenType.ESCAPE: 'ESCAPE'>, 'EXCEPT': <TokenType.EXCEPT: 'EXCEPT'>, 'EXECUTE': <TokenType.EXECUTE: 'EXECUTE'>, 'EXISTS': <TokenType.EXISTS: 'EXISTS'>, 'FALSE': <TokenType.FALSE: 'FALSE'>, 'FETCH': <TokenType.FETCH: 'FETCH'>, 'FILTER': <TokenType.FILTER: 'FILTER'>, 'FIRST': <TokenType.FIRST: 'FIRST'>, 'FULL': <TokenType.FULL: 'FULL'>, 'FUNCTION': <TokenType.FUNCTION: 'FUNCTION'>, 'FOR': <TokenType.FOR: 'FOR'>, 'FOREIGN KEY': <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, 'FORMAT': <TokenType.FORMAT: 'FORMAT'>, 'FROM': <TokenType.FROM: 'FROM'>, 'GEOGRAPHY': <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, 'GEOMETRY': <TokenType.GEOMETRY: 'GEOMETRY'>, 'GLOB': <TokenType.GLOB: 'GLOB'>, 'GROUP BY': <TokenType.GROUP_BY: 'GROUP_BY'>, 'GROUPING SETS': <TokenType.GROUPING_SETS: 'GROUPING_SETS'>, 'HAVING': <TokenType.HAVING: 'HAVING'>, 'ILIKE': <TokenType.ILIKE: 'ILIKE'>, 'IN': <TokenType.IN: 'IN'>, 'INDEX': <TokenType.INDEX: 'INDEX'>, 'INET': <TokenType.INET: 'INET'>, 'INNER': <TokenType.INNER: 'INNER'>, 'INSERT': <TokenType.INSERT: 'INSERT'>, 'INTERVAL': <TokenType.INTERVAL: 'INTERVAL'>, 'INTERSECT': <TokenType.INTERSECT: 'INTERSECT'>, 'INTO': <TokenType.INTO: 'INTO'>, 'IS': <TokenType.IS: 'IS'>, 'ISNULL': <TokenType.ISNULL: 'ISNULL'>, 'JOIN': <TokenType.JOIN: 'JOIN'>, 'KEEP': <TokenType.KEEP: 'KEEP'>, 'KILL': <TokenType.KILL: 'KILL'>, 'LATERAL': <TokenType.LATERAL: 'LATERAL'>, 'LEFT': <TokenType.LEFT: 'LEFT'>, 'LIKE': <TokenType.LIKE: 'LIKE'>, 'LIMIT': <TokenType.LIMIT: 'LIMIT'>, 'LOAD': <TokenType.LOAD: 'LOAD'>, 'LOCK': <TokenType.LOCK: 'LOCK'>, 'MERGE': <TokenType.MERGE: 'MERGE'>, 'NATURAL': <TokenType.NATURAL: 'NATURAL'>, 'NEXT': <TokenType.NEXT: 'NEXT'>, 'NOT': <TokenType.NOT: 'NOT'>, 'NOTNULL': <TokenType.NOTNULL: 'NOTNULL'>, 'NULL': <TokenType.NULL: 'NULL'>, 'OBJECT': <TokenType.OBJECT: 'OBJECT'>, 'OFFSET': <TokenType.OFFSET: 'OFFSET'>, 'ON': <TokenType.ON: 'ON'>, 'OR': <TokenType.OR: 'OR'>, 'XOR': <TokenType.XOR: 'XOR'>, 'ORDER BY': <TokenType.ORDER_BY: 'ORDER_BY'>, 'ORDINALITY': <TokenType.ORDINALITY: 'ORDINALITY'>, 'OUTER': <TokenType.OUTER: 'OUTER'>, 'OVER': <TokenType.OVER: 'OVER'>, 'OVERLAPS': <TokenType.OVERLAPS: 'OVERLAPS'>, 'OVERWRITE': <TokenType.OVERWRITE: 'OVERWRITE'>, 'PARTITION': <TokenType.PARTITION: 'PARTITION'>, 'PARTITION BY': <TokenType.PARTITION_BY: 'PARTITION_BY'>, 'PARTITIONED BY': <TokenType.PARTITION_BY: 'PARTITION_BY'>, 'PARTITIONED_BY': <TokenType.PARTITION_BY: 'PARTITION_BY'>, 'PERCENT': <TokenType.PERCENT: 'PERCENT'>, 'PIVOT': <TokenType.PIVOT: 'PIVOT'>, 'PRAGMA': <TokenType.PRAGMA: 'PRAGMA'>, 'PRIMARY KEY': <TokenType.PRIMARY_KEY: 'PRIMARY_KEY'>, 'PROCEDURE': <TokenType.PROCEDURE: 'PROCEDURE'>, 'QUALIFY': <TokenType.QUALIFY: 'QUALIFY'>, 'RANGE': <TokenType.RANGE: 'RANGE'>, 'RECURSIVE': <TokenType.RECURSIVE: 'RECURSIVE'>, 'REGEXP': <TokenType.RLIKE: 'RLIKE'>, 'REPLACE': <TokenType.REPLACE: 'REPLACE'>, 'RETURNING': <TokenType.RETURNING: 'RETURNING'>, 'REFERENCES': <TokenType.REFERENCES: 'REFERENCES'>, 'RIGHT': <TokenType.RIGHT: 'RIGHT'>, 'RLIKE': <TokenType.RLIKE: 'RLIKE'>, 'ROLLBACK': <TokenType.ROLLBACK: 'ROLLBACK'>, 'ROLLUP': <TokenType.ROLLUP: 'ROLLUP'>, 'ROW': <TokenType.ROW: 'ROW'>, 'ROWS': <TokenType.ROWS: 'ROWS'>, 'SCHEMA': <TokenType.SCHEMA: 'SCHEMA'>, 'SELECT': <TokenType.SELECT: 'SELECT'>, 'SEMI': <TokenType.SEMI: 'SEMI'>, 'SET': <TokenType.SET: 'SET'>, 'SETTINGS': <TokenType.SETTINGS: 'SETTINGS'>, 'SHOW': <TokenType.SHOW: 'SHOW'>, 'SIMILAR TO': <TokenType.SIMILAR_TO: 'SIMILAR_TO'>, 'SOME': <TokenType.SOME: 'SOME'>, 'SORT BY': <TokenType.SORT_BY: 'SORT_BY'>, 'START WITH': <TokenType.START_WITH: 'START_WITH'>, 'TABLE': <TokenType.TABLE: 'TABLE'>, 'TABLESAMPLE': <TokenType.TABLE_SAMPLE: 'TABLE_SAMPLE'>, 'TEMP': <TokenType.TEMPORARY: 'TEMPORARY'>, 'TEMPORARY': <TokenType.TEMPORARY: 'TEMPORARY'>, 'THEN': <TokenType.THEN: 'THEN'>, 'TRUE': <TokenType.TRUE: 'TRUE'>, 'UNION': <TokenType.UNION: 'UNION'>, 'UNKNOWN': <TokenType.UNKNOWN: 'UNKNOWN'>, 'UNNEST': <TokenType.UNNEST: 'UNNEST'>, 'UNPIVOT': <TokenType.UNPIVOT: 'UNPIVOT'>, 'UPDATE': <TokenType.UPDATE: 'UPDATE'>, 'USE': <TokenType.USE: 'USE'>, 'USING': <TokenType.USING: 'USING'>, 'UUID': <TokenType.UUID: 'UUID'>, 'VALUES': <TokenType.VALUES: 'VALUES'>, 'VIEW': <TokenType.VIEW: 'VIEW'>, 'VOLATILE': <TokenType.VOLATILE: 'VOLATILE'>, 'WHEN': <TokenType.WHEN: 'WHEN'>, 'WHERE': <TokenType.WHERE: 'WHERE'>, 'WINDOW': <TokenType.WINDOW: 'WINDOW'>, 'WITH': <TokenType.WITH: 'WITH'>, 'APPLY': <TokenType.APPLY: 'APPLY'>, 'ARRAY': <TokenType.ARRAY: 'ARRAY'>, 'BIT': <TokenType.BIT: 'BIT'>, 'BOOL': <TokenType.BOOLEAN: 'BOOLEAN'>, 'BOOLEAN': <TokenType.BOOLEAN: 'BOOLEAN'>, 'BYTE': <TokenType.TINYINT: 'TINYINT'>, 'MEDIUMINT': <TokenType.MEDIUMINT: 'MEDIUMINT'>, 'TINYINT': <TokenType.TINYINT: 'TINYINT'>, 'SHORT': <TokenType.SMALLINT: 'SMALLINT'>, 'SMALLINT': <TokenType.SMALLINT: 'SMALLINT'>, 'INT128': <TokenType.INT128: 'INT128'>, 'INT2': <TokenType.SMALLINT: 'SMALLINT'>, 'INTEGER': <TokenType.INT: 'INT'>, 'INT': <TokenType.INT: 'INT'>, 'INT4': <TokenType.INT: 'INT'>, 'LONG': <TokenType.BIGINT: 'BIGINT'>, 'BIGINT': <TokenType.BIGINT: 'BIGINT'>, 'INT8': <TokenType.BIGINT: 'BIGINT'>, 'DEC': <TokenType.DECIMAL: 'DECIMAL'>, 'DECIMAL': <TokenType.DECIMAL: 'DECIMAL'>, 'BIGDECIMAL': <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, 'BIGNUMERIC': <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, 'MAP': <TokenType.MAP: 'MAP'>, 'NULLABLE': <TokenType.NULLABLE: 'NULLABLE'>, 'NUMBER': <TokenType.DECIMAL: 'DECIMAL'>, 'NUMERIC': <TokenType.DECIMAL: 'DECIMAL'>, 'FIXED': <TokenType.DECIMAL: 'DECIMAL'>, 'REAL': <TokenType.FLOAT: 'FLOAT'>, 'FLOAT': <TokenType.FLOAT: 'FLOAT'>, 'FLOAT4': <TokenType.FLOAT: 'FLOAT'>, 'FLOAT8': <TokenType.DOUBLE: 'DOUBLE'>, 'DOUBLE': <TokenType.DOUBLE: 'DOUBLE'>, 'DOUBLE PRECISION': <TokenType.DOUBLE: 'DOUBLE'>, 'JSON': <TokenType.JSON: 'JSON'>, 'CHAR': <TokenType.CHAR: 'CHAR'>, 'CHARACTER': <TokenType.CHAR: 'CHAR'>, 'NCHAR': <TokenType.NCHAR: 'NCHAR'>, 'VARCHAR': <TokenType.VARCHAR: 'VARCHAR'>, 'VARCHAR2': <TokenType.VARCHAR: 'VARCHAR'>, 'NVARCHAR': <TokenType.NVARCHAR: 'NVARCHAR'>, 'NVARCHAR2': <TokenType.NVARCHAR: 'NVARCHAR'>, 'STR': <TokenType.TEXT: 'TEXT'>, 'STRING': <TokenType.TEXT: 'TEXT'>, 'TEXT': <TokenType.TEXT: 'TEXT'>, 'LONGTEXT': <TokenType.LONGTEXT: 'LONGTEXT'>, 'MEDIUMTEXT': <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, 'TINYTEXT': <TokenType.TINYTEXT: 'TINYTEXT'>, 'CLOB': <TokenType.TEXT: 'TEXT'>, 'LONGVARCHAR': <TokenType.TEXT: 'TEXT'>, 'BINARY': <TokenType.BINARY: 'BINARY'>, 'BLOB': <TokenType.VARBINARY: 'VARBINARY'>, 'LONGBLOB': <TokenType.LONGBLOB: 'LONGBLOB'>, 'MEDIUMBLOB': <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, 'TINYBLOB': <TokenType.TINYBLOB: 'TINYBLOB'>, 'BYTEA': <TokenType.VARBINARY: 'VARBINARY'>, 'VARBINARY': <TokenType.VARBINARY: 'VARBINARY'>, 'TIME': <TokenType.TIME: 'TIME'>, 'TIMETZ': <TokenType.TIMETZ: 'TIMETZ'>, 'TIMESTAMP': <TokenType.TIMESTAMP: 'TIMESTAMP'>, 'TIMESTAMPTZ': <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, 'TIMESTAMPLTZ': <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, 'DATE': <TokenType.DATE: 'DATE'>, 'DATETIME': <TokenType.DATETIME: 'DATETIME'>, 'INT4RANGE': <TokenType.INT4RANGE: 'INT4RANGE'>, 'INT4MULTIRANGE': <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, 'INT8RANGE': <TokenType.INT8RANGE: 'INT8RANGE'>, 'INT8MULTIRANGE': <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, 'NUMRANGE': <TokenType.NUMRANGE: 'NUMRANGE'>, 'NUMMULTIRANGE': <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, 'TSRANGE': <TokenType.TSRANGE: 'TSRANGE'>, 'TSMULTIRANGE': <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, 'TSTZRANGE': <TokenType.TSTZRANGE: 'TSTZRANGE'>, 'TSTZMULTIRANGE': <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, 'DATERANGE': <TokenType.DATERANGE: 'DATERANGE'>, 'DATEMULTIRANGE': <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, 'UNIQUE': <TokenType.UNIQUE: 'UNIQUE'>, 'STRUCT': <TokenType.STRUCT: 'STRUCT'>, 'VARIANT': <TokenType.VARIANT: 'VARIANT'>, 'ALTER': <TokenType.ALTER: 'ALTER'>, 'ANALYZE': <TokenType.COMMAND: 'COMMAND'>, 'CALL': <TokenType.COMMAND: 'COMMAND'>, 'COMMENT': <TokenType.COMMENT: 'COMMENT'>, 'COPY': <TokenType.COMMAND: 'COMMAND'>, 'EXPLAIN': <TokenType.COMMAND: 'COMMAND'>, 'GRANT': <TokenType.COMMAND: 'COMMAND'>, 'OPTIMIZE': <TokenType.COMMAND: 'COMMAND'>, 'PREPARE': <TokenType.COMMAND: 'COMMAND'>, 'TRUNCATE': <TokenType.COMMAND: 'COMMAND'>, 'VACUUM': <TokenType.COMMAND: 'COMMAND'>, 'USER-DEFINED': <TokenType.USERDEFINED: 'USERDEFINED'>, 'FOR VERSION': <TokenType.VERSION_SNAPSHOT: 'VERSION_SNAPSHOT'>, 'FOR TIMESTAMP': <TokenType.TIMESTAMP_SNAPSHOT: 'TIMESTAMP_SNAPSHOT'>, '(+)': <TokenType.JOIN_MARKER: 'JOIN_MARKER'>, 'BINARY_DOUBLE': <TokenType.DOUBLE: 'DOUBLE'>, 'BINARY_FLOAT': <TokenType.FLOAT: 'FLOAT'>, 'COLUMNS': <TokenType.COLUMN: 'COLUMN'>, 'MATCH_RECOGNIZE': <TokenType.MATCH_RECOGNIZE: 'MATCH_RECOGNIZE'>, 'MINUS': <TokenType.EXCEPT: 'EXCEPT'>, 'SAMPLE': <TokenType.TABLE_SAMPLE: 'TABLE_SAMPLE'>, 'START': <TokenType.BEGIN: 'BEGIN'>, 'TOP': <TokenType.TOP: 'TOP'>}

##### Inherited Members

sqlglot.tokens.Tokenizer
  SINGLE_TOKENS
  BIT_STRINGS
  BYTE_STRINGS
  HEX_STRINGS
  RAW_STRINGS
  HEREDOC_STRINGS
  IDENTIFIERS
  IDENTIFIER_ESCAPES
  QUOTES
  STRING_ESCAPES
  ESCAPE_SEQUENCES
  IDENTIFIERS_CAN_START_WITH_DIGIT
  WHITE_SPACE
  COMMANDS
  COMMAND_PREFIX_TOKENS
  NUMERIC_LITERALS
  ENCODE
  COMMENTS
  reset
  tokenize
  peek
  size
  sql
  tokens