Edit on GitHub

sqlglot.dialects.singlestore

   1import re
   2
   3from sqlglot import TokenType
   4import typing as t
   5
   6from sqlglot import exp
   7from sqlglot.dialects.dialect import (
   8    build_formatted_time,
   9    build_json_extract_path,
  10    json_extract_segments,
  11    json_path_key_only_name,
  12    rename_func,
  13    bool_xor_sql,
  14    count_if_to_sum,
  15    timestamptrunc_sql,
  16    date_add_interval_sql,
  17    timestampdiff_sql,
  18)
  19from sqlglot.dialects.mysql import MySQL, _remove_ts_or_ds_to_date, date_add_sql
  20from sqlglot.expressions import DataType
  21from sqlglot.generator import unsupported_args
  22from sqlglot.helper import seq_get
  23
  24
  25def cast_to_time6(
  26    expression: t.Optional[exp.Expression], time_type: DataType.Type = exp.DataType.Type.TIME
  27) -> exp.Cast:
  28    return exp.Cast(
  29        this=expression,
  30        to=exp.DataType.build(
  31            time_type,
  32            expressions=[exp.DataTypeParam(this=exp.Literal.number(6))],
  33        ),
  34    )
  35
  36
  37class SingleStore(MySQL):
  38    SUPPORTS_ORDER_BY_ALL = True
  39
  40    TIME_MAPPING: t.Dict[str, str] = {
  41        "D": "%u",  # Day of week (1-7)
  42        "DD": "%d",  # day of month (01-31)
  43        "DY": "%a",  # abbreviated name of day
  44        "HH": "%I",  # Hour of day (01-12)
  45        "HH12": "%I",  # alias for HH
  46        "HH24": "%H",  # Hour of day (00-23)
  47        "MI": "%M",  # Minute (00-59)
  48        "MM": "%m",  # Month (01-12; January = 01)
  49        "MON": "%b",  # Abbreviated name of month
  50        "MONTH": "%B",  # Name of month
  51        "SS": "%S",  # Second (00-59)
  52        "RR": "%y",  # 15
  53        "YY": "%y",  # 15
  54        "YYYY": "%Y",  # 2015
  55        "FF6": "%f",  # only 6 digits are supported in python formats
  56    }
  57
  58    class Tokenizer(MySQL.Tokenizer):
  59        BYTE_STRINGS = [("e'", "'"), ("E'", "'")]
  60
  61        KEYWORDS = {
  62            **MySQL.Tokenizer.KEYWORDS,
  63            "BSON": TokenType.JSONB,
  64            "GEOGRAPHYPOINT": TokenType.GEOGRAPHYPOINT,
  65            "TIMESTAMP": TokenType.TIMESTAMP,
  66            "UTC_DATE": TokenType.UTC_DATE,
  67            "UTC_TIME": TokenType.UTC_TIME,
  68            "UTC_TIMESTAMP": TokenType.UTC_TIMESTAMP,
  69            ":>": TokenType.COLON_GT,
  70            "!:>": TokenType.NCOLON_GT,
  71            "::$": TokenType.DCOLONDOLLAR,
  72            "::%": TokenType.DCOLONPERCENT,
  73        }
  74
  75    class Parser(MySQL.Parser):
  76        FUNCTIONS = {
  77            **MySQL.Parser.FUNCTIONS,
  78            "TO_DATE": build_formatted_time(exp.TsOrDsToDate, "singlestore"),
  79            "TO_TIMESTAMP": build_formatted_time(exp.StrToTime, "singlestore"),
  80            "TO_CHAR": build_formatted_time(exp.ToChar, "singlestore"),
  81            "STR_TO_DATE": build_formatted_time(exp.StrToDate, "mysql"),
  82            "DATE_FORMAT": build_formatted_time(exp.TimeToStr, "mysql"),
  83            # The first argument of following functions is converted to TIME(6)
  84            # This is needed because exp.TimeToStr is converted to DATE_FORMAT
  85            # which interprets the first argument as DATETIME and fails to parse
  86            # string literals like '12:05:47' without a date part.
  87            "TIME_FORMAT": lambda args: exp.TimeToStr(
  88                this=cast_to_time6(seq_get(args, 0)),
  89                format=MySQL.format_time(seq_get(args, 1)),
  90            ),
  91            "HOUR": lambda args: exp.cast(
  92                exp.TimeToStr(
  93                    this=cast_to_time6(seq_get(args, 0)),
  94                    format=MySQL.format_time(exp.Literal.string("%k")),
  95                ),
  96                DataType.Type.INT,
  97            ),
  98            "MICROSECOND": lambda args: exp.cast(
  99                exp.TimeToStr(
 100                    this=cast_to_time6(seq_get(args, 0)),
 101                    format=MySQL.format_time(exp.Literal.string("%f")),
 102                ),
 103                DataType.Type.INT,
 104            ),
 105            "SECOND": lambda args: exp.cast(
 106                exp.TimeToStr(
 107                    this=cast_to_time6(seq_get(args, 0)),
 108                    format=MySQL.format_time(exp.Literal.string("%s")),
 109                ),
 110                DataType.Type.INT,
 111            ),
 112            "MINUTE": lambda args: exp.cast(
 113                exp.TimeToStr(
 114                    this=cast_to_time6(seq_get(args, 0)),
 115                    format=MySQL.format_time(exp.Literal.string("%i")),
 116                ),
 117                DataType.Type.INT,
 118            ),
 119            "MONTHNAME": lambda args: exp.TimeToStr(
 120                this=seq_get(args, 0),
 121                format=MySQL.format_time(exp.Literal.string("%M")),
 122            ),
 123            "WEEKDAY": lambda args: exp.paren(exp.DayOfWeek(this=seq_get(args, 0)) + 5, copy=False)
 124            % 7,
 125            "UNIX_TIMESTAMP": exp.StrToUnix.from_arg_list,
 126            "FROM_UNIXTIME": build_formatted_time(exp.UnixToTime, "mysql"),
 127            "TIME_BUCKET": lambda args: exp.DateBin(
 128                this=seq_get(args, 0),
 129                expression=seq_get(args, 1),
 130                origin=seq_get(args, 2),
 131            ),
 132            "BSON_EXTRACT_BSON": build_json_extract_path(exp.JSONBExtract),
 133            "BSON_EXTRACT_STRING": build_json_extract_path(
 134                exp.JSONBExtractScalar, json_type="STRING"
 135            ),
 136            "BSON_EXTRACT_DOUBLE": build_json_extract_path(
 137                exp.JSONBExtractScalar, json_type="DOUBLE"
 138            ),
 139            "BSON_EXTRACT_BIGINT": build_json_extract_path(
 140                exp.JSONBExtractScalar, json_type="BIGINT"
 141            ),
 142            "JSON_EXTRACT_JSON": build_json_extract_path(exp.JSONExtract),
 143            "JSON_EXTRACT_STRING": build_json_extract_path(
 144                exp.JSONExtractScalar, json_type="STRING"
 145            ),
 146            "JSON_EXTRACT_DOUBLE": build_json_extract_path(
 147                exp.JSONExtractScalar, json_type="DOUBLE"
 148            ),
 149            "JSON_EXTRACT_BIGINT": build_json_extract_path(
 150                exp.JSONExtractScalar, json_type="BIGINT"
 151            ),
 152            "JSON_ARRAY_CONTAINS_STRING": lambda args: exp.JSONArrayContains(
 153                this=seq_get(args, 1),
 154                expression=seq_get(args, 0),
 155                json_type="STRING",
 156            ),
 157            "JSON_ARRAY_CONTAINS_DOUBLE": lambda args: exp.JSONArrayContains(
 158                this=seq_get(args, 1),
 159                expression=seq_get(args, 0),
 160                json_type="DOUBLE",
 161            ),
 162            "JSON_ARRAY_CONTAINS_JSON": lambda args: exp.JSONArrayContains(
 163                this=seq_get(args, 1),
 164                expression=seq_get(args, 0),
 165                json_type="JSON",
 166            ),
 167            "JSON_PRETTY": exp.JSONFormat.from_arg_list,
 168            "JSON_BUILD_ARRAY": lambda args: exp.JSONArray(expressions=args),
 169            "JSON_BUILD_OBJECT": lambda args: exp.JSONObject(expressions=args),
 170            "DATE": exp.Date.from_arg_list,
 171            "DAYNAME": lambda args: exp.TimeToStr(
 172                this=seq_get(args, 0),
 173                format=MySQL.format_time(exp.Literal.string("%W")),
 174            ),
 175            "TIMESTAMPDIFF": lambda args: exp.TimestampDiff(
 176                this=seq_get(args, 2),
 177                expression=seq_get(args, 1),
 178                unit=seq_get(args, 0),
 179            ),
 180            "APPROX_COUNT_DISTINCT": exp.Hll.from_arg_list,
 181            "APPROX_PERCENTILE": lambda args, dialect: exp.ApproxQuantile(
 182                this=seq_get(args, 0),
 183                quantile=seq_get(args, 1),
 184                error_tolerance=seq_get(args, 2),
 185            ),
 186            "VARIANCE": exp.VariancePop.from_arg_list,
 187            "INSTR": exp.Contains.from_arg_list,
 188            "REGEXP_MATCH": lambda args: exp.RegexpExtractAll(
 189                this=seq_get(args, 0),
 190                expression=seq_get(args, 1),
 191                parameters=seq_get(args, 2),
 192            ),
 193            "REGEXP_SUBSTR": lambda args: exp.RegexpExtract(
 194                this=seq_get(args, 0),
 195                expression=seq_get(args, 1),
 196                position=seq_get(args, 2),
 197                occurrence=seq_get(args, 3),
 198                parameters=seq_get(args, 4),
 199            ),
 200            "REDUCE": lambda args: exp.Reduce(
 201                initial=seq_get(args, 0),
 202                this=seq_get(args, 1),
 203                merge=seq_get(args, 2),
 204            ),
 205        }
 206
 207        FUNCTION_PARSERS: t.Dict[str, t.Callable] = {
 208            **MySQL.Parser.FUNCTION_PARSERS,
 209            "JSON_AGG": lambda self: exp.JSONArrayAgg(
 210                this=self._parse_term(),
 211                order=self._parse_order(),
 212            ),
 213        }
 214
 215        NO_PAREN_FUNCTIONS = {
 216            **MySQL.Parser.NO_PAREN_FUNCTIONS,
 217            TokenType.UTC_DATE: exp.UtcDate,
 218            TokenType.UTC_TIME: exp.UtcTime,
 219            TokenType.UTC_TIMESTAMP: exp.UtcTimestamp,
 220        }
 221
 222        CAST_COLUMN_OPERATORS = {TokenType.COLON_GT, TokenType.NCOLON_GT}
 223
 224        COLUMN_OPERATORS = {
 225            **MySQL.Parser.COLUMN_OPERATORS,
 226            TokenType.COLON_GT: lambda self, this, to: self.expression(
 227                exp.Cast,
 228                this=this,
 229                to=to,
 230            ),
 231            TokenType.NCOLON_GT: lambda self, this, to: self.expression(
 232                exp.TryCast,
 233                this=this,
 234                to=to,
 235            ),
 236            TokenType.DCOLON: lambda self, this, path: build_json_extract_path(exp.JSONExtract)(
 237                [this, exp.Literal.string(path.name)]
 238            ),
 239            TokenType.DCOLONDOLLAR: lambda self, this, path: build_json_extract_path(
 240                exp.JSONExtractScalar, json_type="STRING"
 241            )([this, exp.Literal.string(path.name)]),
 242            TokenType.DCOLONPERCENT: lambda self, this, path: build_json_extract_path(
 243                exp.JSONExtractScalar, json_type="DOUBLE"
 244            )([this, exp.Literal.string(path.name)]),
 245        }
 246        COLUMN_OPERATORS.pop(TokenType.ARROW)
 247        COLUMN_OPERATORS.pop(TokenType.DARROW)
 248        COLUMN_OPERATORS.pop(TokenType.HASH_ARROW)
 249        COLUMN_OPERATORS.pop(TokenType.DHASH_ARROW)
 250        COLUMN_OPERATORS.pop(TokenType.PLACEHOLDER)
 251
 252    class Generator(MySQL.Generator):
 253        SUPPORTS_UESCAPE = False
 254        NULL_ORDERING_SUPPORTED = True
 255        MATCH_AGAINST_TABLE_PREFIX = "TABLE "
 256
 257        @staticmethod
 258        def _unicode_substitute(m: re.Match[str]) -> str:
 259            # Interpret the number as hex and convert it to the Unicode string
 260            return chr(int(m.group(1), 16))
 261
 262        UNICODE_SUBSTITUTE: t.Optional[t.Callable[[re.Match[str]], str]] = _unicode_substitute
 263
 264        SUPPORTED_JSON_PATH_PARTS = {
 265            exp.JSONPathKey,
 266            exp.JSONPathRoot,
 267            exp.JSONPathSubscript,
 268        }
 269
 270        TRANSFORMS = {
 271            **MySQL.Generator.TRANSFORMS,
 272            exp.TsOrDsToDate: lambda self, e: self.func("TO_DATE", e.this, self.format_time(e))
 273            if e.args.get("format")
 274            else self.func("DATE", e.this),
 275            exp.StrToTime: lambda self, e: self.func("TO_TIMESTAMP", e.this, self.format_time(e)),
 276            exp.ToChar: lambda self, e: self.func("TO_CHAR", e.this, self.format_time(e)),
 277            exp.StrToDate: lambda self, e: self.func(
 278                "STR_TO_DATE",
 279                e.this,
 280                self.format_time(
 281                    e,
 282                    inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING,
 283                    inverse_time_trie=MySQL.INVERSE_TIME_TRIE,
 284                ),
 285            ),
 286            exp.TimeToStr: lambda self, e: self.func(
 287                "DATE_FORMAT",
 288                e.this,
 289                self.format_time(
 290                    e,
 291                    inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING,
 292                    inverse_time_trie=MySQL.INVERSE_TIME_TRIE,
 293                ),
 294            ),
 295            exp.Date: unsupported_args("zone", "expressions")(rename_func("DATE")),
 296            exp.Cast: unsupported_args("format", "action", "default")(
 297                lambda self, e: f"{self.sql(e, 'this')} :> {self.sql(e, 'to')}"
 298            ),
 299            exp.TryCast: unsupported_args("format", "action", "default")(
 300                lambda self, e: f"{self.sql(e, 'this')} !:> {self.sql(e, 'to')}"
 301            ),
 302            exp.CastToStrType: lambda self, e: self.sql(
 303                exp.cast(e.this, DataType.build(e.args["to"].name))
 304            ),
 305            exp.StrToUnix: unsupported_args("format")(rename_func("UNIX_TIMESTAMP")),
 306            exp.TimeToUnix: rename_func("UNIX_TIMESTAMP"),
 307            exp.TimeStrToUnix: rename_func("UNIX_TIMESTAMP"),
 308            exp.UnixSeconds: rename_func("UNIX_TIMESTAMP"),
 309            exp.UnixToStr: lambda self, e: self.func(
 310                "FROM_UNIXTIME",
 311                e.this,
 312                self.format_time(
 313                    e,
 314                    inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING,
 315                    inverse_time_trie=MySQL.INVERSE_TIME_TRIE,
 316                ),
 317            ),
 318            exp.UnixToTime: unsupported_args("scale", "zone", "hours", "minutes")(
 319                lambda self, e: self.func(
 320                    "FROM_UNIXTIME",
 321                    e.this,
 322                    self.format_time(
 323                        e,
 324                        inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING,
 325                        inverse_time_trie=MySQL.INVERSE_TIME_TRIE,
 326                    ),
 327                ),
 328            ),
 329            exp.UnixToTimeStr: lambda self, e: f"FROM_UNIXTIME({self.sql(e, 'this')}) :> TEXT",
 330            exp.DateBin: unsupported_args("unit", "zone")(
 331                lambda self, e: self.func("TIME_BUCKET", e.this, e.expression, e.args.get("origin"))
 332            ),
 333            exp.TimeStrToDate: lambda self, e: self.sql(exp.cast(e.this, exp.DataType.Type.DATE)),
 334            exp.FromTimeZone: lambda self, e: self.func(
 335                "CONVERT_TZ", e.this, e.args.get("zone"), "'UTC'"
 336            ),
 337            exp.DiToDate: lambda self,
 338            e: f"STR_TO_DATE({self.sql(e, 'this')}, {SingleStore.DATEINT_FORMAT})",
 339            exp.DateToDi: lambda self,
 340            e: f"(DATE_FORMAT({self.sql(e, 'this')}, {SingleStore.DATEINT_FORMAT}) :> INT)",
 341            exp.TsOrDiToDi: lambda self,
 342            e: f"(DATE_FORMAT({self.sql(e, 'this')}, {SingleStore.DATEINT_FORMAT}) :> INT)",
 343            exp.Time: unsupported_args("zone")(lambda self, e: f"{self.sql(e, 'this')} :> TIME"),
 344            exp.DatetimeAdd: _remove_ts_or_ds_to_date(date_add_sql("ADD")),
 345            exp.DatetimeTrunc: unsupported_args("zone")(timestamptrunc_sql()),
 346            exp.DatetimeSub: date_add_interval_sql("DATE", "SUB"),
 347            exp.DatetimeDiff: timestampdiff_sql,
 348            exp.DateTrunc: unsupported_args("zone")(timestamptrunc_sql()),
 349            exp.DateDiff: unsupported_args("zone")(
 350                lambda self, e: timestampdiff_sql(self, e)
 351                if e.unit is not None
 352                else self.func("DATEDIFF", e.this, e.expression)
 353            ),
 354            exp.TsOrDsDiff: lambda self, e: timestampdiff_sql(self, e)
 355            if e.unit is not None
 356            else self.func("DATEDIFF", e.this, e.expression),
 357            exp.TimestampTrunc: unsupported_args("zone")(timestamptrunc_sql()),
 358            exp.CurrentDatetime: lambda self, e: self.sql(
 359                cast_to_time6(
 360                    exp.CurrentTimestamp(this=exp.Literal.number(6)), exp.DataType.Type.DATETIME
 361                )
 362            ),
 363            exp.JSONExtract: unsupported_args(
 364                "only_json_types",
 365                "expressions",
 366                "variant_extract",
 367                "json_query",
 368                "option",
 369                "quote",
 370                "on_condition",
 371                "requires_json",
 372            )(json_extract_segments("JSON_EXTRACT_JSON")),
 373            exp.JSONBExtract: json_extract_segments("BSON_EXTRACT_BSON"),
 374            exp.JSONPathKey: json_path_key_only_name,
 375            exp.JSONPathSubscript: lambda self, e: self.json_path_part(e.this),
 376            exp.JSONPathRoot: lambda *_: "",
 377            exp.JSONFormat: unsupported_args("options", "is_json")(rename_func("JSON_PRETTY")),
 378            exp.JSONArrayAgg: unsupported_args("null_handling", "return_type", "strict")(
 379                lambda self, e: self.func("JSON_AGG", e.this, suffix=f"{self.sql(e, 'order')})")
 380            ),
 381            exp.JSONArray: unsupported_args("null_handling", "return_type", "strict")(
 382                rename_func("JSON_BUILD_ARRAY")
 383            ),
 384            exp.JSONBExists: lambda self, e: self.func(
 385                "BSON_MATCH_ANY_EXISTS", e.this, e.args.get("path")
 386            ),
 387            exp.JSONExists: unsupported_args("passing", "on_condition")(
 388                lambda self, e: self.func("JSON_MATCH_ANY_EXISTS", e.this, e.args.get("path"))
 389            ),
 390            exp.JSONObject: unsupported_args(
 391                "null_handling", "unique_keys", "return_type", "encoding"
 392            )(rename_func("JSON_BUILD_OBJECT")),
 393            exp.DayOfWeekIso: lambda self, e: f"(({self.func('DAYOFWEEK', e.this)} % 7) + 1)",
 394            exp.DayOfMonth: rename_func("DAY"),
 395            exp.Hll: rename_func("APPROX_COUNT_DISTINCT"),
 396            exp.ApproxDistinct: rename_func("APPROX_COUNT_DISTINCT"),
 397            exp.CountIf: count_if_to_sum,
 398            exp.LogicalOr: lambda self, e: f"MAX(ABS({self.sql(e, 'this')}))",
 399            exp.LogicalAnd: lambda self, e: f"MIN(ABS({self.sql(e, 'this')}))",
 400            exp.ApproxQuantile: unsupported_args("accuracy", "weight")(
 401                lambda self, e: self.func(
 402                    "APPROX_PERCENTILE",
 403                    e.this,
 404                    e.args.get("quantile"),
 405                    e.args.get("error_tolerance"),
 406                )
 407            ),
 408            exp.Variance: rename_func("VAR_SAMP"),
 409            exp.VariancePop: rename_func("VAR_POP"),
 410            exp.Xor: bool_xor_sql,
 411            exp.Cbrt: lambda self, e: self.sql(
 412                exp.Pow(this=e.this, expression=exp.Literal.number(1) / exp.Literal.number(3))
 413            ),
 414            exp.RegexpLike: lambda self, e: self.binary(e, "RLIKE"),
 415            exp.Repeat: lambda self, e: self.func(
 416                "LPAD",
 417                exp.Literal.string(""),
 418                exp.Mul(this=self.func("LENGTH", e.this), expression=e.args.get("times")),
 419                e.this,
 420            ),
 421            exp.IsAscii: lambda self, e: f"({self.sql(e, 'this')} RLIKE '^[\x00-\x7f]*$')",
 422            exp.MD5Digest: lambda self, e: self.func("UNHEX", self.func("MD5", e.this)),
 423            exp.Chr: rename_func("CHAR"),
 424            exp.Contains: rename_func("INSTR"),
 425            exp.RegexpExtractAll: unsupported_args("position", "occurrence", "group")(
 426                lambda self, e: self.func(
 427                    "REGEXP_MATCH",
 428                    e.this,
 429                    e.expression,
 430                    e.args.get("parameters"),
 431                )
 432            ),
 433            exp.RegexpExtract: unsupported_args("group")(
 434                lambda self, e: self.func(
 435                    "REGEXP_SUBSTR",
 436                    e.this,
 437                    e.expression,
 438                    e.args.get("position"),
 439                    e.args.get("occurrence"),
 440                    e.args.get("parameters"),
 441                )
 442            ),
 443            exp.StartsWith: lambda self, e: self.func(
 444                "REGEXP_INSTR", e.this, self.func("CONCAT", exp.Literal.string("^"), e.expression)
 445            ),
 446            exp.FromBase: lambda self, e: self.func(
 447                "CONV", e.this, e.expression, exp.Literal.number(10)
 448            ),
 449            exp.RegexpILike: lambda self, e: self.binary(
 450                exp.RegexpLike(
 451                    this=exp.Lower(this=e.this),
 452                    expression=exp.Lower(this=e.expression),
 453                ),
 454                "RLIKE",
 455            ),
 456            exp.Stuff: lambda self, e: self.func(
 457                "CONCAT",
 458                self.func("SUBSTRING", e.this, exp.Literal.number(1), e.args.get("start") - 1),
 459                e.expression,
 460                self.func("SUBSTRING", e.this, e.args.get("start") + e.args.get("length")),
 461            ),
 462            exp.Reduce: unsupported_args("finish")(
 463                lambda self, e: self.func(
 464                    "REDUCE", e.args.get("initial"), e.this, e.args.get("merge")
 465                )
 466            ),
 467            exp.MatchAgainst: unsupported_args("modifier")(
 468                lambda self, e: super().matchagainst_sql(e)
 469            ),
 470        }
 471        TRANSFORMS.pop(exp.JSONExtractScalar)
 472        TRANSFORMS.pop(exp.CurrentDate)
 473
 474        UNSUPPORTED_TYPES = {
 475            exp.DataType.Type.ARRAY,
 476            exp.DataType.Type.AGGREGATEFUNCTION,
 477            exp.DataType.Type.SIMPLEAGGREGATEFUNCTION,
 478            exp.DataType.Type.BIGSERIAL,
 479            exp.DataType.Type.BPCHAR,
 480            exp.DataType.Type.DATEMULTIRANGE,
 481            exp.DataType.Type.DATERANGE,
 482            exp.DataType.Type.DYNAMIC,
 483            exp.DataType.Type.HLLSKETCH,
 484            exp.DataType.Type.HSTORE,
 485            exp.DataType.Type.IMAGE,
 486            exp.DataType.Type.INET,
 487            exp.DataType.Type.INT128,
 488            exp.DataType.Type.INT256,
 489            exp.DataType.Type.INT4MULTIRANGE,
 490            exp.DataType.Type.INT4RANGE,
 491            exp.DataType.Type.INT8MULTIRANGE,
 492            exp.DataType.Type.INT8RANGE,
 493            exp.DataType.Type.INTERVAL,
 494            exp.DataType.Type.IPADDRESS,
 495            exp.DataType.Type.IPPREFIX,
 496            exp.DataType.Type.IPV4,
 497            exp.DataType.Type.IPV6,
 498            exp.DataType.Type.LIST,
 499            exp.DataType.Type.MAP,
 500            exp.DataType.Type.LOWCARDINALITY,
 501            exp.DataType.Type.MONEY,
 502            exp.DataType.Type.MULTILINESTRING,
 503            exp.DataType.Type.NAME,
 504            exp.DataType.Type.NESTED,
 505            exp.DataType.Type.NOTHING,
 506            exp.DataType.Type.NULL,
 507            exp.DataType.Type.NUMMULTIRANGE,
 508            exp.DataType.Type.NUMRANGE,
 509            exp.DataType.Type.OBJECT,
 510            exp.DataType.Type.RANGE,
 511            exp.DataType.Type.ROWVERSION,
 512            exp.DataType.Type.SERIAL,
 513            exp.DataType.Type.SMALLSERIAL,
 514            exp.DataType.Type.SMALLMONEY,
 515            exp.DataType.Type.STRUCT,
 516            exp.DataType.Type.SUPER,
 517            exp.DataType.Type.TIMETZ,
 518            exp.DataType.Type.TIMESTAMPNTZ,
 519            exp.DataType.Type.TIMESTAMPLTZ,
 520            exp.DataType.Type.TIMESTAMPTZ,
 521            exp.DataType.Type.TIMESTAMP_NS,
 522            exp.DataType.Type.TSMULTIRANGE,
 523            exp.DataType.Type.TSRANGE,
 524            exp.DataType.Type.TSTZMULTIRANGE,
 525            exp.DataType.Type.TSTZRANGE,
 526            exp.DataType.Type.UINT128,
 527            exp.DataType.Type.UINT256,
 528            exp.DataType.Type.UNION,
 529            exp.DataType.Type.UNKNOWN,
 530            exp.DataType.Type.USERDEFINED,
 531            exp.DataType.Type.UUID,
 532            exp.DataType.Type.VARIANT,
 533            exp.DataType.Type.XML,
 534            exp.DataType.Type.TDIGEST,
 535        }
 536
 537        TYPE_MAPPING = {
 538            **MySQL.Generator.TYPE_MAPPING,
 539            exp.DataType.Type.BIGDECIMAL: "DECIMAL",
 540            exp.DataType.Type.BIT: "BOOLEAN",
 541            exp.DataType.Type.DATE32: "DATE",
 542            exp.DataType.Type.DATETIME64: "DATETIME",
 543            exp.DataType.Type.DECIMAL32: "DECIMAL",
 544            exp.DataType.Type.DECIMAL64: "DECIMAL",
 545            exp.DataType.Type.DECIMAL128: "DECIMAL",
 546            exp.DataType.Type.DECIMAL256: "DECIMAL",
 547            exp.DataType.Type.ENUM8: "ENUM",
 548            exp.DataType.Type.ENUM16: "ENUM",
 549            exp.DataType.Type.FIXEDSTRING: "TEXT",
 550            exp.DataType.Type.GEOMETRY: "GEOGRAPHY",
 551            exp.DataType.Type.POINT: "GEOGRAPHYPOINT",
 552            exp.DataType.Type.RING: "GEOGRAPHY",
 553            exp.DataType.Type.LINESTRING: "GEOGRAPHY",
 554            exp.DataType.Type.POLYGON: "GEOGRAPHY",
 555            exp.DataType.Type.MULTIPOLYGON: "GEOGRAPHY",
 556            exp.DataType.Type.JSONB: "BSON",
 557            exp.DataType.Type.TIMESTAMP: "TIMESTAMP",
 558            exp.DataType.Type.TIMESTAMP_S: "TIMESTAMP",
 559            exp.DataType.Type.TIMESTAMP_MS: "TIMESTAMP(6)",
 560        }
 561
 562        # https://docs.singlestore.com/cloud/reference/sql-reference/restricted-keywords/list-of-restricted-keywords/
 563        RESERVED_KEYWORDS = {
 564            "abs",
 565            "absolute",
 566            "access",
 567            "account",
 568            "acos",
 569            "action",
 570            "add",
 571            "adddate",
 572            "addtime",
 573            "admin",
 574            "aes_decrypt",
 575            "aes_encrypt",
 576            "after",
 577            "against",
 578            "aggregate",
 579            "aggregates",
 580            "aggregator",
 581            "aggregator_id",
 582            "aggregator_plan_hash",
 583            "aggregators",
 584            "algorithm",
 585            "all",
 586            "also",
 587            "alter",
 588            "always",
 589            "analyse",
 590            "analyze",
 591            "and",
 592            "anti_join",
 593            "any",
 594            "any_value",
 595            "approx_count_distinct",
 596            "approx_count_distinct_accumulate",
 597            "approx_count_distinct_combine",
 598            "approx_count_distinct_estimate",
 599            "approx_geography_intersects",
 600            "approx_percentile",
 601            "arghistory",
 602            "arrange",
 603            "arrangement",
 604            "array",
 605            "as",
 606            "asc",
 607            "ascii",
 608            "asensitive",
 609            "asin",
 610            "asm",
 611            "assertion",
 612            "assignment",
 613            "ast",
 614            "asymmetric",
 615            "async",
 616            "at",
 617            "atan",
 618            "atan2",
 619            "attach",
 620            "attribute",
 621            "authorization",
 622            "auto",
 623            "auto_increment",
 624            "auto_reprovision",
 625            "autostats",
 626            "autostats_cardinality_mode",
 627            "autostats_enabled",
 628            "autostats_histogram_mode",
 629            "autostats_sampling",
 630            "availability",
 631            "avg",
 632            "avg_row_length",
 633            "avro",
 634            "azure",
 635            "background",
 636            "_background_threads_for_cleanup",
 637            "backup",
 638            "backup_history",
 639            "backup_id",
 640            "backward",
 641            "batch",
 642            "batches",
 643            "batch_interval",
 644            "_batch_size_limit",
 645            "before",
 646            "begin",
 647            "between",
 648            "bigint",
 649            "bin",
 650            "binary",
 651            "_binary",
 652            "bit",
 653            "bit_and",
 654            "bit_count",
 655            "bit_or",
 656            "bit_xor",
 657            "blob",
 658            "bool",
 659            "boolean",
 660            "bootstrap",
 661            "both",
 662            "_bt",
 663            "btree",
 664            "bucket_count",
 665            "by",
 666            "byte",
 667            "byte_length",
 668            "cache",
 669            "call",
 670            "call_for_pipeline",
 671            "called",
 672            "capture",
 673            "cascade",
 674            "cascaded",
 675            "case",
 676            "cast",
 677            "catalog",
 678            "ceil",
 679            "ceiling",
 680            "chain",
 681            "change",
 682            "char",
 683            "character",
 684            "characteristics",
 685            "character_length",
 686            "char_length",
 687            "charset",
 688            "check",
 689            "checkpoint",
 690            "_check_can_connect",
 691            "_check_consistency",
 692            "checksum",
 693            "_checksum",
 694            "class",
 695            "clear",
 696            "client",
 697            "client_found_rows",
 698            "close",
 699            "cluster",
 700            "clustered",
 701            "cnf",
 702            "coalesce",
 703            "coercibility",
 704            "collate",
 705            "collation",
 706            "collect",
 707            "column",
 708            "columnar",
 709            "columns",
 710            "columnstore",
 711            "columnstore_segment_rows",
 712            "comment",
 713            "comments",
 714            "commit",
 715            "committed",
 716            "_commit_log_tail",
 717            "committed",
 718            "compact",
 719            "compile",
 720            "compressed",
 721            "compression",
 722            "concat",
 723            "concat_ws",
 724            "concurrent",
 725            "concurrently",
 726            "condition",
 727            "configuration",
 728            "connection",
 729            "connection_id",
 730            "connections",
 731            "config",
 732            "constraint",
 733            "constraints",
 734            "content",
 735            "continue",
 736            "_continue_replay",
 737            "conv",
 738            "conversion",
 739            "convert",
 740            "convert_tz",
 741            "copy",
 742            "_core",
 743            "cos",
 744            "cost",
 745            "cot",
 746            "count",
 747            "create",
 748            "credentials",
 749            "cross",
 750            "cube",
 751            "csv",
 752            "cume_dist",
 753            "curdate",
 754            "current",
 755            "current_catalog",
 756            "current_date",
 757            "current_role",
 758            "current_schema",
 759            "current_security_groups",
 760            "current_security_roles",
 761            "current_time",
 762            "current_timestamp",
 763            "current_user",
 764            "cursor",
 765            "curtime",
 766            "cycle",
 767            "data",
 768            "database",
 769            "databases",
 770            "date",
 771            "date_add",
 772            "datediff",
 773            "date_format",
 774            "date_sub",
 775            "date_trunc",
 776            "datetime",
 777            "day",
 778            "day_hour",
 779            "day_microsecond",
 780            "day_minute",
 781            "dayname",
 782            "dayofmonth",
 783            "dayofweek",
 784            "dayofyear",
 785            "day_second",
 786            "deallocate",
 787            "dec",
 788            "decimal",
 789            "declare",
 790            "decode",
 791            "default",
 792            "defaults",
 793            "deferrable",
 794            "deferred",
 795            "defined",
 796            "definer",
 797            "degrees",
 798            "delayed",
 799            "delay_key_write",
 800            "delete",
 801            "delimiter",
 802            "delimiters",
 803            "dense_rank",
 804            "desc",
 805            "describe",
 806            "detach",
 807            "deterministic",
 808            "dictionary",
 809            "differential",
 810            "directory",
 811            "disable",
 812            "discard",
 813            "_disconnect",
 814            "disk",
 815            "distinct",
 816            "distinctrow",
 817            "distributed_joins",
 818            "div",
 819            "do",
 820            "document",
 821            "domain",
 822            "dot_product",
 823            "double",
 824            "drop",
 825            "_drop_profile",
 826            "dual",
 827            "dump",
 828            "duplicate",
 829            "dynamic",
 830            "earliest",
 831            "each",
 832            "echo",
 833            "election",
 834            "else",
 835            "elseif",
 836            "elt",
 837            "enable",
 838            "enclosed",
 839            "encoding",
 840            "encrypted",
 841            "end",
 842            "engine",
 843            "engines",
 844            "enum",
 845            "errors",
 846            "escape",
 847            "escaped",
 848            "estimate",
 849            "euclidean_distance",
 850            "event",
 851            "events",
 852            "except",
 853            "exclude",
 854            "excluding",
 855            "exclusive",
 856            "execute",
 857            "exists",
 858            "exit",
 859            "exp",
 860            "explain",
 861            "extended",
 862            "extension",
 863            "external",
 864            "external_host",
 865            "external_port",
 866            "extract",
 867            "extractor",
 868            "extractors",
 869            "extra_join",
 870            "_failover",
 871            "failed_login_attempts",
 872            "failure",
 873            "false",
 874            "family",
 875            "fault",
 876            "fetch",
 877            "field",
 878            "fields",
 879            "file",
 880            "files",
 881            "fill",
 882            "first",
 883            "first_value",
 884            "fix_alter",
 885            "fixed",
 886            "float",
 887            "float4",
 888            "float8",
 889            "floor",
 890            "flush",
 891            "following",
 892            "for",
 893            "force",
 894            "force_compiled_mode",
 895            "force_interpreter_mode",
 896            "foreground",
 897            "foreign",
 898            "format",
 899            "forward",
 900            "found_rows",
 901            "freeze",
 902            "from",
 903            "from_base64",
 904            "from_days",
 905            "from_unixtime",
 906            "fs",
 907            "_fsync",
 908            "full",
 909            "fulltext",
 910            "function",
 911            "functions",
 912            "gc",
 913            "gcs",
 914            "get_format",
 915            "_gc",
 916            "_gcx",
 917            "generate",
 918            "geography",
 919            "geography_area",
 920            "geography_contains",
 921            "geography_distance",
 922            "geography_intersects",
 923            "geography_latitude",
 924            "geography_length",
 925            "geography_longitude",
 926            "geographypoint",
 927            "geography_point",
 928            "geography_within_distance",
 929            "geometry",
 930            "geometry_area",
 931            "geometry_contains",
 932            "geometry_distance",
 933            "geometry_filter",
 934            "geometry_intersects",
 935            "geometry_length",
 936            "geometrypoint",
 937            "geometry_point",
 938            "geometry_within_distance",
 939            "geometry_x",
 940            "geometry_y",
 941            "global",
 942            "_global_version_timestamp",
 943            "grant",
 944            "granted",
 945            "grants",
 946            "greatest",
 947            "group",
 948            "grouping",
 949            "groups",
 950            "group_concat",
 951            "gzip",
 952            "handle",
 953            "handler",
 954            "hard_cpu_limit_percentage",
 955            "hash",
 956            "has_temp_tables",
 957            "having",
 958            "hdfs",
 959            "header",
 960            "heartbeat_no_logging",
 961            "hex",
 962            "highlight",
 963            "high_priority",
 964            "hold",
 965            "holding",
 966            "host",
 967            "hosts",
 968            "hour",
 969            "hour_microsecond",
 970            "hour_minute",
 971            "hour_second",
 972            "identified",
 973            "identity",
 974            "if",
 975            "ifnull",
 976            "ignore",
 977            "ilike",
 978            "immediate",
 979            "immutable",
 980            "implicit",
 981            "import",
 982            "in",
 983            "including",
 984            "increment",
 985            "incremental",
 986            "index",
 987            "indexes",
 988            "inet_aton",
 989            "inet_ntoa",
 990            "inet6_aton",
 991            "inet6_ntoa",
 992            "infile",
 993            "inherit",
 994            "inherits",
 995            "_init_profile",
 996            "init",
 997            "initcap",
 998            "initialize",
 999            "initially",
1000            "inject",
1001            "inline",
1002            "inner",
1003            "inout",
1004            "input",
1005            "insensitive",
1006            "insert",
1007            "insert_method",
1008            "instance",
1009            "instead",
1010            "instr",
1011            "int",
1012            "int1",
1013            "int2",
1014            "int3",
1015            "int4",
1016            "int8",
1017            "integer",
1018            "_internal_dynamic_typecast",
1019            "interpreter_mode",
1020            "intersect",
1021            "interval",
1022            "into",
1023            "invoker",
1024            "is",
1025            "isnull",
1026            "isolation",
1027            "iterate",
1028            "join",
1029            "json",
1030            "json_agg",
1031            "json_array_contains_double",
1032            "json_array_contains_json",
1033            "json_array_contains_string",
1034            "json_array_push_double",
1035            "json_array_push_json",
1036            "json_array_push_string",
1037            "json_delete_key",
1038            "json_extract_double",
1039            "json_extract_json",
1040            "json_extract_string",
1041            "json_extract_bigint",
1042            "json_get_type",
1043            "json_length",
1044            "json_set_double",
1045            "json_set_json",
1046            "json_set_string",
1047            "json_splice_double",
1048            "json_splice_json",
1049            "json_splice_string",
1050            "kafka",
1051            "key",
1052            "key_block_size",
1053            "keys",
1054            "kill",
1055            "killall",
1056            "label",
1057            "lag",
1058            "language",
1059            "large",
1060            "last",
1061            "last_day",
1062            "last_insert_id",
1063            "last_value",
1064            "lateral",
1065            "latest",
1066            "lc_collate",
1067            "lc_ctype",
1068            "lcase",
1069            "lead",
1070            "leading",
1071            "leaf",
1072            "leakproof",
1073            "least",
1074            "leave",
1075            "leaves",
1076            "left",
1077            "length",
1078            "level",
1079            "license",
1080            "like",
1081            "limit",
1082            "lines",
1083            "listen",
1084            "llvm",
1085            "ln",
1086            "load",
1087            "loaddata_where",
1088            "_load",
1089            "local",
1090            "localtime",
1091            "localtimestamp",
1092            "locate",
1093            "location",
1094            "lock",
1095            "log",
1096            "log10",
1097            "log2",
1098            "long",
1099            "longblob",
1100            "longtext",
1101            "loop",
1102            "lower",
1103            "low_priority",
1104            "lpad",
1105            "_ls",
1106            "ltrim",
1107            "lz4",
1108            "management",
1109            "_management_thread",
1110            "mapping",
1111            "master",
1112            "match",
1113            "materialized",
1114            "max",
1115            "maxvalue",
1116            "max_concurrency",
1117            "max_errors",
1118            "max_partitions_per_batch",
1119            "max_queue_depth",
1120            "max_retries_per_batch_partition",
1121            "max_rows",
1122            "mbc",
1123            "md5",
1124            "mpl",
1125            "median",
1126            "mediumblob",
1127            "mediumint",
1128            "mediumtext",
1129            "member",
1130            "memory",
1131            "memory_percentage",
1132            "_memsql_table_id_lookup",
1133            "memsql",
1134            "memsql_deserialize",
1135            "memsql_imitating_kafka",
1136            "memsql_serialize",
1137            "merge",
1138            "metadata",
1139            "microsecond",
1140            "middleint",
1141            "min",
1142            "min_rows",
1143            "minus",
1144            "minute",
1145            "minute_microsecond",
1146            "minute_second",
1147            "minvalue",
1148            "mod",
1149            "mode",
1150            "model",
1151            "modifies",
1152            "modify",
1153            "month",
1154            "monthname",
1155            "months_between",
1156            "move",
1157            "mpl",
1158            "names",
1159            "named",
1160            "namespace",
1161            "national",
1162            "natural",
1163            "nchar",
1164            "next",
1165            "no",
1166            "node",
1167            "none",
1168            "no_query_rewrite",
1169            "noparam",
1170            "not",
1171            "nothing",
1172            "notify",
1173            "now",
1174            "nowait",
1175            "no_write_to_binlog",
1176            "no_query_rewrite",
1177            "norely",
1178            "nth_value",
1179            "ntile",
1180            "null",
1181            "nullcols",
1182            "nullif",
1183            "nulls",
1184            "numeric",
1185            "nvarchar",
1186            "object",
1187            "octet_length",
1188            "of",
1189            "off",
1190            "offline",
1191            "offset",
1192            "offsets",
1193            "oids",
1194            "on",
1195            "online",
1196            "only",
1197            "open",
1198            "operator",
1199            "optimization",
1200            "optimize",
1201            "optimizer",
1202            "optimizer_state",
1203            "option",
1204            "options",
1205            "optionally",
1206            "or",
1207            "order",
1208            "ordered_serialize",
1209            "orphan",
1210            "out",
1211            "out_of_order",
1212            "outer",
1213            "outfile",
1214            "over",
1215            "overlaps",
1216            "overlay",
1217            "owned",
1218            "owner",
1219            "pack_keys",
1220            "paired",
1221            "parser",
1222            "parquet",
1223            "partial",
1224            "partition",
1225            "partition_id",
1226            "partitioning",
1227            "partitions",
1228            "passing",
1229            "password",
1230            "password_lock_time",
1231            "parser",
1232            "pause",
1233            "_pause_replay",
1234            "percent_rank",
1235            "percentile_cont",
1236            "percentile_disc",
1237            "periodic",
1238            "persisted",
1239            "pi",
1240            "pipeline",
1241            "pipelines",
1242            "pivot",
1243            "placing",
1244            "plan",
1245            "plans",
1246            "plancache",
1247            "plugins",
1248            "pool",
1249            "pools",
1250            "port",
1251            "position",
1252            "pow",
1253            "power",
1254            "preceding",
1255            "precision",
1256            "prepare",
1257            "prepared",
1258            "preserve",
1259            "primary",
1260            "prior",
1261            "privileges",
1262            "procedural",
1263            "procedure",
1264            "procedures",
1265            "process",
1266            "processlist",
1267            "profile",
1268            "profiles",
1269            "program",
1270            "promote",
1271            "proxy",
1272            "purge",
1273            "quarter",
1274            "queries",
1275            "query",
1276            "query_timeout",
1277            "queue",
1278            "quote",
1279            "radians",
1280            "rand",
1281            "range",
1282            "rank",
1283            "read",
1284            "_read",
1285            "reads",
1286            "real",
1287            "reassign",
1288            "rebalance",
1289            "recheck",
1290            "record",
1291            "recursive",
1292            "redundancy",
1293            "redundant",
1294            "ref",
1295            "reference",
1296            "references",
1297            "refresh",
1298            "regexp",
1299            "reindex",
1300            "relative",
1301            "release",
1302            "reload",
1303            "rely",
1304            "remote",
1305            "remove",
1306            "rename",
1307            "repair",
1308            "_repair_table",
1309            "repeat",
1310            "repeatable",
1311            "_repl",
1312            "_reprovisioning",
1313            "replace",
1314            "replica",
1315            "replicate",
1316            "replicating",
1317            "replication",
1318            "durability",
1319            "require",
1320            "resource",
1321            "resource_pool",
1322            "reset",
1323            "restart",
1324            "restore",
1325            "restrict",
1326            "result",
1327            "_resurrect",
1328            "retry",
1329            "return",
1330            "returning",
1331            "returns",
1332            "reverse",
1333            "revoke",
1334            "rg_pool",
1335            "right",
1336            "right_anti_join",
1337            "right_semi_join",
1338            "right_straight_join",
1339            "rlike",
1340            "role",
1341            "roles",
1342            "rollback",
1343            "rollup",
1344            "round",
1345            "routine",
1346            "row",
1347            "row_count",
1348            "row_format",
1349            "row_number",
1350            "rows",
1351            "rowstore",
1352            "rule",
1353            "rpad",
1354            "_rpc",
1355            "rtrim",
1356            "running",
1357            "s3",
1358            "safe",
1359            "save",
1360            "savepoint",
1361            "scalar",
1362            "schema",
1363            "schemas",
1364            "schema_binding",
1365            "scroll",
1366            "search",
1367            "second",
1368            "second_microsecond",
1369            "sec_to_time",
1370            "security",
1371            "select",
1372            "semi_join",
1373            "_send_threads",
1374            "sensitive",
1375            "separator",
1376            "sequence",
1377            "sequences",
1378            "serial",
1379            "serializable",
1380            "series",
1381            "service_user",
1382            "server",
1383            "session",
1384            "session_user",
1385            "set",
1386            "setof",
1387            "security_lists_intersect",
1388            "sha",
1389            "sha1",
1390            "sha2",
1391            "shard",
1392            "sharded",
1393            "sharded_id",
1394            "share",
1395            "show",
1396            "shutdown",
1397            "sigmoid",
1398            "sign",
1399            "signal",
1400            "similar",
1401            "simple",
1402            "site",
1403            "signed",
1404            "sin",
1405            "skip",
1406            "skipped_batches",
1407            "sleep",
1408            "_sleep",
1409            "smallint",
1410            "snapshot",
1411            "_snapshot",
1412            "_snapshots",
1413            "soft_cpu_limit_percentage",
1414            "some",
1415            "soname",
1416            "sparse",
1417            "spatial",
1418            "spatial_check_index",
1419            "specific",
1420            "split",
1421            "sql",
1422            "sql_big_result",
1423            "sql_buffer_result",
1424            "sql_cache",
1425            "sql_calc_found_rows",
1426            "sqlexception",
1427            "sql_mode",
1428            "sql_no_cache",
1429            "sql_no_logging",
1430            "sql_small_result",
1431            "sqlstate",
1432            "sqlwarning",
1433            "sqrt",
1434            "ssl",
1435            "stable",
1436            "standalone",
1437            "start",
1438            "starting",
1439            "state",
1440            "statement",
1441            "statistics",
1442            "stats",
1443            "status",
1444            "std",
1445            "stddev",
1446            "stddev_pop",
1447            "stddev_samp",
1448            "stdin",
1449            "stdout",
1450            "stop",
1451            "storage",
1452            "str_to_date",
1453            "straight_join",
1454            "strict",
1455            "string",
1456            "strip",
1457            "subdate",
1458            "substr",
1459            "substring",
1460            "substring_index",
1461            "success",
1462            "sum",
1463            "super",
1464            "symmetric",
1465            "sync_snapshot",
1466            "sync",
1467            "_sync",
1468            "_sync2",
1469            "_sync_partitions",
1470            "_sync_snapshot",
1471            "synchronize",
1472            "sysid",
1473            "system",
1474            "table",
1475            "table_checksum",
1476            "tables",
1477            "tablespace",
1478            "tags",
1479            "tan",
1480            "target_size",
1481            "task",
1482            "temp",
1483            "template",
1484            "temporary",
1485            "temptable",
1486            "_term_bump",
1487            "terminate",
1488            "terminated",
1489            "test",
1490            "text",
1491            "then",
1492            "time",
1493            "timediff",
1494            "time_bucket",
1495            "time_format",
1496            "timeout",
1497            "timestamp",
1498            "timestampadd",
1499            "timestampdiff",
1500            "timezone",
1501            "time_to_sec",
1502            "tinyblob",
1503            "tinyint",
1504            "tinytext",
1505            "to",
1506            "to_base64",
1507            "to_char",
1508            "to_date",
1509            "to_days",
1510            "to_json",
1511            "to_number",
1512            "to_seconds",
1513            "to_timestamp",
1514            "tracelogs",
1515            "traditional",
1516            "trailing",
1517            "transform",
1518            "transaction",
1519            "_transactions_experimental",
1520            "treat",
1521            "trigger",
1522            "triggers",
1523            "trim",
1524            "true",
1525            "trunc",
1526            "truncate",
1527            "trusted",
1528            "two_phase",
1529            "_twopcid",
1530            "type",
1531            "types",
1532            "ucase",
1533            "unbounded",
1534            "uncommitted",
1535            "undefined",
1536            "undo",
1537            "unencrypted",
1538            "unenforced",
1539            "unhex",
1540            "unhold",
1541            "unicode",
1542            "union",
1543            "unique",
1544            "_unittest",
1545            "unix_timestamp",
1546            "unknown",
1547            "unlisten",
1548            "_unload",
1549            "unlock",
1550            "unlogged",
1551            "unpivot",
1552            "unsigned",
1553            "until",
1554            "update",
1555            "upgrade",
1556            "upper",
1557            "usage",
1558            "use",
1559            "user",
1560            "users",
1561            "using",
1562            "utc_date",
1563            "utc_time",
1564            "utc_timestamp",
1565            "_utf8",
1566            "vacuum",
1567            "valid",
1568            "validate",
1569            "validator",
1570            "value",
1571            "values",
1572            "varbinary",
1573            "varchar",
1574            "varcharacter",
1575            "variables",
1576            "variadic",
1577            "variance",
1578            "var_pop",
1579            "var_samp",
1580            "varying",
1581            "vector_sub",
1582            "verbose",
1583            "version",
1584            "view",
1585            "void",
1586            "volatile",
1587            "voting",
1588            "wait",
1589            "_wake",
1590            "warnings",
1591            "week",
1592            "weekday",
1593            "weekofyear",
1594            "when",
1595            "where",
1596            "while",
1597            "whitespace",
1598            "window",
1599            "with",
1600            "without",
1601            "within",
1602            "_wm_heartbeat",
1603            "work",
1604            "workload",
1605            "wrapper",
1606            "write",
1607            "xact_id",
1608            "xor",
1609            "year",
1610            "year_month",
1611            "yes",
1612            "zerofill",
1613            "zone",
1614        }
1615
1616        def jsonextractscalar_sql(self, expression: exp.JSONExtractScalar) -> str:
1617            json_type = expression.args.get("json_type")
1618            func_name = "JSON_EXTRACT_JSON" if json_type is None else f"JSON_EXTRACT_{json_type}"
1619            return json_extract_segments(func_name)(self, expression)
1620
1621        def jsonbextractscalar_sql(self, expression: exp.JSONBExtractScalar) -> str:
1622            json_type = expression.args.get("json_type")
1623            func_name = "BSON_EXTRACT_BSON" if json_type is None else f"BSON_EXTRACT_{json_type}"
1624            return json_extract_segments(func_name)(self, expression)
1625
1626        def jsonextractarray_sql(self, expression: exp.JSONExtractArray) -> str:
1627            self.unsupported("Arrays are not supported in SingleStore")
1628            return self.function_fallback_sql(expression)
1629
1630        @unsupported_args("on_condition")
1631        def jsonvalue_sql(self, expression: exp.JSONValue) -> str:
1632            res: exp.Expression = exp.JSONExtractScalar(
1633                this=expression.this,
1634                expression=expression.args.get("path"),
1635                json_type="STRING",
1636            )
1637
1638            returning = expression.args.get("returning")
1639            if returning is not None:
1640                res = exp.Cast(this=res, to=returning)
1641
1642            return self.sql(res)
1643
1644        def all_sql(self, expression: exp.All) -> str:
1645            self.unsupported("ALL subquery predicate is not supported in SingleStore")
1646            return super().all_sql(expression)
1647
1648        def jsonarraycontains_sql(self, expression: exp.JSONArrayContains) -> str:
1649            json_type = expression.text("json_type").upper()
1650
1651            if json_type:
1652                return self.func(
1653                    f"JSON_ARRAY_CONTAINS_{json_type}", expression.expression, expression.this
1654                )
1655
1656            return self.func(
1657                "JSON_ARRAY_CONTAINS_JSON",
1658                expression.expression,
1659                self.func("TO_JSON", expression.this),
1660            )
1661
1662        @unsupported_args("kind", "nested", "values")
1663        def datatype_sql(self, expression: exp.DataType) -> str:
1664            if expression.is_type(exp.DataType.Type.VARBINARY) and not expression.expressions:
1665                # `VARBINARY` must always have a size - if it doesn't, we always generate `BLOB`
1666                return "BLOB"
1667            if expression.is_type(
1668                exp.DataType.Type.DECIMAL32,
1669                exp.DataType.Type.DECIMAL64,
1670                exp.DataType.Type.DECIMAL128,
1671                exp.DataType.Type.DECIMAL256,
1672            ):
1673                scale = self.expressions(expression, flat=True)
1674
1675                if expression.is_type(exp.DataType.Type.DECIMAL32):
1676                    precision = "9"
1677                elif expression.is_type(exp.DataType.Type.DECIMAL64):
1678                    precision = "18"
1679                elif expression.is_type(exp.DataType.Type.DECIMAL128):
1680                    precision = "38"
1681                else:
1682                    # 65 is a maximum precision supported in SingleStore
1683                    precision = "65"
1684                if scale is not None:
1685                    return f"DECIMAL({precision}, {scale[0]})"
1686                else:
1687                    return f"DECIMAL({precision})"
1688
1689            return super().datatype_sql(expression)
1690
1691        def collate_sql(self, expression: exp.Collate) -> str:
1692            # SingleStore does not support setting a collation for column in the SELECT query,
1693            # so we cast column to a LONGTEXT type with specific collation
1694            return self.binary(expression, ":> LONGTEXT COLLATE")
1695
1696        def currentdate_sql(self, expression: exp.CurrentDate) -> str:
1697            timezone = expression.this
1698            if timezone:
1699                if isinstance(timezone, exp.Literal) and timezone.name.lower() == "utc":
1700                    return self.func("UTC_DATE")
1701                self.unsupported("CurrentDate with timezone is not supported in SingleStore")
1702
1703            return self.func("CURRENT_DATE")
1704
1705        def currenttime_sql(self, expression: exp.CurrentTime) -> str:
1706            arg = expression.this
1707            if arg:
1708                if isinstance(arg, exp.Literal) and arg.name.lower() == "utc":
1709                    return self.func("UTC_TIME")
1710                if isinstance(arg, exp.Literal) and arg.is_number:
1711                    return self.func("CURRENT_TIME", arg)
1712                self.unsupported("CurrentTime with timezone is not supported in SingleStore")
1713
1714            return self.func("CURRENT_TIME")
1715
1716        def currenttimestamp_sql(self, expression: exp.CurrentTimestamp) -> str:
1717            arg = expression.this
1718            if arg:
1719                if isinstance(arg, exp.Literal) and arg.name.lower() == "utc":
1720                    return self.func("UTC_TIMESTAMP")
1721                if isinstance(arg, exp.Literal) and arg.is_number:
1722                    return self.func("CURRENT_TIMESTAMP", arg)
1723                self.unsupported("CurrentTimestamp with timezone is not supported in SingleStore")
1724
1725            return self.func("CURRENT_TIMESTAMP")
1726
1727        def standardhash_sql(self, expression: exp.StandardHash) -> str:
1728            hash_function = expression.expression
1729            if hash_function is None:
1730                return self.func("SHA", expression.this)
1731            if isinstance(hash_function, exp.Literal):
1732                if hash_function.name.lower() == "sha":
1733                    return self.func("SHA", expression.this)
1734                if hash_function.name.lower() == "md5":
1735                    return self.func("MD5", expression.this)
1736
1737                self.unsupported(
1738                    f"{hash_function.this} hash method is not supported in SingleStore"
1739                )
1740                return self.func("SHA", expression.this)
1741
1742            self.unsupported("STANDARD_HASH function is not supported in SingleStore")
1743            return self.func("SHA", expression.this)
def cast_to_time6( expression: Optional[sqlglot.expressions.Expression], time_type: sqlglot.expressions.DataType.Type = <Type.TIME: 'TIME'>) -> sqlglot.expressions.Cast:
26def cast_to_time6(
27    expression: t.Optional[exp.Expression], time_type: DataType.Type = exp.DataType.Type.TIME
28) -> exp.Cast:
29    return exp.Cast(
30        this=expression,
31        to=exp.DataType.build(
32            time_type,
33            expressions=[exp.DataTypeParam(this=exp.Literal.number(6))],
34        ),
35    )
class SingleStore(sqlglot.dialects.mysql.MySQL):
  38class SingleStore(MySQL):
  39    SUPPORTS_ORDER_BY_ALL = True
  40
  41    TIME_MAPPING: t.Dict[str, str] = {
  42        "D": "%u",  # Day of week (1-7)
  43        "DD": "%d",  # day of month (01-31)
  44        "DY": "%a",  # abbreviated name of day
  45        "HH": "%I",  # Hour of day (01-12)
  46        "HH12": "%I",  # alias for HH
  47        "HH24": "%H",  # Hour of day (00-23)
  48        "MI": "%M",  # Minute (00-59)
  49        "MM": "%m",  # Month (01-12; January = 01)
  50        "MON": "%b",  # Abbreviated name of month
  51        "MONTH": "%B",  # Name of month
  52        "SS": "%S",  # Second (00-59)
  53        "RR": "%y",  # 15
  54        "YY": "%y",  # 15
  55        "YYYY": "%Y",  # 2015
  56        "FF6": "%f",  # only 6 digits are supported in python formats
  57    }
  58
  59    class Tokenizer(MySQL.Tokenizer):
  60        BYTE_STRINGS = [("e'", "'"), ("E'", "'")]
  61
  62        KEYWORDS = {
  63            **MySQL.Tokenizer.KEYWORDS,
  64            "BSON": TokenType.JSONB,
  65            "GEOGRAPHYPOINT": TokenType.GEOGRAPHYPOINT,
  66            "TIMESTAMP": TokenType.TIMESTAMP,
  67            "UTC_DATE": TokenType.UTC_DATE,
  68            "UTC_TIME": TokenType.UTC_TIME,
  69            "UTC_TIMESTAMP": TokenType.UTC_TIMESTAMP,
  70            ":>": TokenType.COLON_GT,
  71            "!:>": TokenType.NCOLON_GT,
  72            "::$": TokenType.DCOLONDOLLAR,
  73            "::%": TokenType.DCOLONPERCENT,
  74        }
  75
  76    class Parser(MySQL.Parser):
  77        FUNCTIONS = {
  78            **MySQL.Parser.FUNCTIONS,
  79            "TO_DATE": build_formatted_time(exp.TsOrDsToDate, "singlestore"),
  80            "TO_TIMESTAMP": build_formatted_time(exp.StrToTime, "singlestore"),
  81            "TO_CHAR": build_formatted_time(exp.ToChar, "singlestore"),
  82            "STR_TO_DATE": build_formatted_time(exp.StrToDate, "mysql"),
  83            "DATE_FORMAT": build_formatted_time(exp.TimeToStr, "mysql"),
  84            # The first argument of following functions is converted to TIME(6)
  85            # This is needed because exp.TimeToStr is converted to DATE_FORMAT
  86            # which interprets the first argument as DATETIME and fails to parse
  87            # string literals like '12:05:47' without a date part.
  88            "TIME_FORMAT": lambda args: exp.TimeToStr(
  89                this=cast_to_time6(seq_get(args, 0)),
  90                format=MySQL.format_time(seq_get(args, 1)),
  91            ),
  92            "HOUR": lambda args: exp.cast(
  93                exp.TimeToStr(
  94                    this=cast_to_time6(seq_get(args, 0)),
  95                    format=MySQL.format_time(exp.Literal.string("%k")),
  96                ),
  97                DataType.Type.INT,
  98            ),
  99            "MICROSECOND": lambda args: exp.cast(
 100                exp.TimeToStr(
 101                    this=cast_to_time6(seq_get(args, 0)),
 102                    format=MySQL.format_time(exp.Literal.string("%f")),
 103                ),
 104                DataType.Type.INT,
 105            ),
 106            "SECOND": lambda args: exp.cast(
 107                exp.TimeToStr(
 108                    this=cast_to_time6(seq_get(args, 0)),
 109                    format=MySQL.format_time(exp.Literal.string("%s")),
 110                ),
 111                DataType.Type.INT,
 112            ),
 113            "MINUTE": lambda args: exp.cast(
 114                exp.TimeToStr(
 115                    this=cast_to_time6(seq_get(args, 0)),
 116                    format=MySQL.format_time(exp.Literal.string("%i")),
 117                ),
 118                DataType.Type.INT,
 119            ),
 120            "MONTHNAME": lambda args: exp.TimeToStr(
 121                this=seq_get(args, 0),
 122                format=MySQL.format_time(exp.Literal.string("%M")),
 123            ),
 124            "WEEKDAY": lambda args: exp.paren(exp.DayOfWeek(this=seq_get(args, 0)) + 5, copy=False)
 125            % 7,
 126            "UNIX_TIMESTAMP": exp.StrToUnix.from_arg_list,
 127            "FROM_UNIXTIME": build_formatted_time(exp.UnixToTime, "mysql"),
 128            "TIME_BUCKET": lambda args: exp.DateBin(
 129                this=seq_get(args, 0),
 130                expression=seq_get(args, 1),
 131                origin=seq_get(args, 2),
 132            ),
 133            "BSON_EXTRACT_BSON": build_json_extract_path(exp.JSONBExtract),
 134            "BSON_EXTRACT_STRING": build_json_extract_path(
 135                exp.JSONBExtractScalar, json_type="STRING"
 136            ),
 137            "BSON_EXTRACT_DOUBLE": build_json_extract_path(
 138                exp.JSONBExtractScalar, json_type="DOUBLE"
 139            ),
 140            "BSON_EXTRACT_BIGINT": build_json_extract_path(
 141                exp.JSONBExtractScalar, json_type="BIGINT"
 142            ),
 143            "JSON_EXTRACT_JSON": build_json_extract_path(exp.JSONExtract),
 144            "JSON_EXTRACT_STRING": build_json_extract_path(
 145                exp.JSONExtractScalar, json_type="STRING"
 146            ),
 147            "JSON_EXTRACT_DOUBLE": build_json_extract_path(
 148                exp.JSONExtractScalar, json_type="DOUBLE"
 149            ),
 150            "JSON_EXTRACT_BIGINT": build_json_extract_path(
 151                exp.JSONExtractScalar, json_type="BIGINT"
 152            ),
 153            "JSON_ARRAY_CONTAINS_STRING": lambda args: exp.JSONArrayContains(
 154                this=seq_get(args, 1),
 155                expression=seq_get(args, 0),
 156                json_type="STRING",
 157            ),
 158            "JSON_ARRAY_CONTAINS_DOUBLE": lambda args: exp.JSONArrayContains(
 159                this=seq_get(args, 1),
 160                expression=seq_get(args, 0),
 161                json_type="DOUBLE",
 162            ),
 163            "JSON_ARRAY_CONTAINS_JSON": lambda args: exp.JSONArrayContains(
 164                this=seq_get(args, 1),
 165                expression=seq_get(args, 0),
 166                json_type="JSON",
 167            ),
 168            "JSON_PRETTY": exp.JSONFormat.from_arg_list,
 169            "JSON_BUILD_ARRAY": lambda args: exp.JSONArray(expressions=args),
 170            "JSON_BUILD_OBJECT": lambda args: exp.JSONObject(expressions=args),
 171            "DATE": exp.Date.from_arg_list,
 172            "DAYNAME": lambda args: exp.TimeToStr(
 173                this=seq_get(args, 0),
 174                format=MySQL.format_time(exp.Literal.string("%W")),
 175            ),
 176            "TIMESTAMPDIFF": lambda args: exp.TimestampDiff(
 177                this=seq_get(args, 2),
 178                expression=seq_get(args, 1),
 179                unit=seq_get(args, 0),
 180            ),
 181            "APPROX_COUNT_DISTINCT": exp.Hll.from_arg_list,
 182            "APPROX_PERCENTILE": lambda args, dialect: exp.ApproxQuantile(
 183                this=seq_get(args, 0),
 184                quantile=seq_get(args, 1),
 185                error_tolerance=seq_get(args, 2),
 186            ),
 187            "VARIANCE": exp.VariancePop.from_arg_list,
 188            "INSTR": exp.Contains.from_arg_list,
 189            "REGEXP_MATCH": lambda args: exp.RegexpExtractAll(
 190                this=seq_get(args, 0),
 191                expression=seq_get(args, 1),
 192                parameters=seq_get(args, 2),
 193            ),
 194            "REGEXP_SUBSTR": lambda args: exp.RegexpExtract(
 195                this=seq_get(args, 0),
 196                expression=seq_get(args, 1),
 197                position=seq_get(args, 2),
 198                occurrence=seq_get(args, 3),
 199                parameters=seq_get(args, 4),
 200            ),
 201            "REDUCE": lambda args: exp.Reduce(
 202                initial=seq_get(args, 0),
 203                this=seq_get(args, 1),
 204                merge=seq_get(args, 2),
 205            ),
 206        }
 207
 208        FUNCTION_PARSERS: t.Dict[str, t.Callable] = {
 209            **MySQL.Parser.FUNCTION_PARSERS,
 210            "JSON_AGG": lambda self: exp.JSONArrayAgg(
 211                this=self._parse_term(),
 212                order=self._parse_order(),
 213            ),
 214        }
 215
 216        NO_PAREN_FUNCTIONS = {
 217            **MySQL.Parser.NO_PAREN_FUNCTIONS,
 218            TokenType.UTC_DATE: exp.UtcDate,
 219            TokenType.UTC_TIME: exp.UtcTime,
 220            TokenType.UTC_TIMESTAMP: exp.UtcTimestamp,
 221        }
 222
 223        CAST_COLUMN_OPERATORS = {TokenType.COLON_GT, TokenType.NCOLON_GT}
 224
 225        COLUMN_OPERATORS = {
 226            **MySQL.Parser.COLUMN_OPERATORS,
 227            TokenType.COLON_GT: lambda self, this, to: self.expression(
 228                exp.Cast,
 229                this=this,
 230                to=to,
 231            ),
 232            TokenType.NCOLON_GT: lambda self, this, to: self.expression(
 233                exp.TryCast,
 234                this=this,
 235                to=to,
 236            ),
 237            TokenType.DCOLON: lambda self, this, path: build_json_extract_path(exp.JSONExtract)(
 238                [this, exp.Literal.string(path.name)]
 239            ),
 240            TokenType.DCOLONDOLLAR: lambda self, this, path: build_json_extract_path(
 241                exp.JSONExtractScalar, json_type="STRING"
 242            )([this, exp.Literal.string(path.name)]),
 243            TokenType.DCOLONPERCENT: lambda self, this, path: build_json_extract_path(
 244                exp.JSONExtractScalar, json_type="DOUBLE"
 245            )([this, exp.Literal.string(path.name)]),
 246        }
 247        COLUMN_OPERATORS.pop(TokenType.ARROW)
 248        COLUMN_OPERATORS.pop(TokenType.DARROW)
 249        COLUMN_OPERATORS.pop(TokenType.HASH_ARROW)
 250        COLUMN_OPERATORS.pop(TokenType.DHASH_ARROW)
 251        COLUMN_OPERATORS.pop(TokenType.PLACEHOLDER)
 252
 253    class Generator(MySQL.Generator):
 254        SUPPORTS_UESCAPE = False
 255        NULL_ORDERING_SUPPORTED = True
 256        MATCH_AGAINST_TABLE_PREFIX = "TABLE "
 257
 258        @staticmethod
 259        def _unicode_substitute(m: re.Match[str]) -> str:
 260            # Interpret the number as hex and convert it to the Unicode string
 261            return chr(int(m.group(1), 16))
 262
 263        UNICODE_SUBSTITUTE: t.Optional[t.Callable[[re.Match[str]], str]] = _unicode_substitute
 264
 265        SUPPORTED_JSON_PATH_PARTS = {
 266            exp.JSONPathKey,
 267            exp.JSONPathRoot,
 268            exp.JSONPathSubscript,
 269        }
 270
 271        TRANSFORMS = {
 272            **MySQL.Generator.TRANSFORMS,
 273            exp.TsOrDsToDate: lambda self, e: self.func("TO_DATE", e.this, self.format_time(e))
 274            if e.args.get("format")
 275            else self.func("DATE", e.this),
 276            exp.StrToTime: lambda self, e: self.func("TO_TIMESTAMP", e.this, self.format_time(e)),
 277            exp.ToChar: lambda self, e: self.func("TO_CHAR", e.this, self.format_time(e)),
 278            exp.StrToDate: lambda self, e: self.func(
 279                "STR_TO_DATE",
 280                e.this,
 281                self.format_time(
 282                    e,
 283                    inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING,
 284                    inverse_time_trie=MySQL.INVERSE_TIME_TRIE,
 285                ),
 286            ),
 287            exp.TimeToStr: lambda self, e: self.func(
 288                "DATE_FORMAT",
 289                e.this,
 290                self.format_time(
 291                    e,
 292                    inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING,
 293                    inverse_time_trie=MySQL.INVERSE_TIME_TRIE,
 294                ),
 295            ),
 296            exp.Date: unsupported_args("zone", "expressions")(rename_func("DATE")),
 297            exp.Cast: unsupported_args("format", "action", "default")(
 298                lambda self, e: f"{self.sql(e, 'this')} :> {self.sql(e, 'to')}"
 299            ),
 300            exp.TryCast: unsupported_args("format", "action", "default")(
 301                lambda self, e: f"{self.sql(e, 'this')} !:> {self.sql(e, 'to')}"
 302            ),
 303            exp.CastToStrType: lambda self, e: self.sql(
 304                exp.cast(e.this, DataType.build(e.args["to"].name))
 305            ),
 306            exp.StrToUnix: unsupported_args("format")(rename_func("UNIX_TIMESTAMP")),
 307            exp.TimeToUnix: rename_func("UNIX_TIMESTAMP"),
 308            exp.TimeStrToUnix: rename_func("UNIX_TIMESTAMP"),
 309            exp.UnixSeconds: rename_func("UNIX_TIMESTAMP"),
 310            exp.UnixToStr: lambda self, e: self.func(
 311                "FROM_UNIXTIME",
 312                e.this,
 313                self.format_time(
 314                    e,
 315                    inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING,
 316                    inverse_time_trie=MySQL.INVERSE_TIME_TRIE,
 317                ),
 318            ),
 319            exp.UnixToTime: unsupported_args("scale", "zone", "hours", "minutes")(
 320                lambda self, e: self.func(
 321                    "FROM_UNIXTIME",
 322                    e.this,
 323                    self.format_time(
 324                        e,
 325                        inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING,
 326                        inverse_time_trie=MySQL.INVERSE_TIME_TRIE,
 327                    ),
 328                ),
 329            ),
 330            exp.UnixToTimeStr: lambda self, e: f"FROM_UNIXTIME({self.sql(e, 'this')}) :> TEXT",
 331            exp.DateBin: unsupported_args("unit", "zone")(
 332                lambda self, e: self.func("TIME_BUCKET", e.this, e.expression, e.args.get("origin"))
 333            ),
 334            exp.TimeStrToDate: lambda self, e: self.sql(exp.cast(e.this, exp.DataType.Type.DATE)),
 335            exp.FromTimeZone: lambda self, e: self.func(
 336                "CONVERT_TZ", e.this, e.args.get("zone"), "'UTC'"
 337            ),
 338            exp.DiToDate: lambda self,
 339            e: f"STR_TO_DATE({self.sql(e, 'this')}, {SingleStore.DATEINT_FORMAT})",
 340            exp.DateToDi: lambda self,
 341            e: f"(DATE_FORMAT({self.sql(e, 'this')}, {SingleStore.DATEINT_FORMAT}) :> INT)",
 342            exp.TsOrDiToDi: lambda self,
 343            e: f"(DATE_FORMAT({self.sql(e, 'this')}, {SingleStore.DATEINT_FORMAT}) :> INT)",
 344            exp.Time: unsupported_args("zone")(lambda self, e: f"{self.sql(e, 'this')} :> TIME"),
 345            exp.DatetimeAdd: _remove_ts_or_ds_to_date(date_add_sql("ADD")),
 346            exp.DatetimeTrunc: unsupported_args("zone")(timestamptrunc_sql()),
 347            exp.DatetimeSub: date_add_interval_sql("DATE", "SUB"),
 348            exp.DatetimeDiff: timestampdiff_sql,
 349            exp.DateTrunc: unsupported_args("zone")(timestamptrunc_sql()),
 350            exp.DateDiff: unsupported_args("zone")(
 351                lambda self, e: timestampdiff_sql(self, e)
 352                if e.unit is not None
 353                else self.func("DATEDIFF", e.this, e.expression)
 354            ),
 355            exp.TsOrDsDiff: lambda self, e: timestampdiff_sql(self, e)
 356            if e.unit is not None
 357            else self.func("DATEDIFF", e.this, e.expression),
 358            exp.TimestampTrunc: unsupported_args("zone")(timestamptrunc_sql()),
 359            exp.CurrentDatetime: lambda self, e: self.sql(
 360                cast_to_time6(
 361                    exp.CurrentTimestamp(this=exp.Literal.number(6)), exp.DataType.Type.DATETIME
 362                )
 363            ),
 364            exp.JSONExtract: unsupported_args(
 365                "only_json_types",
 366                "expressions",
 367                "variant_extract",
 368                "json_query",
 369                "option",
 370                "quote",
 371                "on_condition",
 372                "requires_json",
 373            )(json_extract_segments("JSON_EXTRACT_JSON")),
 374            exp.JSONBExtract: json_extract_segments("BSON_EXTRACT_BSON"),
 375            exp.JSONPathKey: json_path_key_only_name,
 376            exp.JSONPathSubscript: lambda self, e: self.json_path_part(e.this),
 377            exp.JSONPathRoot: lambda *_: "",
 378            exp.JSONFormat: unsupported_args("options", "is_json")(rename_func("JSON_PRETTY")),
 379            exp.JSONArrayAgg: unsupported_args("null_handling", "return_type", "strict")(
 380                lambda self, e: self.func("JSON_AGG", e.this, suffix=f"{self.sql(e, 'order')})")
 381            ),
 382            exp.JSONArray: unsupported_args("null_handling", "return_type", "strict")(
 383                rename_func("JSON_BUILD_ARRAY")
 384            ),
 385            exp.JSONBExists: lambda self, e: self.func(
 386                "BSON_MATCH_ANY_EXISTS", e.this, e.args.get("path")
 387            ),
 388            exp.JSONExists: unsupported_args("passing", "on_condition")(
 389                lambda self, e: self.func("JSON_MATCH_ANY_EXISTS", e.this, e.args.get("path"))
 390            ),
 391            exp.JSONObject: unsupported_args(
 392                "null_handling", "unique_keys", "return_type", "encoding"
 393            )(rename_func("JSON_BUILD_OBJECT")),
 394            exp.DayOfWeekIso: lambda self, e: f"(({self.func('DAYOFWEEK', e.this)} % 7) + 1)",
 395            exp.DayOfMonth: rename_func("DAY"),
 396            exp.Hll: rename_func("APPROX_COUNT_DISTINCT"),
 397            exp.ApproxDistinct: rename_func("APPROX_COUNT_DISTINCT"),
 398            exp.CountIf: count_if_to_sum,
 399            exp.LogicalOr: lambda self, e: f"MAX(ABS({self.sql(e, 'this')}))",
 400            exp.LogicalAnd: lambda self, e: f"MIN(ABS({self.sql(e, 'this')}))",
 401            exp.ApproxQuantile: unsupported_args("accuracy", "weight")(
 402                lambda self, e: self.func(
 403                    "APPROX_PERCENTILE",
 404                    e.this,
 405                    e.args.get("quantile"),
 406                    e.args.get("error_tolerance"),
 407                )
 408            ),
 409            exp.Variance: rename_func("VAR_SAMP"),
 410            exp.VariancePop: rename_func("VAR_POP"),
 411            exp.Xor: bool_xor_sql,
 412            exp.Cbrt: lambda self, e: self.sql(
 413                exp.Pow(this=e.this, expression=exp.Literal.number(1) / exp.Literal.number(3))
 414            ),
 415            exp.RegexpLike: lambda self, e: self.binary(e, "RLIKE"),
 416            exp.Repeat: lambda self, e: self.func(
 417                "LPAD",
 418                exp.Literal.string(""),
 419                exp.Mul(this=self.func("LENGTH", e.this), expression=e.args.get("times")),
 420                e.this,
 421            ),
 422            exp.IsAscii: lambda self, e: f"({self.sql(e, 'this')} RLIKE '^[\x00-\x7f]*$')",
 423            exp.MD5Digest: lambda self, e: self.func("UNHEX", self.func("MD5", e.this)),
 424            exp.Chr: rename_func("CHAR"),
 425            exp.Contains: rename_func("INSTR"),
 426            exp.RegexpExtractAll: unsupported_args("position", "occurrence", "group")(
 427                lambda self, e: self.func(
 428                    "REGEXP_MATCH",
 429                    e.this,
 430                    e.expression,
 431                    e.args.get("parameters"),
 432                )
 433            ),
 434            exp.RegexpExtract: unsupported_args("group")(
 435                lambda self, e: self.func(
 436                    "REGEXP_SUBSTR",
 437                    e.this,
 438                    e.expression,
 439                    e.args.get("position"),
 440                    e.args.get("occurrence"),
 441                    e.args.get("parameters"),
 442                )
 443            ),
 444            exp.StartsWith: lambda self, e: self.func(
 445                "REGEXP_INSTR", e.this, self.func("CONCAT", exp.Literal.string("^"), e.expression)
 446            ),
 447            exp.FromBase: lambda self, e: self.func(
 448                "CONV", e.this, e.expression, exp.Literal.number(10)
 449            ),
 450            exp.RegexpILike: lambda self, e: self.binary(
 451                exp.RegexpLike(
 452                    this=exp.Lower(this=e.this),
 453                    expression=exp.Lower(this=e.expression),
 454                ),
 455                "RLIKE",
 456            ),
 457            exp.Stuff: lambda self, e: self.func(
 458                "CONCAT",
 459                self.func("SUBSTRING", e.this, exp.Literal.number(1), e.args.get("start") - 1),
 460                e.expression,
 461                self.func("SUBSTRING", e.this, e.args.get("start") + e.args.get("length")),
 462            ),
 463            exp.Reduce: unsupported_args("finish")(
 464                lambda self, e: self.func(
 465                    "REDUCE", e.args.get("initial"), e.this, e.args.get("merge")
 466                )
 467            ),
 468            exp.MatchAgainst: unsupported_args("modifier")(
 469                lambda self, e: super().matchagainst_sql(e)
 470            ),
 471        }
 472        TRANSFORMS.pop(exp.JSONExtractScalar)
 473        TRANSFORMS.pop(exp.CurrentDate)
 474
 475        UNSUPPORTED_TYPES = {
 476            exp.DataType.Type.ARRAY,
 477            exp.DataType.Type.AGGREGATEFUNCTION,
 478            exp.DataType.Type.SIMPLEAGGREGATEFUNCTION,
 479            exp.DataType.Type.BIGSERIAL,
 480            exp.DataType.Type.BPCHAR,
 481            exp.DataType.Type.DATEMULTIRANGE,
 482            exp.DataType.Type.DATERANGE,
 483            exp.DataType.Type.DYNAMIC,
 484            exp.DataType.Type.HLLSKETCH,
 485            exp.DataType.Type.HSTORE,
 486            exp.DataType.Type.IMAGE,
 487            exp.DataType.Type.INET,
 488            exp.DataType.Type.INT128,
 489            exp.DataType.Type.INT256,
 490            exp.DataType.Type.INT4MULTIRANGE,
 491            exp.DataType.Type.INT4RANGE,
 492            exp.DataType.Type.INT8MULTIRANGE,
 493            exp.DataType.Type.INT8RANGE,
 494            exp.DataType.Type.INTERVAL,
 495            exp.DataType.Type.IPADDRESS,
 496            exp.DataType.Type.IPPREFIX,
 497            exp.DataType.Type.IPV4,
 498            exp.DataType.Type.IPV6,
 499            exp.DataType.Type.LIST,
 500            exp.DataType.Type.MAP,
 501            exp.DataType.Type.LOWCARDINALITY,
 502            exp.DataType.Type.MONEY,
 503            exp.DataType.Type.MULTILINESTRING,
 504            exp.DataType.Type.NAME,
 505            exp.DataType.Type.NESTED,
 506            exp.DataType.Type.NOTHING,
 507            exp.DataType.Type.NULL,
 508            exp.DataType.Type.NUMMULTIRANGE,
 509            exp.DataType.Type.NUMRANGE,
 510            exp.DataType.Type.OBJECT,
 511            exp.DataType.Type.RANGE,
 512            exp.DataType.Type.ROWVERSION,
 513            exp.DataType.Type.SERIAL,
 514            exp.DataType.Type.SMALLSERIAL,
 515            exp.DataType.Type.SMALLMONEY,
 516            exp.DataType.Type.STRUCT,
 517            exp.DataType.Type.SUPER,
 518            exp.DataType.Type.TIMETZ,
 519            exp.DataType.Type.TIMESTAMPNTZ,
 520            exp.DataType.Type.TIMESTAMPLTZ,
 521            exp.DataType.Type.TIMESTAMPTZ,
 522            exp.DataType.Type.TIMESTAMP_NS,
 523            exp.DataType.Type.TSMULTIRANGE,
 524            exp.DataType.Type.TSRANGE,
 525            exp.DataType.Type.TSTZMULTIRANGE,
 526            exp.DataType.Type.TSTZRANGE,
 527            exp.DataType.Type.UINT128,
 528            exp.DataType.Type.UINT256,
 529            exp.DataType.Type.UNION,
 530            exp.DataType.Type.UNKNOWN,
 531            exp.DataType.Type.USERDEFINED,
 532            exp.DataType.Type.UUID,
 533            exp.DataType.Type.VARIANT,
 534            exp.DataType.Type.XML,
 535            exp.DataType.Type.TDIGEST,
 536        }
 537
 538        TYPE_MAPPING = {
 539            **MySQL.Generator.TYPE_MAPPING,
 540            exp.DataType.Type.BIGDECIMAL: "DECIMAL",
 541            exp.DataType.Type.BIT: "BOOLEAN",
 542            exp.DataType.Type.DATE32: "DATE",
 543            exp.DataType.Type.DATETIME64: "DATETIME",
 544            exp.DataType.Type.DECIMAL32: "DECIMAL",
 545            exp.DataType.Type.DECIMAL64: "DECIMAL",
 546            exp.DataType.Type.DECIMAL128: "DECIMAL",
 547            exp.DataType.Type.DECIMAL256: "DECIMAL",
 548            exp.DataType.Type.ENUM8: "ENUM",
 549            exp.DataType.Type.ENUM16: "ENUM",
 550            exp.DataType.Type.FIXEDSTRING: "TEXT",
 551            exp.DataType.Type.GEOMETRY: "GEOGRAPHY",
 552            exp.DataType.Type.POINT: "GEOGRAPHYPOINT",
 553            exp.DataType.Type.RING: "GEOGRAPHY",
 554            exp.DataType.Type.LINESTRING: "GEOGRAPHY",
 555            exp.DataType.Type.POLYGON: "GEOGRAPHY",
 556            exp.DataType.Type.MULTIPOLYGON: "GEOGRAPHY",
 557            exp.DataType.Type.JSONB: "BSON",
 558            exp.DataType.Type.TIMESTAMP: "TIMESTAMP",
 559            exp.DataType.Type.TIMESTAMP_S: "TIMESTAMP",
 560            exp.DataType.Type.TIMESTAMP_MS: "TIMESTAMP(6)",
 561        }
 562
 563        # https://docs.singlestore.com/cloud/reference/sql-reference/restricted-keywords/list-of-restricted-keywords/
 564        RESERVED_KEYWORDS = {
 565            "abs",
 566            "absolute",
 567            "access",
 568            "account",
 569            "acos",
 570            "action",
 571            "add",
 572            "adddate",
 573            "addtime",
 574            "admin",
 575            "aes_decrypt",
 576            "aes_encrypt",
 577            "after",
 578            "against",
 579            "aggregate",
 580            "aggregates",
 581            "aggregator",
 582            "aggregator_id",
 583            "aggregator_plan_hash",
 584            "aggregators",
 585            "algorithm",
 586            "all",
 587            "also",
 588            "alter",
 589            "always",
 590            "analyse",
 591            "analyze",
 592            "and",
 593            "anti_join",
 594            "any",
 595            "any_value",
 596            "approx_count_distinct",
 597            "approx_count_distinct_accumulate",
 598            "approx_count_distinct_combine",
 599            "approx_count_distinct_estimate",
 600            "approx_geography_intersects",
 601            "approx_percentile",
 602            "arghistory",
 603            "arrange",
 604            "arrangement",
 605            "array",
 606            "as",
 607            "asc",
 608            "ascii",
 609            "asensitive",
 610            "asin",
 611            "asm",
 612            "assertion",
 613            "assignment",
 614            "ast",
 615            "asymmetric",
 616            "async",
 617            "at",
 618            "atan",
 619            "atan2",
 620            "attach",
 621            "attribute",
 622            "authorization",
 623            "auto",
 624            "auto_increment",
 625            "auto_reprovision",
 626            "autostats",
 627            "autostats_cardinality_mode",
 628            "autostats_enabled",
 629            "autostats_histogram_mode",
 630            "autostats_sampling",
 631            "availability",
 632            "avg",
 633            "avg_row_length",
 634            "avro",
 635            "azure",
 636            "background",
 637            "_background_threads_for_cleanup",
 638            "backup",
 639            "backup_history",
 640            "backup_id",
 641            "backward",
 642            "batch",
 643            "batches",
 644            "batch_interval",
 645            "_batch_size_limit",
 646            "before",
 647            "begin",
 648            "between",
 649            "bigint",
 650            "bin",
 651            "binary",
 652            "_binary",
 653            "bit",
 654            "bit_and",
 655            "bit_count",
 656            "bit_or",
 657            "bit_xor",
 658            "blob",
 659            "bool",
 660            "boolean",
 661            "bootstrap",
 662            "both",
 663            "_bt",
 664            "btree",
 665            "bucket_count",
 666            "by",
 667            "byte",
 668            "byte_length",
 669            "cache",
 670            "call",
 671            "call_for_pipeline",
 672            "called",
 673            "capture",
 674            "cascade",
 675            "cascaded",
 676            "case",
 677            "cast",
 678            "catalog",
 679            "ceil",
 680            "ceiling",
 681            "chain",
 682            "change",
 683            "char",
 684            "character",
 685            "characteristics",
 686            "character_length",
 687            "char_length",
 688            "charset",
 689            "check",
 690            "checkpoint",
 691            "_check_can_connect",
 692            "_check_consistency",
 693            "checksum",
 694            "_checksum",
 695            "class",
 696            "clear",
 697            "client",
 698            "client_found_rows",
 699            "close",
 700            "cluster",
 701            "clustered",
 702            "cnf",
 703            "coalesce",
 704            "coercibility",
 705            "collate",
 706            "collation",
 707            "collect",
 708            "column",
 709            "columnar",
 710            "columns",
 711            "columnstore",
 712            "columnstore_segment_rows",
 713            "comment",
 714            "comments",
 715            "commit",
 716            "committed",
 717            "_commit_log_tail",
 718            "committed",
 719            "compact",
 720            "compile",
 721            "compressed",
 722            "compression",
 723            "concat",
 724            "concat_ws",
 725            "concurrent",
 726            "concurrently",
 727            "condition",
 728            "configuration",
 729            "connection",
 730            "connection_id",
 731            "connections",
 732            "config",
 733            "constraint",
 734            "constraints",
 735            "content",
 736            "continue",
 737            "_continue_replay",
 738            "conv",
 739            "conversion",
 740            "convert",
 741            "convert_tz",
 742            "copy",
 743            "_core",
 744            "cos",
 745            "cost",
 746            "cot",
 747            "count",
 748            "create",
 749            "credentials",
 750            "cross",
 751            "cube",
 752            "csv",
 753            "cume_dist",
 754            "curdate",
 755            "current",
 756            "current_catalog",
 757            "current_date",
 758            "current_role",
 759            "current_schema",
 760            "current_security_groups",
 761            "current_security_roles",
 762            "current_time",
 763            "current_timestamp",
 764            "current_user",
 765            "cursor",
 766            "curtime",
 767            "cycle",
 768            "data",
 769            "database",
 770            "databases",
 771            "date",
 772            "date_add",
 773            "datediff",
 774            "date_format",
 775            "date_sub",
 776            "date_trunc",
 777            "datetime",
 778            "day",
 779            "day_hour",
 780            "day_microsecond",
 781            "day_minute",
 782            "dayname",
 783            "dayofmonth",
 784            "dayofweek",
 785            "dayofyear",
 786            "day_second",
 787            "deallocate",
 788            "dec",
 789            "decimal",
 790            "declare",
 791            "decode",
 792            "default",
 793            "defaults",
 794            "deferrable",
 795            "deferred",
 796            "defined",
 797            "definer",
 798            "degrees",
 799            "delayed",
 800            "delay_key_write",
 801            "delete",
 802            "delimiter",
 803            "delimiters",
 804            "dense_rank",
 805            "desc",
 806            "describe",
 807            "detach",
 808            "deterministic",
 809            "dictionary",
 810            "differential",
 811            "directory",
 812            "disable",
 813            "discard",
 814            "_disconnect",
 815            "disk",
 816            "distinct",
 817            "distinctrow",
 818            "distributed_joins",
 819            "div",
 820            "do",
 821            "document",
 822            "domain",
 823            "dot_product",
 824            "double",
 825            "drop",
 826            "_drop_profile",
 827            "dual",
 828            "dump",
 829            "duplicate",
 830            "dynamic",
 831            "earliest",
 832            "each",
 833            "echo",
 834            "election",
 835            "else",
 836            "elseif",
 837            "elt",
 838            "enable",
 839            "enclosed",
 840            "encoding",
 841            "encrypted",
 842            "end",
 843            "engine",
 844            "engines",
 845            "enum",
 846            "errors",
 847            "escape",
 848            "escaped",
 849            "estimate",
 850            "euclidean_distance",
 851            "event",
 852            "events",
 853            "except",
 854            "exclude",
 855            "excluding",
 856            "exclusive",
 857            "execute",
 858            "exists",
 859            "exit",
 860            "exp",
 861            "explain",
 862            "extended",
 863            "extension",
 864            "external",
 865            "external_host",
 866            "external_port",
 867            "extract",
 868            "extractor",
 869            "extractors",
 870            "extra_join",
 871            "_failover",
 872            "failed_login_attempts",
 873            "failure",
 874            "false",
 875            "family",
 876            "fault",
 877            "fetch",
 878            "field",
 879            "fields",
 880            "file",
 881            "files",
 882            "fill",
 883            "first",
 884            "first_value",
 885            "fix_alter",
 886            "fixed",
 887            "float",
 888            "float4",
 889            "float8",
 890            "floor",
 891            "flush",
 892            "following",
 893            "for",
 894            "force",
 895            "force_compiled_mode",
 896            "force_interpreter_mode",
 897            "foreground",
 898            "foreign",
 899            "format",
 900            "forward",
 901            "found_rows",
 902            "freeze",
 903            "from",
 904            "from_base64",
 905            "from_days",
 906            "from_unixtime",
 907            "fs",
 908            "_fsync",
 909            "full",
 910            "fulltext",
 911            "function",
 912            "functions",
 913            "gc",
 914            "gcs",
 915            "get_format",
 916            "_gc",
 917            "_gcx",
 918            "generate",
 919            "geography",
 920            "geography_area",
 921            "geography_contains",
 922            "geography_distance",
 923            "geography_intersects",
 924            "geography_latitude",
 925            "geography_length",
 926            "geography_longitude",
 927            "geographypoint",
 928            "geography_point",
 929            "geography_within_distance",
 930            "geometry",
 931            "geometry_area",
 932            "geometry_contains",
 933            "geometry_distance",
 934            "geometry_filter",
 935            "geometry_intersects",
 936            "geometry_length",
 937            "geometrypoint",
 938            "geometry_point",
 939            "geometry_within_distance",
 940            "geometry_x",
 941            "geometry_y",
 942            "global",
 943            "_global_version_timestamp",
 944            "grant",
 945            "granted",
 946            "grants",
 947            "greatest",
 948            "group",
 949            "grouping",
 950            "groups",
 951            "group_concat",
 952            "gzip",
 953            "handle",
 954            "handler",
 955            "hard_cpu_limit_percentage",
 956            "hash",
 957            "has_temp_tables",
 958            "having",
 959            "hdfs",
 960            "header",
 961            "heartbeat_no_logging",
 962            "hex",
 963            "highlight",
 964            "high_priority",
 965            "hold",
 966            "holding",
 967            "host",
 968            "hosts",
 969            "hour",
 970            "hour_microsecond",
 971            "hour_minute",
 972            "hour_second",
 973            "identified",
 974            "identity",
 975            "if",
 976            "ifnull",
 977            "ignore",
 978            "ilike",
 979            "immediate",
 980            "immutable",
 981            "implicit",
 982            "import",
 983            "in",
 984            "including",
 985            "increment",
 986            "incremental",
 987            "index",
 988            "indexes",
 989            "inet_aton",
 990            "inet_ntoa",
 991            "inet6_aton",
 992            "inet6_ntoa",
 993            "infile",
 994            "inherit",
 995            "inherits",
 996            "_init_profile",
 997            "init",
 998            "initcap",
 999            "initialize",
1000            "initially",
1001            "inject",
1002            "inline",
1003            "inner",
1004            "inout",
1005            "input",
1006            "insensitive",
1007            "insert",
1008            "insert_method",
1009            "instance",
1010            "instead",
1011            "instr",
1012            "int",
1013            "int1",
1014            "int2",
1015            "int3",
1016            "int4",
1017            "int8",
1018            "integer",
1019            "_internal_dynamic_typecast",
1020            "interpreter_mode",
1021            "intersect",
1022            "interval",
1023            "into",
1024            "invoker",
1025            "is",
1026            "isnull",
1027            "isolation",
1028            "iterate",
1029            "join",
1030            "json",
1031            "json_agg",
1032            "json_array_contains_double",
1033            "json_array_contains_json",
1034            "json_array_contains_string",
1035            "json_array_push_double",
1036            "json_array_push_json",
1037            "json_array_push_string",
1038            "json_delete_key",
1039            "json_extract_double",
1040            "json_extract_json",
1041            "json_extract_string",
1042            "json_extract_bigint",
1043            "json_get_type",
1044            "json_length",
1045            "json_set_double",
1046            "json_set_json",
1047            "json_set_string",
1048            "json_splice_double",
1049            "json_splice_json",
1050            "json_splice_string",
1051            "kafka",
1052            "key",
1053            "key_block_size",
1054            "keys",
1055            "kill",
1056            "killall",
1057            "label",
1058            "lag",
1059            "language",
1060            "large",
1061            "last",
1062            "last_day",
1063            "last_insert_id",
1064            "last_value",
1065            "lateral",
1066            "latest",
1067            "lc_collate",
1068            "lc_ctype",
1069            "lcase",
1070            "lead",
1071            "leading",
1072            "leaf",
1073            "leakproof",
1074            "least",
1075            "leave",
1076            "leaves",
1077            "left",
1078            "length",
1079            "level",
1080            "license",
1081            "like",
1082            "limit",
1083            "lines",
1084            "listen",
1085            "llvm",
1086            "ln",
1087            "load",
1088            "loaddata_where",
1089            "_load",
1090            "local",
1091            "localtime",
1092            "localtimestamp",
1093            "locate",
1094            "location",
1095            "lock",
1096            "log",
1097            "log10",
1098            "log2",
1099            "long",
1100            "longblob",
1101            "longtext",
1102            "loop",
1103            "lower",
1104            "low_priority",
1105            "lpad",
1106            "_ls",
1107            "ltrim",
1108            "lz4",
1109            "management",
1110            "_management_thread",
1111            "mapping",
1112            "master",
1113            "match",
1114            "materialized",
1115            "max",
1116            "maxvalue",
1117            "max_concurrency",
1118            "max_errors",
1119            "max_partitions_per_batch",
1120            "max_queue_depth",
1121            "max_retries_per_batch_partition",
1122            "max_rows",
1123            "mbc",
1124            "md5",
1125            "mpl",
1126            "median",
1127            "mediumblob",
1128            "mediumint",
1129            "mediumtext",
1130            "member",
1131            "memory",
1132            "memory_percentage",
1133            "_memsql_table_id_lookup",
1134            "memsql",
1135            "memsql_deserialize",
1136            "memsql_imitating_kafka",
1137            "memsql_serialize",
1138            "merge",
1139            "metadata",
1140            "microsecond",
1141            "middleint",
1142            "min",
1143            "min_rows",
1144            "minus",
1145            "minute",
1146            "minute_microsecond",
1147            "minute_second",
1148            "minvalue",
1149            "mod",
1150            "mode",
1151            "model",
1152            "modifies",
1153            "modify",
1154            "month",
1155            "monthname",
1156            "months_between",
1157            "move",
1158            "mpl",
1159            "names",
1160            "named",
1161            "namespace",
1162            "national",
1163            "natural",
1164            "nchar",
1165            "next",
1166            "no",
1167            "node",
1168            "none",
1169            "no_query_rewrite",
1170            "noparam",
1171            "not",
1172            "nothing",
1173            "notify",
1174            "now",
1175            "nowait",
1176            "no_write_to_binlog",
1177            "no_query_rewrite",
1178            "norely",
1179            "nth_value",
1180            "ntile",
1181            "null",
1182            "nullcols",
1183            "nullif",
1184            "nulls",
1185            "numeric",
1186            "nvarchar",
1187            "object",
1188            "octet_length",
1189            "of",
1190            "off",
1191            "offline",
1192            "offset",
1193            "offsets",
1194            "oids",
1195            "on",
1196            "online",
1197            "only",
1198            "open",
1199            "operator",
1200            "optimization",
1201            "optimize",
1202            "optimizer",
1203            "optimizer_state",
1204            "option",
1205            "options",
1206            "optionally",
1207            "or",
1208            "order",
1209            "ordered_serialize",
1210            "orphan",
1211            "out",
1212            "out_of_order",
1213            "outer",
1214            "outfile",
1215            "over",
1216            "overlaps",
1217            "overlay",
1218            "owned",
1219            "owner",
1220            "pack_keys",
1221            "paired",
1222            "parser",
1223            "parquet",
1224            "partial",
1225            "partition",
1226            "partition_id",
1227            "partitioning",
1228            "partitions",
1229            "passing",
1230            "password",
1231            "password_lock_time",
1232            "parser",
1233            "pause",
1234            "_pause_replay",
1235            "percent_rank",
1236            "percentile_cont",
1237            "percentile_disc",
1238            "periodic",
1239            "persisted",
1240            "pi",
1241            "pipeline",
1242            "pipelines",
1243            "pivot",
1244            "placing",
1245            "plan",
1246            "plans",
1247            "plancache",
1248            "plugins",
1249            "pool",
1250            "pools",
1251            "port",
1252            "position",
1253            "pow",
1254            "power",
1255            "preceding",
1256            "precision",
1257            "prepare",
1258            "prepared",
1259            "preserve",
1260            "primary",
1261            "prior",
1262            "privileges",
1263            "procedural",
1264            "procedure",
1265            "procedures",
1266            "process",
1267            "processlist",
1268            "profile",
1269            "profiles",
1270            "program",
1271            "promote",
1272            "proxy",
1273            "purge",
1274            "quarter",
1275            "queries",
1276            "query",
1277            "query_timeout",
1278            "queue",
1279            "quote",
1280            "radians",
1281            "rand",
1282            "range",
1283            "rank",
1284            "read",
1285            "_read",
1286            "reads",
1287            "real",
1288            "reassign",
1289            "rebalance",
1290            "recheck",
1291            "record",
1292            "recursive",
1293            "redundancy",
1294            "redundant",
1295            "ref",
1296            "reference",
1297            "references",
1298            "refresh",
1299            "regexp",
1300            "reindex",
1301            "relative",
1302            "release",
1303            "reload",
1304            "rely",
1305            "remote",
1306            "remove",
1307            "rename",
1308            "repair",
1309            "_repair_table",
1310            "repeat",
1311            "repeatable",
1312            "_repl",
1313            "_reprovisioning",
1314            "replace",
1315            "replica",
1316            "replicate",
1317            "replicating",
1318            "replication",
1319            "durability",
1320            "require",
1321            "resource",
1322            "resource_pool",
1323            "reset",
1324            "restart",
1325            "restore",
1326            "restrict",
1327            "result",
1328            "_resurrect",
1329            "retry",
1330            "return",
1331            "returning",
1332            "returns",
1333            "reverse",
1334            "revoke",
1335            "rg_pool",
1336            "right",
1337            "right_anti_join",
1338            "right_semi_join",
1339            "right_straight_join",
1340            "rlike",
1341            "role",
1342            "roles",
1343            "rollback",
1344            "rollup",
1345            "round",
1346            "routine",
1347            "row",
1348            "row_count",
1349            "row_format",
1350            "row_number",
1351            "rows",
1352            "rowstore",
1353            "rule",
1354            "rpad",
1355            "_rpc",
1356            "rtrim",
1357            "running",
1358            "s3",
1359            "safe",
1360            "save",
1361            "savepoint",
1362            "scalar",
1363            "schema",
1364            "schemas",
1365            "schema_binding",
1366            "scroll",
1367            "search",
1368            "second",
1369            "second_microsecond",
1370            "sec_to_time",
1371            "security",
1372            "select",
1373            "semi_join",
1374            "_send_threads",
1375            "sensitive",
1376            "separator",
1377            "sequence",
1378            "sequences",
1379            "serial",
1380            "serializable",
1381            "series",
1382            "service_user",
1383            "server",
1384            "session",
1385            "session_user",
1386            "set",
1387            "setof",
1388            "security_lists_intersect",
1389            "sha",
1390            "sha1",
1391            "sha2",
1392            "shard",
1393            "sharded",
1394            "sharded_id",
1395            "share",
1396            "show",
1397            "shutdown",
1398            "sigmoid",
1399            "sign",
1400            "signal",
1401            "similar",
1402            "simple",
1403            "site",
1404            "signed",
1405            "sin",
1406            "skip",
1407            "skipped_batches",
1408            "sleep",
1409            "_sleep",
1410            "smallint",
1411            "snapshot",
1412            "_snapshot",
1413            "_snapshots",
1414            "soft_cpu_limit_percentage",
1415            "some",
1416            "soname",
1417            "sparse",
1418            "spatial",
1419            "spatial_check_index",
1420            "specific",
1421            "split",
1422            "sql",
1423            "sql_big_result",
1424            "sql_buffer_result",
1425            "sql_cache",
1426            "sql_calc_found_rows",
1427            "sqlexception",
1428            "sql_mode",
1429            "sql_no_cache",
1430            "sql_no_logging",
1431            "sql_small_result",
1432            "sqlstate",
1433            "sqlwarning",
1434            "sqrt",
1435            "ssl",
1436            "stable",
1437            "standalone",
1438            "start",
1439            "starting",
1440            "state",
1441            "statement",
1442            "statistics",
1443            "stats",
1444            "status",
1445            "std",
1446            "stddev",
1447            "stddev_pop",
1448            "stddev_samp",
1449            "stdin",
1450            "stdout",
1451            "stop",
1452            "storage",
1453            "str_to_date",
1454            "straight_join",
1455            "strict",
1456            "string",
1457            "strip",
1458            "subdate",
1459            "substr",
1460            "substring",
1461            "substring_index",
1462            "success",
1463            "sum",
1464            "super",
1465            "symmetric",
1466            "sync_snapshot",
1467            "sync",
1468            "_sync",
1469            "_sync2",
1470            "_sync_partitions",
1471            "_sync_snapshot",
1472            "synchronize",
1473            "sysid",
1474            "system",
1475            "table",
1476            "table_checksum",
1477            "tables",
1478            "tablespace",
1479            "tags",
1480            "tan",
1481            "target_size",
1482            "task",
1483            "temp",
1484            "template",
1485            "temporary",
1486            "temptable",
1487            "_term_bump",
1488            "terminate",
1489            "terminated",
1490            "test",
1491            "text",
1492            "then",
1493            "time",
1494            "timediff",
1495            "time_bucket",
1496            "time_format",
1497            "timeout",
1498            "timestamp",
1499            "timestampadd",
1500            "timestampdiff",
1501            "timezone",
1502            "time_to_sec",
1503            "tinyblob",
1504            "tinyint",
1505            "tinytext",
1506            "to",
1507            "to_base64",
1508            "to_char",
1509            "to_date",
1510            "to_days",
1511            "to_json",
1512            "to_number",
1513            "to_seconds",
1514            "to_timestamp",
1515            "tracelogs",
1516            "traditional",
1517            "trailing",
1518            "transform",
1519            "transaction",
1520            "_transactions_experimental",
1521            "treat",
1522            "trigger",
1523            "triggers",
1524            "trim",
1525            "true",
1526            "trunc",
1527            "truncate",
1528            "trusted",
1529            "two_phase",
1530            "_twopcid",
1531            "type",
1532            "types",
1533            "ucase",
1534            "unbounded",
1535            "uncommitted",
1536            "undefined",
1537            "undo",
1538            "unencrypted",
1539            "unenforced",
1540            "unhex",
1541            "unhold",
1542            "unicode",
1543            "union",
1544            "unique",
1545            "_unittest",
1546            "unix_timestamp",
1547            "unknown",
1548            "unlisten",
1549            "_unload",
1550            "unlock",
1551            "unlogged",
1552            "unpivot",
1553            "unsigned",
1554            "until",
1555            "update",
1556            "upgrade",
1557            "upper",
1558            "usage",
1559            "use",
1560            "user",
1561            "users",
1562            "using",
1563            "utc_date",
1564            "utc_time",
1565            "utc_timestamp",
1566            "_utf8",
1567            "vacuum",
1568            "valid",
1569            "validate",
1570            "validator",
1571            "value",
1572            "values",
1573            "varbinary",
1574            "varchar",
1575            "varcharacter",
1576            "variables",
1577            "variadic",
1578            "variance",
1579            "var_pop",
1580            "var_samp",
1581            "varying",
1582            "vector_sub",
1583            "verbose",
1584            "version",
1585            "view",
1586            "void",
1587            "volatile",
1588            "voting",
1589            "wait",
1590            "_wake",
1591            "warnings",
1592            "week",
1593            "weekday",
1594            "weekofyear",
1595            "when",
1596            "where",
1597            "while",
1598            "whitespace",
1599            "window",
1600            "with",
1601            "without",
1602            "within",
1603            "_wm_heartbeat",
1604            "work",
1605            "workload",
1606            "wrapper",
1607            "write",
1608            "xact_id",
1609            "xor",
1610            "year",
1611            "year_month",
1612            "yes",
1613            "zerofill",
1614            "zone",
1615        }
1616
1617        def jsonextractscalar_sql(self, expression: exp.JSONExtractScalar) -> str:
1618            json_type = expression.args.get("json_type")
1619            func_name = "JSON_EXTRACT_JSON" if json_type is None else f"JSON_EXTRACT_{json_type}"
1620            return json_extract_segments(func_name)(self, expression)
1621
1622        def jsonbextractscalar_sql(self, expression: exp.JSONBExtractScalar) -> str:
1623            json_type = expression.args.get("json_type")
1624            func_name = "BSON_EXTRACT_BSON" if json_type is None else f"BSON_EXTRACT_{json_type}"
1625            return json_extract_segments(func_name)(self, expression)
1626
1627        def jsonextractarray_sql(self, expression: exp.JSONExtractArray) -> str:
1628            self.unsupported("Arrays are not supported in SingleStore")
1629            return self.function_fallback_sql(expression)
1630
1631        @unsupported_args("on_condition")
1632        def jsonvalue_sql(self, expression: exp.JSONValue) -> str:
1633            res: exp.Expression = exp.JSONExtractScalar(
1634                this=expression.this,
1635                expression=expression.args.get("path"),
1636                json_type="STRING",
1637            )
1638
1639            returning = expression.args.get("returning")
1640            if returning is not None:
1641                res = exp.Cast(this=res, to=returning)
1642
1643            return self.sql(res)
1644
1645        def all_sql(self, expression: exp.All) -> str:
1646            self.unsupported("ALL subquery predicate is not supported in SingleStore")
1647            return super().all_sql(expression)
1648
1649        def jsonarraycontains_sql(self, expression: exp.JSONArrayContains) -> str:
1650            json_type = expression.text("json_type").upper()
1651
1652            if json_type:
1653                return self.func(
1654                    f"JSON_ARRAY_CONTAINS_{json_type}", expression.expression, expression.this
1655                )
1656
1657            return self.func(
1658                "JSON_ARRAY_CONTAINS_JSON",
1659                expression.expression,
1660                self.func("TO_JSON", expression.this),
1661            )
1662
1663        @unsupported_args("kind", "nested", "values")
1664        def datatype_sql(self, expression: exp.DataType) -> str:
1665            if expression.is_type(exp.DataType.Type.VARBINARY) and not expression.expressions:
1666                # `VARBINARY` must always have a size - if it doesn't, we always generate `BLOB`
1667                return "BLOB"
1668            if expression.is_type(
1669                exp.DataType.Type.DECIMAL32,
1670                exp.DataType.Type.DECIMAL64,
1671                exp.DataType.Type.DECIMAL128,
1672                exp.DataType.Type.DECIMAL256,
1673            ):
1674                scale = self.expressions(expression, flat=True)
1675
1676                if expression.is_type(exp.DataType.Type.DECIMAL32):
1677                    precision = "9"
1678                elif expression.is_type(exp.DataType.Type.DECIMAL64):
1679                    precision = "18"
1680                elif expression.is_type(exp.DataType.Type.DECIMAL128):
1681                    precision = "38"
1682                else:
1683                    # 65 is a maximum precision supported in SingleStore
1684                    precision = "65"
1685                if scale is not None:
1686                    return f"DECIMAL({precision}, {scale[0]})"
1687                else:
1688                    return f"DECIMAL({precision})"
1689
1690            return super().datatype_sql(expression)
1691
1692        def collate_sql(self, expression: exp.Collate) -> str:
1693            # SingleStore does not support setting a collation for column in the SELECT query,
1694            # so we cast column to a LONGTEXT type with specific collation
1695            return self.binary(expression, ":> LONGTEXT COLLATE")
1696
1697        def currentdate_sql(self, expression: exp.CurrentDate) -> str:
1698            timezone = expression.this
1699            if timezone:
1700                if isinstance(timezone, exp.Literal) and timezone.name.lower() == "utc":
1701                    return self.func("UTC_DATE")
1702                self.unsupported("CurrentDate with timezone is not supported in SingleStore")
1703
1704            return self.func("CURRENT_DATE")
1705
1706        def currenttime_sql(self, expression: exp.CurrentTime) -> str:
1707            arg = expression.this
1708            if arg:
1709                if isinstance(arg, exp.Literal) and arg.name.lower() == "utc":
1710                    return self.func("UTC_TIME")
1711                if isinstance(arg, exp.Literal) and arg.is_number:
1712                    return self.func("CURRENT_TIME", arg)
1713                self.unsupported("CurrentTime with timezone is not supported in SingleStore")
1714
1715            return self.func("CURRENT_TIME")
1716
1717        def currenttimestamp_sql(self, expression: exp.CurrentTimestamp) -> str:
1718            arg = expression.this
1719            if arg:
1720                if isinstance(arg, exp.Literal) and arg.name.lower() == "utc":
1721                    return self.func("UTC_TIMESTAMP")
1722                if isinstance(arg, exp.Literal) and arg.is_number:
1723                    return self.func("CURRENT_TIMESTAMP", arg)
1724                self.unsupported("CurrentTimestamp with timezone is not supported in SingleStore")
1725
1726            return self.func("CURRENT_TIMESTAMP")
1727
1728        def standardhash_sql(self, expression: exp.StandardHash) -> str:
1729            hash_function = expression.expression
1730            if hash_function is None:
1731                return self.func("SHA", expression.this)
1732            if isinstance(hash_function, exp.Literal):
1733                if hash_function.name.lower() == "sha":
1734                    return self.func("SHA", expression.this)
1735                if hash_function.name.lower() == "md5":
1736                    return self.func("MD5", expression.this)
1737
1738                self.unsupported(
1739                    f"{hash_function.this} hash method is not supported in SingleStore"
1740                )
1741                return self.func("SHA", expression.this)
1742
1743            self.unsupported("STANDARD_HASH function is not supported in SingleStore")
1744            return self.func("SHA", expression.this)
SUPPORTS_ORDER_BY_ALL = True

Whether ORDER BY ALL is supported (expands to all the selected columns) as in DuckDB, Spark3/Databricks

TIME_MAPPING: Dict[str, str] = {'D': '%u', 'DD': '%d', 'DY': '%a', 'HH': '%I', 'HH12': '%I', 'HH24': '%H', 'MI': '%M', 'MM': '%m', 'MON': '%b', 'MONTH': '%B', 'SS': '%S', 'RR': '%y', 'YY': '%y', 'YYYY': '%Y', 'FF6': '%f'}

Associates this dialect's time formats with their equivalent Python strftime formats.

SUPPORTS_COLUMN_JOIN_MARKS = False

Whether the old-style outer join (+) syntax is supported.

UNESCAPED_SEQUENCES: Dict[str, str] = {'\\a': '\x07', '\\b': '\x08', '\\f': '\x0c', '\\n': '\n', '\\r': '\r', '\\t': '\t', '\\v': '\x0b', '\\\\': '\\'}

Mapping of an escaped sequence (\n) to its unescaped version ( ).

tokenizer_class = <class 'SingleStore.Tokenizer'>
jsonpath_tokenizer_class = <class 'sqlglot.tokens.JSONPathTokenizer'>
parser_class = <class 'SingleStore.Parser'>
generator_class = <class 'SingleStore.Generator'>
TIME_TRIE: Dict = {'D': {0: True, 'D': {0: True}, 'Y': {0: True}}, 'H': {'H': {0: True, '1': {'2': {0: True}}, '2': {'4': {0: True}}}}, 'M': {'I': {0: True}, 'M': {0: True}, 'O': {'N': {0: True, 'T': {'H': {0: True}}}}}, 'S': {'S': {0: True}}, 'R': {'R': {0: True}}, 'Y': {'Y': {0: True, 'Y': {'Y': {0: True}}}}, 'F': {'F': {'6': {0: True}}}}
FORMAT_TRIE: Dict = {'D': {0: True, 'D': {0: True}, 'Y': {0: True}}, 'H': {'H': {0: True, '1': {'2': {0: True}}, '2': {'4': {0: True}}}}, 'M': {'I': {0: True}, 'M': {0: True}, 'O': {'N': {0: True, 'T': {'H': {0: True}}}}}, 'S': {'S': {0: True}}, 'R': {'R': {0: True}}, 'Y': {'Y': {0: True, 'Y': {'Y': {0: True}}}}, 'F': {'F': {'6': {0: True}}}}
INVERSE_TIME_MAPPING: Dict[str, str] = {'%u': 'D', '%d': 'DD', '%a': 'DY', '%I': 'HH12', '%H': 'HH24', '%M': 'MI', '%m': 'MM', '%b': 'MON', '%B': 'MONTH', '%S': 'SS', '%y': 'YY', '%Y': 'YYYY', '%f': 'FF6'}
INVERSE_TIME_TRIE: Dict = {'%': {'u': {0: True}, 'd': {0: True}, 'a': {0: True}, 'I': {0: True}, 'H': {0: True}, 'M': {0: True}, 'm': {0: True}, 'b': {0: True}, 'B': {0: True}, 'S': {0: True}, 'y': {0: True}, 'Y': {0: True}, 'f': {0: True}}}
INVERSE_FORMAT_MAPPING: Dict[str, str] = {}
INVERSE_FORMAT_TRIE: Dict = {}
INVERSE_CREATABLE_KIND_MAPPING: dict[str, str] = {}
ESCAPED_SEQUENCES: Dict[str, str] = {'\x07': '\\a', '\x08': '\\b', '\x0c': '\\f', '\n': '\\n', '\r': '\\r', '\t': '\\t', '\x0b': '\\v', '\\': '\\\\'}
QUOTE_START = "'"
QUOTE_END = "'"
IDENTIFIER_START = '`'
IDENTIFIER_END = '`'
BIT_START: Optional[str] = "b'"
BIT_END: Optional[str] = "'"
HEX_START: Optional[str] = "x'"
HEX_END: Optional[str] = "'"
BYTE_START: Optional[str] = "e'"
BYTE_END: Optional[str] = "'"
UNICODE_START: Optional[str] = None
UNICODE_END: Optional[str] = None
class SingleStore.Tokenizer(sqlglot.dialects.mysql.MySQL.Tokenizer):
59    class Tokenizer(MySQL.Tokenizer):
60        BYTE_STRINGS = [("e'", "'"), ("E'", "'")]
61
62        KEYWORDS = {
63            **MySQL.Tokenizer.KEYWORDS,
64            "BSON": TokenType.JSONB,
65            "GEOGRAPHYPOINT": TokenType.GEOGRAPHYPOINT,
66            "TIMESTAMP": TokenType.TIMESTAMP,
67            "UTC_DATE": TokenType.UTC_DATE,
68            "UTC_TIME": TokenType.UTC_TIME,
69            "UTC_TIMESTAMP": TokenType.UTC_TIMESTAMP,
70            ":>": TokenType.COLON_GT,
71            "!:>": TokenType.NCOLON_GT,
72            "::$": TokenType.DCOLONDOLLAR,
73            "::%": TokenType.DCOLONPERCENT,
74        }
BYTE_STRINGS = [("e'", "'"), ("E'", "'")]
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.PIPE_GT: 'PIPE_GT'>, '>=': <TokenType.GTE: 'GTE'>, '<=': <TokenType.LTE: 'LTE'>, '<>': <TokenType.NEQ: 'NEQ'>, '!=': <TokenType.NEQ: 'NEQ'>, ':=': <TokenType.COLON_EQ: 'COLON_EQ'>, '<=>': <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'>, '~~~': <TokenType.GLOB: 'GLOB'>, '~~': <TokenType.LIKE: 'LIKE'>, '~~*': <TokenType.ILIKE: 'ILIKE'>, '~*': <TokenType.IRLIKE: 'IRLIKE'>, 'ALL': <TokenType.ALL: 'ALL'>, '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'>, 'COPY': <TokenType.COPY: 'COPY'>, 'CREATE': <TokenType.CREATE: 'CREATE'>, 'CROSS': <TokenType.CROSS: 'CROSS'>, 'CUBE': <TokenType.CUBE: 'CUBE'>, 'CURRENT_DATE': <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, 'CURRENT_SCHEMA': <TokenType.CURRENT_SCHEMA: 'CURRENT_SCHEMA'>, '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'>, 'ENUM': <TokenType.ENUM: 'ENUM'>, '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'>, 'NAMESPACE': <TokenType.NAMESPACE: 'NAMESPACE'>, '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'>, 'RENAME': <TokenType.RENAME: 'RENAME'>, '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'>, 'SESSION': <TokenType.SESSION: 'SESSION'>, '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'>, 'STRAIGHT_JOIN': <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, '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'>, 'TRUNCATE': <TokenType.TRUNCATE: 'TRUNCATE'>, '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'>, 'INT1': <TokenType.TINYINT: 'TINYINT'>, 'TINYINT': <TokenType.TINYINT: 'TINYINT'>, 'INT16': <TokenType.SMALLINT: 'SMALLINT'>, 'SHORT': <TokenType.SMALLINT: 'SMALLINT'>, 'SMALLINT': <TokenType.SMALLINT: 'SMALLINT'>, 'HUGEINT': <TokenType.INT128: 'INT128'>, 'UHUGEINT': <TokenType.UINT128: 'UINT128'>, 'INT2': <TokenType.SMALLINT: 'SMALLINT'>, 'INTEGER': <TokenType.INT: 'INT'>, 'INT': <TokenType.INT: 'INT'>, 'INT4': <TokenType.INT: 'INT'>, 'INT32': <TokenType.INT: 'INT'>, 'INT64': <TokenType.BIGINT: 'BIGINT'>, 'INT128': <TokenType.INT128: 'INT128'>, 'INT256': <TokenType.INT256: 'INT256'>, 'LONG': <TokenType.BIGINT: 'BIGINT'>, 'BIGINT': <TokenType.BIGINT: 'BIGINT'>, 'INT8': <TokenType.TINYINT: 'TINYINT'>, 'UINT': <TokenType.UINT: 'UINT'>, 'UINT128': <TokenType.UINT128: 'UINT128'>, 'UINT256': <TokenType.UINT256: 'UINT256'>, 'DEC': <TokenType.DECIMAL: 'DECIMAL'>, 'DECIMAL': <TokenType.DECIMAL: 'DECIMAL'>, 'DECIMAL32': <TokenType.DECIMAL32: 'DECIMAL32'>, 'DECIMAL64': <TokenType.DECIMAL64: 'DECIMAL64'>, 'DECIMAL128': <TokenType.DECIMAL128: 'DECIMAL128'>, 'DECIMAL256': <TokenType.DECIMAL256: 'DECIMAL256'>, 'BIGDECIMAL': <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, 'BIGNUMERIC': <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, 'LIST': <TokenType.LIST: 'LIST'>, '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'>, 'JSONB': <TokenType.JSONB: 'JSONB'>, 'CHAR': <TokenType.CHAR: 'CHAR'>, 'CHARACTER': <TokenType.CHAR: 'CHAR'>, 'CHAR VARYING': <TokenType.VARCHAR: 'VARCHAR'>, 'CHARACTER VARYING': <TokenType.VARCHAR: 'VARCHAR'>, 'NCHAR': <TokenType.NCHAR: 'NCHAR'>, 'VARCHAR': <TokenType.VARCHAR: 'VARCHAR'>, 'VARCHAR2': <TokenType.VARCHAR: 'VARCHAR'>, 'NVARCHAR': <TokenType.NVARCHAR: 'NVARCHAR'>, 'NVARCHAR2': <TokenType.NVARCHAR: 'NVARCHAR'>, 'BPCHAR': <TokenType.BPCHAR: 'BPCHAR'>, '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.BLOB: 'BLOB'>, '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'>, 'TIMESTAMP_LTZ': <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, 'TIMESTAMPNTZ': <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, 'TIMESTAMP_NTZ': <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, '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'>, 'VECTOR': <TokenType.VECTOR: 'VECTOR'>, 'STRUCT': <TokenType.STRUCT: 'STRUCT'>, 'SEQUENCE': <TokenType.SEQUENCE: 'SEQUENCE'>, 'VARIANT': <TokenType.VARIANT: 'VARIANT'>, 'ALTER': <TokenType.ALTER: 'ALTER'>, 'ANALYZE': <TokenType.ANALYZE: 'ANALYZE'>, 'CALL': <TokenType.COMMAND: 'COMMAND'>, 'COMMENT': <TokenType.COMMENT: 'COMMENT'>, 'EXPLAIN': <TokenType.DESCRIBE: 'DESCRIBE'>, 'GRANT': <TokenType.GRANT: 'GRANT'>, 'REVOKE': <TokenType.REVOKE: 'REVOKE'>, 'OPTIMIZE': <TokenType.COMMAND: 'COMMAND'>, 'PREPARE': <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'>, 'CHARSET': <TokenType.CHARACTER_SET: 'CHARACTER_SET'>, 'DISTINCTROW': <TokenType.DISTINCT: 'DISTINCT'>, 'FORCE': <TokenType.FORCE: 'FORCE'>, 'IGNORE': <TokenType.IGNORE: 'IGNORE'>, 'KEY': <TokenType.KEY: 'KEY'>, 'LOCK TABLES': <TokenType.COMMAND: 'COMMAND'>, 'MEMBER OF': <TokenType.MEMBER_OF: 'MEMBER_OF'>, 'SEPARATOR': <TokenType.SEPARATOR: 'SEPARATOR'>, 'SERIAL': <TokenType.SERIAL: 'SERIAL'>, 'START': <TokenType.BEGIN: 'BEGIN'>, 'SIGNED': <TokenType.BIGINT: 'BIGINT'>, 'SIGNED INTEGER': <TokenType.BIGINT: 'BIGINT'>, 'UNLOCK TABLES': <TokenType.COMMAND: 'COMMAND'>, 'UNSIGNED': <TokenType.UBIGINT: 'UBIGINT'>, 'UNSIGNED INTEGER': <TokenType.UBIGINT: 'UBIGINT'>, 'YEAR': <TokenType.YEAR: 'YEAR'>, '_ARMSCII8': <TokenType.INTRODUCER: 'INTRODUCER'>, '_ASCII': <TokenType.INTRODUCER: 'INTRODUCER'>, '_BIG5': <TokenType.INTRODUCER: 'INTRODUCER'>, '_BINARY': <TokenType.INTRODUCER: 'INTRODUCER'>, '_CP1250': <TokenType.INTRODUCER: 'INTRODUCER'>, '_CP1251': <TokenType.INTRODUCER: 'INTRODUCER'>, '_CP1256': <TokenType.INTRODUCER: 'INTRODUCER'>, '_CP1257': <TokenType.INTRODUCER: 'INTRODUCER'>, '_CP850': <TokenType.INTRODUCER: 'INTRODUCER'>, '_CP852': <TokenType.INTRODUCER: 'INTRODUCER'>, '_CP866': <TokenType.INTRODUCER: 'INTRODUCER'>, '_CP932': <TokenType.INTRODUCER: 'INTRODUCER'>, '_DEC8': <TokenType.INTRODUCER: 'INTRODUCER'>, '_EUCJPMS': <TokenType.INTRODUCER: 'INTRODUCER'>, '_EUCKR': <TokenType.INTRODUCER: 'INTRODUCER'>, '_GB18030': <TokenType.INTRODUCER: 'INTRODUCER'>, '_GB2312': <TokenType.INTRODUCER: 'INTRODUCER'>, '_GBK': <TokenType.INTRODUCER: 'INTRODUCER'>, '_GEOSTD8': <TokenType.INTRODUCER: 'INTRODUCER'>, '_GREEK': <TokenType.INTRODUCER: 'INTRODUCER'>, '_HEBREW': <TokenType.INTRODUCER: 'INTRODUCER'>, '_HP8': <TokenType.INTRODUCER: 'INTRODUCER'>, '_KEYBCS2': <TokenType.INTRODUCER: 'INTRODUCER'>, '_KOI8R': <TokenType.INTRODUCER: 'INTRODUCER'>, '_KOI8U': <TokenType.INTRODUCER: 'INTRODUCER'>, '_LATIN1': <TokenType.INTRODUCER: 'INTRODUCER'>, '_LATIN2': <TokenType.INTRODUCER: 'INTRODUCER'>, '_LATIN5': <TokenType.INTRODUCER: 'INTRODUCER'>, '_LATIN7': <TokenType.INTRODUCER: 'INTRODUCER'>, '_MACCE': <TokenType.INTRODUCER: 'INTRODUCER'>, '_MACROMAN': <TokenType.INTRODUCER: 'INTRODUCER'>, '_SJIS': <TokenType.INTRODUCER: 'INTRODUCER'>, '_SWE7': <TokenType.INTRODUCER: 'INTRODUCER'>, '_TIS620': <TokenType.INTRODUCER: 'INTRODUCER'>, '_UCS2': <TokenType.INTRODUCER: 'INTRODUCER'>, '_UJIS': <TokenType.INTRODUCER: 'INTRODUCER'>, '_UTF8': <TokenType.INTRODUCER: 'INTRODUCER'>, '_UTF16': <TokenType.INTRODUCER: 'INTRODUCER'>, '_UTF16LE': <TokenType.INTRODUCER: 'INTRODUCER'>, '_UTF32': <TokenType.INTRODUCER: 'INTRODUCER'>, '_UTF8MB3': <TokenType.INTRODUCER: 'INTRODUCER'>, '_UTF8MB4': <TokenType.INTRODUCER: 'INTRODUCER'>, '@@': <TokenType.SESSION_PARAMETER: 'SESSION_PARAMETER'>, 'BSON': <TokenType.JSONB: 'JSONB'>, 'GEOGRAPHYPOINT': <TokenType.GEOGRAPHYPOINT: 'GEOGRAPHYPOINT'>, 'UTC_DATE': <TokenType.UTC_DATE: 'UTC_DATE'>, 'UTC_TIME': <TokenType.UTC_TIME: 'UTC_TIME'>, 'UTC_TIMESTAMP': <TokenType.UTC_TIMESTAMP: 'UTC_TIMESTAMP'>, ':>': <TokenType.COLON_GT: 'COLON_GT'>, '!:>': <TokenType.NCOLON_GT: 'NCOLON_GT'>, '::$': <TokenType.DCOLONDOLLAR: 'DCOLONDOLLAR'>, '::%': <TokenType.DCOLONPERCENT: 'DCOLONPERCENT'>}
class SingleStore.Parser(sqlglot.dialects.mysql.MySQL.Parser):
 76    class Parser(MySQL.Parser):
 77        FUNCTIONS = {
 78            **MySQL.Parser.FUNCTIONS,
 79            "TO_DATE": build_formatted_time(exp.TsOrDsToDate, "singlestore"),
 80            "TO_TIMESTAMP": build_formatted_time(exp.StrToTime, "singlestore"),
 81            "TO_CHAR": build_formatted_time(exp.ToChar, "singlestore"),
 82            "STR_TO_DATE": build_formatted_time(exp.StrToDate, "mysql"),
 83            "DATE_FORMAT": build_formatted_time(exp.TimeToStr, "mysql"),
 84            # The first argument of following functions is converted to TIME(6)
 85            # This is needed because exp.TimeToStr is converted to DATE_FORMAT
 86            # which interprets the first argument as DATETIME and fails to parse
 87            # string literals like '12:05:47' without a date part.
 88            "TIME_FORMAT": lambda args: exp.TimeToStr(
 89                this=cast_to_time6(seq_get(args, 0)),
 90                format=MySQL.format_time(seq_get(args, 1)),
 91            ),
 92            "HOUR": lambda args: exp.cast(
 93                exp.TimeToStr(
 94                    this=cast_to_time6(seq_get(args, 0)),
 95                    format=MySQL.format_time(exp.Literal.string("%k")),
 96                ),
 97                DataType.Type.INT,
 98            ),
 99            "MICROSECOND": lambda args: exp.cast(
100                exp.TimeToStr(
101                    this=cast_to_time6(seq_get(args, 0)),
102                    format=MySQL.format_time(exp.Literal.string("%f")),
103                ),
104                DataType.Type.INT,
105            ),
106            "SECOND": lambda args: exp.cast(
107                exp.TimeToStr(
108                    this=cast_to_time6(seq_get(args, 0)),
109                    format=MySQL.format_time(exp.Literal.string("%s")),
110                ),
111                DataType.Type.INT,
112            ),
113            "MINUTE": lambda args: exp.cast(
114                exp.TimeToStr(
115                    this=cast_to_time6(seq_get(args, 0)),
116                    format=MySQL.format_time(exp.Literal.string("%i")),
117                ),
118                DataType.Type.INT,
119            ),
120            "MONTHNAME": lambda args: exp.TimeToStr(
121                this=seq_get(args, 0),
122                format=MySQL.format_time(exp.Literal.string("%M")),
123            ),
124            "WEEKDAY": lambda args: exp.paren(exp.DayOfWeek(this=seq_get(args, 0)) + 5, copy=False)
125            % 7,
126            "UNIX_TIMESTAMP": exp.StrToUnix.from_arg_list,
127            "FROM_UNIXTIME": build_formatted_time(exp.UnixToTime, "mysql"),
128            "TIME_BUCKET": lambda args: exp.DateBin(
129                this=seq_get(args, 0),
130                expression=seq_get(args, 1),
131                origin=seq_get(args, 2),
132            ),
133            "BSON_EXTRACT_BSON": build_json_extract_path(exp.JSONBExtract),
134            "BSON_EXTRACT_STRING": build_json_extract_path(
135                exp.JSONBExtractScalar, json_type="STRING"
136            ),
137            "BSON_EXTRACT_DOUBLE": build_json_extract_path(
138                exp.JSONBExtractScalar, json_type="DOUBLE"
139            ),
140            "BSON_EXTRACT_BIGINT": build_json_extract_path(
141                exp.JSONBExtractScalar, json_type="BIGINT"
142            ),
143            "JSON_EXTRACT_JSON": build_json_extract_path(exp.JSONExtract),
144            "JSON_EXTRACT_STRING": build_json_extract_path(
145                exp.JSONExtractScalar, json_type="STRING"
146            ),
147            "JSON_EXTRACT_DOUBLE": build_json_extract_path(
148                exp.JSONExtractScalar, json_type="DOUBLE"
149            ),
150            "JSON_EXTRACT_BIGINT": build_json_extract_path(
151                exp.JSONExtractScalar, json_type="BIGINT"
152            ),
153            "JSON_ARRAY_CONTAINS_STRING": lambda args: exp.JSONArrayContains(
154                this=seq_get(args, 1),
155                expression=seq_get(args, 0),
156                json_type="STRING",
157            ),
158            "JSON_ARRAY_CONTAINS_DOUBLE": lambda args: exp.JSONArrayContains(
159                this=seq_get(args, 1),
160                expression=seq_get(args, 0),
161                json_type="DOUBLE",
162            ),
163            "JSON_ARRAY_CONTAINS_JSON": lambda args: exp.JSONArrayContains(
164                this=seq_get(args, 1),
165                expression=seq_get(args, 0),
166                json_type="JSON",
167            ),
168            "JSON_PRETTY": exp.JSONFormat.from_arg_list,
169            "JSON_BUILD_ARRAY": lambda args: exp.JSONArray(expressions=args),
170            "JSON_BUILD_OBJECT": lambda args: exp.JSONObject(expressions=args),
171            "DATE": exp.Date.from_arg_list,
172            "DAYNAME": lambda args: exp.TimeToStr(
173                this=seq_get(args, 0),
174                format=MySQL.format_time(exp.Literal.string("%W")),
175            ),
176            "TIMESTAMPDIFF": lambda args: exp.TimestampDiff(
177                this=seq_get(args, 2),
178                expression=seq_get(args, 1),
179                unit=seq_get(args, 0),
180            ),
181            "APPROX_COUNT_DISTINCT": exp.Hll.from_arg_list,
182            "APPROX_PERCENTILE": lambda args, dialect: exp.ApproxQuantile(
183                this=seq_get(args, 0),
184                quantile=seq_get(args, 1),
185                error_tolerance=seq_get(args, 2),
186            ),
187            "VARIANCE": exp.VariancePop.from_arg_list,
188            "INSTR": exp.Contains.from_arg_list,
189            "REGEXP_MATCH": lambda args: exp.RegexpExtractAll(
190                this=seq_get(args, 0),
191                expression=seq_get(args, 1),
192                parameters=seq_get(args, 2),
193            ),
194            "REGEXP_SUBSTR": lambda args: exp.RegexpExtract(
195                this=seq_get(args, 0),
196                expression=seq_get(args, 1),
197                position=seq_get(args, 2),
198                occurrence=seq_get(args, 3),
199                parameters=seq_get(args, 4),
200            ),
201            "REDUCE": lambda args: exp.Reduce(
202                initial=seq_get(args, 0),
203                this=seq_get(args, 1),
204                merge=seq_get(args, 2),
205            ),
206        }
207
208        FUNCTION_PARSERS: t.Dict[str, t.Callable] = {
209            **MySQL.Parser.FUNCTION_PARSERS,
210            "JSON_AGG": lambda self: exp.JSONArrayAgg(
211                this=self._parse_term(),
212                order=self._parse_order(),
213            ),
214        }
215
216        NO_PAREN_FUNCTIONS = {
217            **MySQL.Parser.NO_PAREN_FUNCTIONS,
218            TokenType.UTC_DATE: exp.UtcDate,
219            TokenType.UTC_TIME: exp.UtcTime,
220            TokenType.UTC_TIMESTAMP: exp.UtcTimestamp,
221        }
222
223        CAST_COLUMN_OPERATORS = {TokenType.COLON_GT, TokenType.NCOLON_GT}
224
225        COLUMN_OPERATORS = {
226            **MySQL.Parser.COLUMN_OPERATORS,
227            TokenType.COLON_GT: lambda self, this, to: self.expression(
228                exp.Cast,
229                this=this,
230                to=to,
231            ),
232            TokenType.NCOLON_GT: lambda self, this, to: self.expression(
233                exp.TryCast,
234                this=this,
235                to=to,
236            ),
237            TokenType.DCOLON: lambda self, this, path: build_json_extract_path(exp.JSONExtract)(
238                [this, exp.Literal.string(path.name)]
239            ),
240            TokenType.DCOLONDOLLAR: lambda self, this, path: build_json_extract_path(
241                exp.JSONExtractScalar, json_type="STRING"
242            )([this, exp.Literal.string(path.name)]),
243            TokenType.DCOLONPERCENT: lambda self, this, path: build_json_extract_path(
244                exp.JSONExtractScalar, json_type="DOUBLE"
245            )([this, exp.Literal.string(path.name)]),
246        }
247        COLUMN_OPERATORS.pop(TokenType.ARROW)
248        COLUMN_OPERATORS.pop(TokenType.DARROW)
249        COLUMN_OPERATORS.pop(TokenType.HASH_ARROW)
250        COLUMN_OPERATORS.pop(TokenType.DHASH_ARROW)
251        COLUMN_OPERATORS.pop(TokenType.PLACEHOLDER)

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: 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
FUNCTIONS = {'ABS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Abs'>>, 'ACOS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Acos'>>, 'ACOSH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Acosh'>>, 'ADD_MONTHS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.AddMonths'>>, 'AND': <bound method Func.from_arg_list of <class 'sqlglot.expressions.And'>>, 'ANONYMOUS_AGG_FUNC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.AnonymousAggFunc'>>, 'ANY_VALUE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.AnyValue'>>, 'APPLY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Apply'>>, '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.Hll'>>, 'APPROX_QUANTILE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ApproxQuantile'>>, 'APPROX_QUANTILES': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ApproxQuantiles'>>, 'APPROX_TOP_K': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ApproxTopK'>>, 'APPROX_TOP_SUM': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ApproxTopSum'>>, 'ARG_MAX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArgMax'>>, 'ARGMAX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArgMax'>>, 'MAX_BY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArgMax'>>, 'ARG_MIN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArgMin'>>, 'ARGMIN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArgMin'>>, 'MIN_BY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArgMin'>>, 'ARRAY': <function Parser.<lambda>>, 'ARRAY_AGG': <function Parser.<lambda>>, '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_CONCAT_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayConcatAgg'>>, 'ARRAY_CONSTRUCT_COMPACT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayConstructCompact'>>, 'ARRAY_CONTAINS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayContains'>>, 'ARRAY_HAS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayContains'>>, 'ARRAY_CONTAINS_ALL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayContainsAll'>>, 'ARRAY_HAS_ALL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayContainsAll'>>, '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_FIRST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayFirst'>>, 'ARRAY_INTERSECT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayIntersect'>>, 'ARRAY_INTERSECTION': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayIntersect'>>, 'ARRAY_LAST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayLast'>>, 'ARRAY_OVERLAPS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayOverlaps'>>, 'ARRAY_REMOVE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayRemove'>>, 'ARRAY_REVERSE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayReverse'>>, 'ARRAY_SIZE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArraySize'>>, 'ARRAY_LENGTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArraySize'>>, 'ARRAY_SLICE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArraySlice'>>, '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_TO_STRING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayToString'>>, 'ARRAY_JOIN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayToString'>>, 'ARRAY_UNION_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayUnionAgg'>>, 'ARRAY_UNIQUE_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ArrayUniqueAgg'>>, 'ASCII': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Ascii'>>, 'ASIN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Asin'>>, 'ASINH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Asinh'>>, 'ATAN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Atan'>>, 'ATAN2': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Atan2'>>, 'ATANH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Atanh'>>, 'AVG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Avg'>>, 'BITWISE_AND_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.BitwiseAndAgg'>>, 'BITWISE_COUNT_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.BitwiseCountAgg'>>, 'BITWISE_OR_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.BitwiseOrAgg'>>, 'BITWISE_XOR_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.BitwiseXorAgg'>>, 'BYTE_LENGTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ByteLength'>>, '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'>>, 'CBRT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Cbrt'>>, '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': <function Parser.<lambda>>, 'CHAR': <function Parser.<lambda>>, 'COALESCE': <function build_coalesce>, 'IFNULL': <function build_coalesce>, 'NVL': <function build_coalesce>, 'CODE_POINTS_TO_BYTES': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CodePointsToBytes'>>, 'CODE_POINTS_TO_STRING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CodePointsToString'>>, 'COLLATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Collate'>>, 'COLUMNS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Columns'>>, 'COMBINED_AGG_FUNC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CombinedAggFunc'>>, 'COMBINED_PARAMETERIZED_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CombinedParameterizedAgg'>>, 'CONCAT': <function Parser.<lambda>>, 'CONCAT_WS': <function Parser.<lambda>>, 'CONNECT_BY_ROOT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ConnectByRoot'>>, 'CONTAINS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Contains'>>, 'CONVERT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Convert'>>, 'CONVERT_TIMEZONE': <function build_convert_timezone>, 'CONVERT_TO_CHARSET': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ConvertToCharset'>>, 'CORR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Corr'>>, 'COSINE_DISTANCE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CosineDistance'>>, 'COT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Cot'>>, 'COTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Coth'>>, 'COUNT': <function Parser.<lambda>>, 'COUNT_IF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CountIf'>>, 'COUNTIF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CountIf'>>, 'COVAR_POP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CovarPop'>>, 'COVAR_SAMP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CovarSamp'>>, 'CSC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Csc'>>, 'CSCH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Csch'>>, 'CUME_DIST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CumeDist'>>, '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_SCHEMA': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CurrentSchema'>>, '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_TIMESTAMP_L_T_Z': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CurrentTimestampLTZ'>>, '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': <function build_date_delta_with_interval.<locals>._builder>, 'DATE_BIN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateBin'>>, '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'>>, 'DATE_FROM_PARTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateFromParts'>>, 'DATEFROMPARTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateFromParts'>>, 'DATE_FROM_UNIX_DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateFromUnixDate'>>, 'DATE_STR_TO_DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateStrToDate'>>, 'DATE_SUB': <function build_date_delta_with_interval.<locals>._builder>, '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': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Datetime'>>, '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': <function MySQL.Parser.<lambda>>, 'DAY_OF_MONTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DayOfMonth'>>, 'DAYOFMONTH': <function MySQL.Parser.<lambda>>, 'DAY_OF_WEEK': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DayOfWeek'>>, 'DAYOFWEEK': <function MySQL.Parser.<lambda>>, 'DAYOFWEEK_ISO': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DayOfWeekIso'>>, 'ISODOW': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DayOfWeekIso'>>, 'DAY_OF_YEAR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DayOfYear'>>, 'DAYOFYEAR': <function MySQL.Parser.<lambda>>, 'DECODE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Decode'>>, 'DECODE_CASE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DecodeCase'>>, 'DENSE_RANK': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DenseRank'>>, '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'>>, 'ENDS_WITH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.EndsWith'>>, 'ENDSWITH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.EndsWith'>>, 'EUCLIDEAN_DISTANCE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.EuclideanDistance'>>, 'EXISTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Exists'>>, 'EXP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Exp'>>, 'EXPLODE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Explode'>>, 'EXPLODE_OUTER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ExplodeOuter'>>, 'EXPLODING_GENERATE_SERIES': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ExplodingGenerateSeries'>>, 'EXTRACT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Extract'>>, 'FARM_FINGERPRINT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.FarmFingerprint'>>, 'FARMFINGERPRINT64': <bound method Func.from_arg_list of <class 'sqlglot.expressions.FarmFingerprint'>>, 'FEATURES_AT_TIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.FeaturesAtTime'>>, 'FIRST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.First'>>, 'FIRST_VALUE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.FirstValue'>>, 'FLATTEN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Flatten'>>, 'FLOAT64': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Float64'>>, 'FLOOR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Floor'>>, 'FORMAT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.NumberToStr'>>, 'FROM_BASE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.FromBase'>>, 'FROM_BASE32': <bound method Func.from_arg_list of <class 'sqlglot.expressions.FromBase32'>>, 'FROM_BASE64': <bound method Func.from_arg_list of <class 'sqlglot.expressions.FromBase64'>>, 'FROM_ISO8601_TIMESTAMP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.FromISO8601Timestamp'>>, 'GAP_FILL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.GapFill'>>, 'GENERATE_DATE_ARRAY': <function Parser.<lambda>>, 'GENERATE_EMBEDDING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.GenerateEmbedding'>>, 'GENERATE_SERIES': <bound method Func.from_arg_list of <class 'sqlglot.expressions.GenerateSeries'>>, 'GENERATE_TIMESTAMP_ARRAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.GenerateTimestampArray'>>, 'GET_EXTRACT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.GetExtract'>>, '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'>>, 'GROUPING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Grouping'>>, 'HEX': <function build_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'>>, 'IIF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.If'>>, 'INITCAP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Initcap'>>, 'INLINE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Inline'>>, 'INT64': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Int64'>>, 'IS_ASCII': <bound method Func.from_arg_list of <class 'sqlglot.expressions.IsAscii'>>, 'IS_INF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.IsInf'>>, 'ISINF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.IsInf'>>, '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_APPEND': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONArrayAppend'>>, 'JSON_ARRAY_CONTAINS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONArrayContains'>>, 'JSON_ARRAY_INSERT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONArrayInsert'>>, 'JSONB_CONTAINS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONBContains'>>, 'JSONB_EXISTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONBExists'>>, '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'>>, 'J_S_O_N_B_OBJECT_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONBObjectAgg'>>, 'J_S_O_N_BOOL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONBool'>>, 'J_S_O_N_CAST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONCast'>>, 'J_S_O_N_EXISTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONExists'>>, 'JSON_EXTRACT': <function build_extract_json_with_path.<locals>._builder>, 'JSON_EXTRACT_ARRAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONExtractArray'>>, 'JSON_EXTRACT_SCALAR': <function build_extract_json_with_path.<locals>._builder>, 'JSON_FORMAT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONFormat'>>, 'J_S_O_N_KEYS_AT_DEPTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONKeysAtDepth'>>, 'J_S_O_N_OBJECT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONObject'>>, 'J_S_O_N_OBJECT_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONObjectAgg'>>, 'JSON_REMOVE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONRemove'>>, 'JSON_SET': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONSet'>>, 'JSON_STRIP_NULLS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONStripNulls'>>, 'J_S_O_N_TABLE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONTable'>>, 'JSON_TYPE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONType'>>, 'J_S_O_N_VALUE_ARRAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONValueArray'>>, 'JUSTIFY_DAYS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JustifyDays'>>, 'JUSTIFY_HOURS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JustifyHours'>>, 'JUSTIFY_INTERVAL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JustifyInterval'>>, 'LAG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Lag'>>, 'LAST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Last'>>, 'LAST_DAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LastDay'>>, 'LAST_DAY_OF_MONTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LastDay'>>, 'LAST_VALUE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LastValue'>>, 'LAX_BOOL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LaxBool'>>, 'LAX_FLOAT64': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LaxFloat64'>>, 'LAX_INT64': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LaxInt64'>>, 'LAX_STRING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LaxString'>>, 'LEAD': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Lead'>>, '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': <function MySQL.Parser.<lambda>>, 'LEN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Length'>>, 'CHAR_LENGTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Length'>>, 'CHARACTER_LENGTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Length'>>, 'LEVENSHTEIN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Levenshtein'>>, 'LIST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.List'>>, 'LN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Ln'>>, 'LOG': <function build_logarithm>, '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': <function build_lower>, 'LCASE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Lower'>>, 'LOWER_HEX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LowerHex'>>, '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'>>, 'MAKE_INTERVAL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.MakeInterval'>>, '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'>>, 'MEDIAN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Median'>>, 'MIN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Min'>>, 'MONTH': <function MySQL.Parser.<lambda>>, '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'>>, 'NORMALIZE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Normalize'>>, 'NTH_VALUE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.NthValue'>>, 'NTILE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Ntile'>>, 'NULLIF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Nullif'>>, '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'>>, 'OBJECT_INSERT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ObjectInsert'>>, 'OPEN_J_S_O_N': <bound method Func.from_arg_list of <class 'sqlglot.expressions.OpenJSON'>>, 'OR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Or'>>, 'OVERLAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Overlay'>>, 'PAD': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Pad'>>, 'PARAMETERIZED_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ParameterizedAgg'>>, 'PARSE_BIGNUMERIC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ParseBignumeric'>>, 'PARSE_DATETIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ParseDatetime'>>, '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'>>, 'PARSE_NUMERIC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ParseNumeric'>>, 'PARSE_TIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ParseTime'>>, 'PERCENT_RANK': <bound method Func.from_arg_list of <class 'sqlglot.expressions.PercentRank'>>, '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'>>, 'POSEXPLODE_OUTER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.PosexplodeOuter'>>, 'POWER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Pow'>>, 'POW': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Pow'>>, 'PREDICT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Predict'>>, 'QUANTILE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Quantile'>>, 'QUARTER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Quarter'>>, 'RAND': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Rand'>>, 'RANDOM': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Rand'>>, 'RANDN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Randn'>>, 'RANGE_BUCKET': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RangeBucket'>>, 'RANGE_N': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RangeN'>>, 'RANK': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Rank'>>, 'READ_CSV': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ReadCSV'>>, 'REDUCE': <function SingleStore.Parser.<lambda>>, 'REGEXP_EXTRACT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpExtract'>>, 'REGEXP_EXTRACT_ALL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpExtractAll'>>, 'REGEXP_I_LIKE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpILike'>>, 'REGEXP_INSTR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpInstr'>>, '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'>>, 'REPLACE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Replace'>>, 'REVERSE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Reverse'>>, '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_ADD': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SafeAdd'>>, 'SAFE_CONVERT_BYTES_TO_STRING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SafeConvertBytesToString'>>, 'SAFE_DIVIDE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SafeDivide'>>, 'SAFE_MULTIPLY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SafeMultiply'>>, 'SAFE_NEGATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SafeNegate'>>, 'SAFE_SUBTRACT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SafeSubtract'>>, 'SEC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Sec'>>, 'SECH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Sech'>>, 'SIGN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Sign'>>, 'SIGNUM': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Sign'>>, 'SIN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Sin'>>, 'SINH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Sinh'>>, 'SORT_ARRAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SortArray'>>, 'SOUNDEX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Soundex'>>, 'SPACE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Space'>>, 'SPLIT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Split'>>, 'SPLIT_PART': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SplitPart'>>, 'SQRT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Sqrt'>>, 'ST_DISTANCE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StDistance'>>, 'ST_POINT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StPoint'>>, 'ST_MAKEPOINT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StPoint'>>, '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'>>, 'STDEV': <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': <function build_formatted_time.<locals>._builder>, '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'>>, 'STRING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.String'>>, 'STRING_TO_ARRAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StringToArray'>>, 'SPLIT_BY_STRING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StringToArray'>>, 'STRTOK_TO_ARRAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StringToArray'>>, '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'>>, 'SUBSTR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Substring'>>, 'SUBSTRING_INDEX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SubstringIndex'>>, 'SUM': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Sum'>>, 'TIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Time'>>, '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_FROM_PARTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeFromParts'>>, 'TIMEFROMPARTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeFromParts'>>, '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'>>, 'TIMESTAMPDIFF': <function SingleStore.Parser.<lambda>>, 'TIMESTAMP_DIFF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimestampDiff'>>, 'TIMESTAMP_FROM_PARTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimestampFromParts'>>, 'TIMESTAMPFROMPARTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimestampFromParts'>>, '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_ARRAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ToArray'>>, 'TO_BASE32': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ToBase32'>>, 'TO_BASE64': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ToBase64'>>, 'TO_CHAR': <function build_formatted_time.<locals>._builder>, 'TO_CODE_POINTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ToCodePoints'>>, 'TO_DAYS': <function MySQL.Parser.<lambda>>, 'TO_DOUBLE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ToDouble'>>, 'TO_MAP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ToMap'>>, 'TO_NUMBER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ToNumber'>>, 'TRANSFORM': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Transform'>>, 'TRANSLATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Translate'>>, 'TRIM': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Trim'>>, 'TRY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Try'>>, '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_DIFF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TsOrDsDiff'>>, '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>>, 'TS_OR_DS_TO_DATETIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TsOrDsToDatetime'>>, 'TS_OR_DS_TO_TIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TsOrDsToTime'>>, 'TS_OR_DS_TO_TIMESTAMP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TsOrDsToTimestamp'>>, 'TYPEOF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Typeof'>>, 'UNHEX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Unhex'>>, 'UNICODE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Unicode'>>, 'UNIX_DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.UnixDate'>>, 'UNIX_MICROS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.UnixMicros'>>, 'UNIX_MILLIS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.UnixMillis'>>, 'UNIX_SECONDS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.UnixSeconds'>>, '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'>>, 'UNNEST': <function Parser.<lambda>>, 'UPPER': <function build_upper>, 'UCASE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Upper'>>, 'UTC_DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.UtcDate'>>, 'UTC_TIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.UtcTime'>>, 'UTC_TIMESTAMP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.UtcTimestamp'>>, 'UUID': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Uuid'>>, 'GEN_RANDOM_UUID': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Uuid'>>, 'GENERATE_UUID': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Uuid'>>, 'UUID_STRING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Uuid'>>, 'VAR_MAP': <function build_var_map>, 'VARIANCE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.VariancePop'>>, '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'>>, 'VECTOR_SEARCH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.VectorSearch'>>, 'WEEK': <function MySQL.Parser.<lambda>>, 'WEEK_OF_YEAR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.WeekOfYear'>>, 'WEEKOFYEAR': <function MySQL.Parser.<lambda>>, 'XMLELEMENT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.XMLElement'>>, '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': <function MySQL.Parser.<lambda>>, 'ARRAYAGG': <function Parser.<lambda>>, 'GLOB': <function Parser.<lambda>>, 'JSON_EXTRACT_PATH_TEXT': <function build_extract_json_with_path.<locals>._builder>, 'LIKE': <function build_like>, 'LOG2': <function Parser.<lambda>>, 'LOG10': <function Parser.<lambda>>, 'LPAD': <function Parser.<lambda>>, 'LEFTPAD': <function Parser.<lambda>>, 'LTRIM': <function Parser.<lambda>>, 'MOD': <function build_mod>, 'RIGHTPAD': <function Parser.<lambda>>, 'RPAD': <function Parser.<lambda>>, 'RTRIM': <function Parser.<lambda>>, 'SCOPE_RESOLUTION': <function Parser.<lambda>>, 'STRPOS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StrPosition'>>, 'CHARINDEX': <function Parser.<lambda>>, 'INSTR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Contains'>>, 'LOCATE': <function Parser.<lambda>>, 'TO_HEX': <function build_hex>, 'BIT_AND': <bound method Func.from_arg_list of <class 'sqlglot.expressions.BitwiseAndAgg'>>, 'BIT_OR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.BitwiseOrAgg'>>, 'BIT_XOR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.BitwiseXorAgg'>>, 'BIT_COUNT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.BitwiseCountAgg'>>, 'CONVERT_TZ': <function MySQL.Parser.<lambda>>, 'CURDATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CurrentDate'>>, 'DATE_FORMAT': <function build_formatted_time.<locals>._builder>, 'FROM_UNIXTIME': <function build_formatted_time.<locals>._builder>, 'ISNULL': <function isnull_to_is_null>, 'MAKETIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeFromParts'>>, 'MONTHNAME': <function SingleStore.Parser.<lambda>>, 'SCHEMA': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CurrentSchema'>>, 'DATABASE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CurrentSchema'>>, 'TO_DATE': <function build_formatted_time.<locals>._builder>, 'TO_TIMESTAMP': <function build_formatted_time.<locals>._builder>, 'TIME_FORMAT': <function SingleStore.Parser.<lambda>>, 'HOUR': <function SingleStore.Parser.<lambda>>, 'MICROSECOND': <function SingleStore.Parser.<lambda>>, 'SECOND': <function SingleStore.Parser.<lambda>>, 'MINUTE': <function SingleStore.Parser.<lambda>>, 'WEEKDAY': <function SingleStore.Parser.<lambda>>, 'UNIX_TIMESTAMP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StrToUnix'>>, 'TIME_BUCKET': <function SingleStore.Parser.<lambda>>, 'BSON_EXTRACT_BSON': <function build_json_extract_path.<locals>._builder>, 'BSON_EXTRACT_STRING': <function build_json_extract_path.<locals>._builder>, 'BSON_EXTRACT_DOUBLE': <function build_json_extract_path.<locals>._builder>, 'BSON_EXTRACT_BIGINT': <function build_json_extract_path.<locals>._builder>, 'JSON_EXTRACT_JSON': <function build_json_extract_path.<locals>._builder>, 'JSON_EXTRACT_STRING': <function build_json_extract_path.<locals>._builder>, 'JSON_EXTRACT_DOUBLE': <function build_json_extract_path.<locals>._builder>, 'JSON_EXTRACT_BIGINT': <function build_json_extract_path.<locals>._builder>, 'JSON_ARRAY_CONTAINS_STRING': <function SingleStore.Parser.<lambda>>, 'JSON_ARRAY_CONTAINS_DOUBLE': <function SingleStore.Parser.<lambda>>, 'JSON_ARRAY_CONTAINS_JSON': <function SingleStore.Parser.<lambda>>, 'JSON_PRETTY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONFormat'>>, 'JSON_BUILD_ARRAY': <function SingleStore.Parser.<lambda>>, 'JSON_BUILD_OBJECT': <function SingleStore.Parser.<lambda>>, 'DAYNAME': <function SingleStore.Parser.<lambda>>, 'APPROX_PERCENTILE': <function SingleStore.Parser.<lambda>>, 'REGEXP_MATCH': <function SingleStore.Parser.<lambda>>, 'REGEXP_SUBSTR': <function SingleStore.Parser.<lambda>>}
FUNCTION_PARSERS: Dict[str, Callable] = {'ARG_MAX': <function Parser.<dictcomp>.<lambda>>, 'ARGMAX': <function Parser.<dictcomp>.<lambda>>, 'MAX_BY': <function Parser.<dictcomp>.<lambda>>, 'ARG_MIN': <function Parser.<dictcomp>.<lambda>>, 'ARGMIN': <function Parser.<dictcomp>.<lambda>>, 'MIN_BY': <function Parser.<dictcomp>.<lambda>>, 'CAST': <function Parser.<lambda>>, 'CEIL': <function Parser.<lambda>>, 'CONVERT': <function Parser.<lambda>>, 'DECODE': <function Parser.<lambda>>, 'EXTRACT': <function Parser.<lambda>>, 'FLOOR': <function Parser.<lambda>>, 'GAP_FILL': <function Parser.<lambda>>, 'JSON_OBJECT': <function Parser.<lambda>>, 'JSON_OBJECTAGG': <function Parser.<lambda>>, 'JSON_TABLE': <function Parser.<lambda>>, 'MATCH': <function Parser.<lambda>>, 'NORMALIZE': <function Parser.<lambda>>, 'OPENJSON': <function Parser.<lambda>>, 'OVERLAY': <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>>, 'XMLELEMENT': <function Parser.<lambda>>, 'XMLTABLE': <function Parser.<lambda>>, 'CHAR': <function MySQL.Parser.<lambda>>, 'GROUP_CONCAT': <function MySQL.Parser.<lambda>>, 'VALUES': <function MySQL.Parser.<lambda>>, 'JSON_VALUE': <function MySQL.Parser.<lambda>>, 'JSON_AGG': <function SingleStore.Parser.<lambda>>}
NO_PAREN_FUNCTIONS = {<TokenType.CURRENT_DATE: 'CURRENT_DATE'>: <class 'sqlglot.expressions.CurrentDate'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>: <class 'sqlglot.expressions.CurrentDate'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>: <class 'sqlglot.expressions.CurrentTime'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>: <class 'sqlglot.expressions.CurrentTimestamp'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>: <class 'sqlglot.expressions.CurrentUser'>, <TokenType.UTC_DATE: 'UTC_DATE'>: <class 'sqlglot.expressions.UtcDate'>, <TokenType.UTC_TIME: 'UTC_TIME'>: <class 'sqlglot.expressions.UtcTime'>, <TokenType.UTC_TIMESTAMP: 'UTC_TIMESTAMP'>: <class 'sqlglot.expressions.UtcTimestamp'>}
CAST_COLUMN_OPERATORS = {<TokenType.NCOLON_GT: 'NCOLON_GT'>, <TokenType.COLON_GT: 'COLON_GT'>}
COLUMN_OPERATORS = {<TokenType.DOT: 'DOT'>: None, <TokenType.DOTCOLON: 'DOTCOLON'>: <function Parser.<lambda>>, <TokenType.DCOLON: 'DCOLON'>: <function SingleStore.Parser.<lambda>>, <TokenType.COLON_GT: 'COLON_GT'>: <function SingleStore.Parser.<lambda>>, <TokenType.NCOLON_GT: 'NCOLON_GT'>: <function SingleStore.Parser.<lambda>>, <TokenType.DCOLONDOLLAR: 'DCOLONDOLLAR'>: <function SingleStore.Parser.<lambda>>, <TokenType.DCOLONPERCENT: 'DCOLONPERCENT'>: <function SingleStore.Parser.<lambda>>}
TABLE_ALIAS_TOKENS = {<TokenType.MULTIPOLYGON: 'MULTIPOLYGON'>, <TokenType.TABLE: 'TABLE'>, <TokenType.ASC: 'ASC'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.SOME: 'SOME'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.MODEL: 'MODEL'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.DECIMAL32: 'DECIMAL32'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.UUID: 'UUID'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.ESCAPE: 'ESCAPE'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.JSON: 'JSON'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.LIMIT: 'LIMIT'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.DECIMAL128: 'DECIMAL128'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.TEXT: 'TEXT'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.DELETE: 'DELETE'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.SEMANTIC_VIEW: 'SEMANTIC_VIEW'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.IPV4: 'IPV4'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.VAR: 'VAR'>, <TokenType.SET: 'SET'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.CUBE: 'CUBE'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.COPY: 'COPY'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.NULL: 'NULL'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.FILTER: 'FILTER'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.VOID: 'VOID'>, <TokenType.NEXT: 'NEXT'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.UINT128: 'UINT128'>, <TokenType.FALSE: 'FALSE'>, <TokenType.LINESTRING: 'LINESTRING'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.BIT: 'BIT'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.ENUM: 'ENUM'>, <TokenType.SMALLDATETIME: 'SMALLDATETIME'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.ROW: 'ROW'>, <TokenType.NESTED: 'NESTED'>, <TokenType.INET: 'INET'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.FILE_FORMAT: 'FILE_FORMAT'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.DETACH: 'DETACH'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.PUT: 'PUT'>, <TokenType.NAME: 'NAME'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.XML: 'XML'>, <TokenType.UINT256: 'UINT256'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.SESSION: 'SESSION'>, <TokenType.DATE32: 'DATE32'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.VECTOR: 'VECTOR'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.WAREHOUSE: 'WAREHOUSE'>, <TokenType.APPLY: 'APPLY'>, <TokenType.TOP: 'TOP'>, <TokenType.CACHE: 'CACHE'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.MAP: 'MAP'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.KEEP: 'KEEP'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.INT128: 'INT128'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.DESC: 'DESC'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.RENAME: 'RENAME'>, <TokenType.CASE: 'CASE'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.LOAD: 'LOAD'>, <TokenType.STREAMLIT: 'STREAMLIT'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.OFFSET: 'OFFSET'>, <TokenType.DYNAMIC: 'DYNAMIC'>, <TokenType.DATETIME2: 'DATETIME2'>, <TokenType.MULTILINESTRING: 'MULTILINESTRING'>, <TokenType.GET: 'GET'>, <TokenType.POINT: 'POINT'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.POLYGON: 'POLYGON'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.TAG: 'TAG'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.UINT: 'UINT'>, <TokenType.CHAR: 'CHAR'>, <TokenType.RING: 'RING'>, <TokenType.IPV6: 'IPV6'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.GEOGRAPHYPOINT: 'GEOGRAPHYPOINT'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.SOURCE: 'SOURCE'>, <TokenType.INDEX: 'INDEX'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.DECIMAL256: 'DECIMAL256'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.DATE: 'DATE'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.RANGE: 'RANGE'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.TRUE: 'TRUE'>, <TokenType.NOTHING: 'NOTHING'>, <TokenType.SEMI: 'SEMI'>, <TokenType.ALL: 'ALL'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.MERGE: 'MERGE'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.SUPER: 'SUPER'>, <TokenType.YEAR: 'YEAR'>, <TokenType.UPDATE: 'UPDATE'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.STAGE: 'STAGE'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.ROWS: 'ROWS'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.UDOUBLE: 'UDOUBLE'>, <TokenType.ANTI: 'ANTI'>, <TokenType.FINAL: 'FINAL'>, <TokenType.LIST: 'LIST'>, <TokenType.SINK: 'SINK'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.NAMESPACE: 'NAMESPACE'>, <TokenType.EXPORT: 'EXPORT'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.BLOB: 'BLOB'>, <TokenType.VIEW: 'VIEW'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.JSONB: 'JSONB'>, <TokenType.FIRST: 'FIRST'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.SHOW: 'SHOW'>, <TokenType.INT256: 'INT256'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.DIV: 'DIV'>, <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.IS: 'IS'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.ROLLUP: 'ROLLUP'>, <TokenType.END: 'END'>, <TokenType.ANY: 'ANY'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.ATTACH: 'ATTACH'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.BINARY: 'BINARY'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.INT: 'INT'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.CURRENT_SCHEMA: 'CURRENT_SCHEMA'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.TIME: 'TIME'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.KILL: 'KILL'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.COMMENT: 'COMMENT'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.MONEY: 'MONEY'>, <TokenType.DECIMAL64: 'DECIMAL64'>, <TokenType.PROCEDURE: 'PROCEDURE'>}
ID_VAR_TOKENS = {<TokenType.MULTIPOLYGON: 'MULTIPOLYGON'>, <TokenType.TABLE: 'TABLE'>, <TokenType.ASC: 'ASC'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.SOME: 'SOME'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.MODEL: 'MODEL'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.DECIMAL32: 'DECIMAL32'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.UUID: 'UUID'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.ESCAPE: 'ESCAPE'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.JSON: 'JSON'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.LIMIT: 'LIMIT'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.DECIMAL128: 'DECIMAL128'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.TEXT: 'TEXT'>, <TokenType.FULL: 'FULL'>, <TokenType.DELETE: 'DELETE'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.SEMANTIC_VIEW: 'SEMANTIC_VIEW'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.IPV4: 'IPV4'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.VAR: 'VAR'>, <TokenType.SET: 'SET'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.CUBE: 'CUBE'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.COPY: 'COPY'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.NULL: 'NULL'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.FILTER: 'FILTER'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.VOID: 'VOID'>, <TokenType.NEXT: 'NEXT'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.UINT128: 'UINT128'>, <TokenType.FALSE: 'FALSE'>, <TokenType.LINESTRING: 'LINESTRING'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.BIT: 'BIT'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.ENUM: 'ENUM'>, <TokenType.SMALLDATETIME: 'SMALLDATETIME'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.ROW: 'ROW'>, <TokenType.NESTED: 'NESTED'>, <TokenType.INET: 'INET'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.FILE_FORMAT: 'FILE_FORMAT'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.DETACH: 'DETACH'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.PUT: 'PUT'>, <TokenType.NAME: 'NAME'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.XML: 'XML'>, <TokenType.UINT256: 'UINT256'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.SESSION: 'SESSION'>, <TokenType.DATE32: 'DATE32'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.VECTOR: 'VECTOR'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.WAREHOUSE: 'WAREHOUSE'>, <TokenType.APPLY: 'APPLY'>, <TokenType.TOP: 'TOP'>, <TokenType.CACHE: 'CACHE'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.MAP: 'MAP'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.KEEP: 'KEEP'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.INT128: 'INT128'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.DESC: 'DESC'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.RENAME: 'RENAME'>, <TokenType.CASE: 'CASE'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.LOAD: 'LOAD'>, <TokenType.STREAMLIT: 'STREAMLIT'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.OFFSET: 'OFFSET'>, <TokenType.DYNAMIC: 'DYNAMIC'>, <TokenType.DATETIME2: 'DATETIME2'>, <TokenType.MULTILINESTRING: 'MULTILINESTRING'>, <TokenType.GET: 'GET'>, <TokenType.POINT: 'POINT'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.POLYGON: 'POLYGON'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.TAG: 'TAG'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.UINT: 'UINT'>, <TokenType.CHAR: 'CHAR'>, <TokenType.RING: 'RING'>, <TokenType.IPV6: 'IPV6'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.GEOGRAPHYPOINT: 'GEOGRAPHYPOINT'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.SOURCE: 'SOURCE'>, <TokenType.INDEX: 'INDEX'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.DECIMAL256: 'DECIMAL256'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.DATE: 'DATE'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.RANGE: 'RANGE'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.LEFT: 'LEFT'>, <TokenType.TRUE: 'TRUE'>, <TokenType.NOTHING: 'NOTHING'>, <TokenType.SEMI: 'SEMI'>, <TokenType.ALL: 'ALL'>, <TokenType.RIGHT: 'RIGHT'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.MERGE: 'MERGE'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.SUPER: 'SUPER'>, <TokenType.YEAR: 'YEAR'>, <TokenType.UPDATE: 'UPDATE'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.STAGE: 'STAGE'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.ROWS: 'ROWS'>, <TokenType.ANTI: 'ANTI'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.UDOUBLE: 'UDOUBLE'>, <TokenType.FINAL: 'FINAL'>, <TokenType.LIST: 'LIST'>, <TokenType.SINK: 'SINK'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.NAMESPACE: 'NAMESPACE'>, <TokenType.EXPORT: 'EXPORT'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.BLOB: 'BLOB'>, <TokenType.VIEW: 'VIEW'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.JSONB: 'JSONB'>, <TokenType.FIRST: 'FIRST'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.SHOW: 'SHOW'>, <TokenType.INT256: 'INT256'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.DIV: 'DIV'>, <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.IS: 'IS'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.ROLLUP: 'ROLLUP'>, <TokenType.USE: 'USE'>, <TokenType.END: 'END'>, <TokenType.ANY: 'ANY'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.ATTACH: 'ATTACH'>, <TokenType.ASOF: 'ASOF'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.BINARY: 'BINARY'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.WINDOW: 'WINDOW'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.INT: 'INT'>, <TokenType.CURRENT_SCHEMA: 'CURRENT_SCHEMA'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.TIME: 'TIME'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.KILL: 'KILL'>, <TokenType.NATURAL: 'NATURAL'>, <TokenType.COMMENT: 'COMMENT'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.MONEY: 'MONEY'>, <TokenType.DECIMAL64: 'DECIMAL64'>, <TokenType.PROCEDURE: 'PROCEDURE'>}
SHOW_TRIE: Dict = {'BINARY': {'LOGS': {0: True}}, 'MASTER': {'LOGS': {0: True}, 'STATUS': {0: True}}, 'BINLOG': {'EVENTS': {0: True}}, 'CHARACTER': {'SET': {0: True}}, 'CHARSET': {0: True}, 'COLLATION': {0: True}, 'FULL': {'COLUMNS': {0: True}, 'PROCESSLIST': {0: True}, 'TABLES': {0: True}}, 'COLUMNS': {0: True}, 'CREATE': {'DATABASE': {0: True}, 'EVENT': {0: True}, 'FUNCTION': {0: True}, 'PROCEDURE': {0: True}, 'TABLE': {0: True}, 'TRIGGER': {0: True}, 'VIEW': {0: True}}, 'DATABASES': {0: True}, 'SCHEMAS': {0: True}, 'ENGINE': {0: True}, 'STORAGE': {'ENGINES': {0: True}}, 'ENGINES': {0: True}, 'ERRORS': {0: True}, 'EVENTS': {0: True}, 'FUNCTION': {'CODE': {0: True}, 'STATUS': {0: True}}, 'GRANTS': {0: True}, 'INDEX': {0: True}, 'OPEN': {'TABLES': {0: True}}, 'PLUGINS': {0: True}, 'PROCEDURE': {'CODE': {0: True}, 'STATUS': {0: True}}, 'PRIVILEGES': {0: True}, 'PROCESSLIST': {0: True}, 'PROFILE': {0: True}, 'PROFILES': {0: True}, 'RELAYLOG': {'EVENTS': {0: True}}, 'REPLICAS': {0: True}, 'SLAVE': {'HOSTS': {0: True}, 'STATUS': {0: True}}, 'REPLICA': {'STATUS': {0: True}}, 'GLOBAL': {'STATUS': {0: True}, 'VARIABLES': {0: True}}, 'SESSION': {'STATUS': {0: True}, 'VARIABLES': {0: True}}, 'STATUS': {0: True}, 'TABLE': {'STATUS': {0: True}}, 'TABLES': {0: True}, 'TRIGGERS': {0: True}, 'VARIABLES': {0: True}, 'WARNINGS': {0: True}}
SET_TRIE: Dict = {'GLOBAL': {0: True}, 'LOCAL': {0: True}, 'SESSION': {0: True}, 'TRANSACTION': {0: True}, 'PERSIST': {0: True}, 'PERSIST_ONLY': {0: True}, 'CHARACTER': {'SET': {0: True}}, 'CHARSET': {0: True}, 'NAMES': {0: True}}
Inherited Members
sqlglot.parser.Parser
Parser
STRUCT_TYPE_TOKENS
NESTED_TYPE_TOKENS
AGGREGATE_TYPE_TOKENS
SIGNED_TO_UNSIGNED_TYPE_TOKEN
SUBQUERY_PREDICATES
RESERVED_TOKENS
DB_CREATABLES
CREATABLES
ALTERABLES
ALIAS_TOKENS
COLON_PLACEHOLDER_TOKENS
ARRAY_CONSTRUCTORS
COMMENT_TABLE_ALIAS_TOKENS
UPDATE_ALIAS_TOKENS
TRIM_TYPES
ASSIGNMENT
EQUALITY
COMPARISON
BITWISE
TERM
FACTOR
EXPONENT
TIMES
TIMESTAMPS
SET_OPERATIONS
JOIN_METHODS
JOIN_SIDES
JOIN_KINDS
JOIN_HINTS
LAMBDAS
EXPRESSION_PARSERS
UNARY_PARSERS
STRING_PARSERS
NUMERIC_PARSERS
PRIMARY_PARSERS
PLACEHOLDER_PARSERS
PIPE_SYNTAX_TRANSFORM_PARSERS
NO_PAREN_FUNCTION_PARSERS
INVALID_FUNC_NAME_TOKENS
FUNCTIONS_WITH_ALIASED_ARGS
KEY_VALUE_DEFINITIONS
QUERY_MODIFIER_PARSERS
QUERY_MODIFIER_TOKENS
TYPE_LITERAL_PARSERS
TYPE_CONVERTERS
DDL_SELECT_TOKENS
PRE_VOLATILE_TOKENS
TRANSACTION_KIND
TRANSACTION_CHARACTERISTICS
CONFLICT_ACTIONS
CREATE_SEQUENCE
ISOLATED_LOADING_OPTIONS
USABLES
CAST_ACTIONS
SCHEMA_BINDING_OPTIONS
PROCEDURE_OPTIONS
EXECUTE_AS_OPTIONS
KEY_CONSTRAINT_OPTIONS
WINDOW_EXCLUDE_OPTIONS
INSERT_ALTERNATIVES
CLONE_KEYWORDS
HISTORICAL_DATA_PREFIX
HISTORICAL_DATA_KIND
OPCLASS_FOLLOW_KEYWORDS
OPTYPE_FOLLOW_TOKENS
TABLE_INDEX_HINT_TOKENS
VIEW_ATTRIBUTES
WINDOW_ALIAS_TOKENS
WINDOW_BEFORE_PAREN_TOKENS
WINDOW_SIDES
JSON_KEY_VALUE_SEPARATOR_TOKENS
FETCH_TOKENS
ADD_CONSTRAINT_TOKENS
DISTINCT_TOKENS
NULL_TOKENS
UNNEST_OFFSET_ALIAS_TOKENS
SELECT_START_TOKENS
COPY_INTO_VARLEN_OPTIONS
IS_JSON_PREDICATE_KIND
ODBC_DATETIME_LITERALS
ON_CONDITION_TOKENS
PRIVILEGE_FOLLOW_TOKENS
DESCRIBE_STYLES
ANALYZE_STYLES
ANALYZE_EXPRESSION_PARSERS
PARTITION_KEYWORDS
AMBIGUOUS_ALIAS_TOKENS
RECURSIVE_CTE_SEARCH_KIND
MODIFIABLES
STRICT_CAST
PREFIXED_PIVOT_COLUMNS
IDENTIFY_PIVOT_STRINGS
TABLESAMPLE_CSV
DEFAULT_SAMPLING_METHOD
SET_REQUIRES_ASSIGNMENT_DELIMITER
TRIM_PATTERN_FIRST
MODIFIERS_ATTACHED_TO_SET_OP
SET_OP_MODIFIERS
NO_PAREN_IF_COMMANDS
JSON_ARROWS_REQUIRE_JSON_TYPE
COLON_IS_VARIANT_EXTRACT
SUPPORTS_IMPLICIT_UNNEST
INTERVAL_SPANS
WRAPPED_TRANSFORM_COLUMN_CONSTRAINT
OPTIONAL_ALIAS_TOKEN_CTE
ALTER_RENAME_REQUIRES_COLUMN
JOINS_HAVE_EQUAL_PRECEDENCE
ZONE_AWARE_TIMESTAMP_CONSTRUCTOR
MAP_KEYS_ARE_ARBITRARY_EXPRESSIONS
JSON_EXTRACT_REQUIRES_JSON_EXPRESSION
error_level
error_message_context
max_errors
dialect
reset
parse
parse_into
check_errors
raise_error
expression
validate_expression
parse_set_operation
build_cast
errors
sql
sqlglot.dialects.mysql.MySQL.Parser
FUNC_TOKENS
CONJUNCTION
DISJUNCTION
RANGE_PARSERS
STATEMENT_PARSERS
SHOW_PARSERS
PROPERTY_PARSERS
SET_PARSERS
CONSTRAINT_PARSERS
ALTER_PARSERS
ALTER_ALTER_PARSERS
SCHEMA_UNNAMED_CONSTRAINTS
PROFILE_TYPES
TYPE_TOKENS
ENUM_TYPE_TOKENS
OPERATION_MODIFIERS
LOG_DEFAULTS_TO_LN
STRING_ALIASES
VALUES_FOLLOWED_BY_PAREN
SUPPORTS_PARTITION_SELECTION
class SingleStore.Generator(sqlglot.dialects.mysql.MySQL.Generator):
 253    class Generator(MySQL.Generator):
 254        SUPPORTS_UESCAPE = False
 255        NULL_ORDERING_SUPPORTED = True
 256        MATCH_AGAINST_TABLE_PREFIX = "TABLE "
 257
 258        @staticmethod
 259        def _unicode_substitute(m: re.Match[str]) -> str:
 260            # Interpret the number as hex and convert it to the Unicode string
 261            return chr(int(m.group(1), 16))
 262
 263        UNICODE_SUBSTITUTE: t.Optional[t.Callable[[re.Match[str]], str]] = _unicode_substitute
 264
 265        SUPPORTED_JSON_PATH_PARTS = {
 266            exp.JSONPathKey,
 267            exp.JSONPathRoot,
 268            exp.JSONPathSubscript,
 269        }
 270
 271        TRANSFORMS = {
 272            **MySQL.Generator.TRANSFORMS,
 273            exp.TsOrDsToDate: lambda self, e: self.func("TO_DATE", e.this, self.format_time(e))
 274            if e.args.get("format")
 275            else self.func("DATE", e.this),
 276            exp.StrToTime: lambda self, e: self.func("TO_TIMESTAMP", e.this, self.format_time(e)),
 277            exp.ToChar: lambda self, e: self.func("TO_CHAR", e.this, self.format_time(e)),
 278            exp.StrToDate: lambda self, e: self.func(
 279                "STR_TO_DATE",
 280                e.this,
 281                self.format_time(
 282                    e,
 283                    inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING,
 284                    inverse_time_trie=MySQL.INVERSE_TIME_TRIE,
 285                ),
 286            ),
 287            exp.TimeToStr: lambda self, e: self.func(
 288                "DATE_FORMAT",
 289                e.this,
 290                self.format_time(
 291                    e,
 292                    inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING,
 293                    inverse_time_trie=MySQL.INVERSE_TIME_TRIE,
 294                ),
 295            ),
 296            exp.Date: unsupported_args("zone", "expressions")(rename_func("DATE")),
 297            exp.Cast: unsupported_args("format", "action", "default")(
 298                lambda self, e: f"{self.sql(e, 'this')} :> {self.sql(e, 'to')}"
 299            ),
 300            exp.TryCast: unsupported_args("format", "action", "default")(
 301                lambda self, e: f"{self.sql(e, 'this')} !:> {self.sql(e, 'to')}"
 302            ),
 303            exp.CastToStrType: lambda self, e: self.sql(
 304                exp.cast(e.this, DataType.build(e.args["to"].name))
 305            ),
 306            exp.StrToUnix: unsupported_args("format")(rename_func("UNIX_TIMESTAMP")),
 307            exp.TimeToUnix: rename_func("UNIX_TIMESTAMP"),
 308            exp.TimeStrToUnix: rename_func("UNIX_TIMESTAMP"),
 309            exp.UnixSeconds: rename_func("UNIX_TIMESTAMP"),
 310            exp.UnixToStr: lambda self, e: self.func(
 311                "FROM_UNIXTIME",
 312                e.this,
 313                self.format_time(
 314                    e,
 315                    inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING,
 316                    inverse_time_trie=MySQL.INVERSE_TIME_TRIE,
 317                ),
 318            ),
 319            exp.UnixToTime: unsupported_args("scale", "zone", "hours", "minutes")(
 320                lambda self, e: self.func(
 321                    "FROM_UNIXTIME",
 322                    e.this,
 323                    self.format_time(
 324                        e,
 325                        inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING,
 326                        inverse_time_trie=MySQL.INVERSE_TIME_TRIE,
 327                    ),
 328                ),
 329            ),
 330            exp.UnixToTimeStr: lambda self, e: f"FROM_UNIXTIME({self.sql(e, 'this')}) :> TEXT",
 331            exp.DateBin: unsupported_args("unit", "zone")(
 332                lambda self, e: self.func("TIME_BUCKET", e.this, e.expression, e.args.get("origin"))
 333            ),
 334            exp.TimeStrToDate: lambda self, e: self.sql(exp.cast(e.this, exp.DataType.Type.DATE)),
 335            exp.FromTimeZone: lambda self, e: self.func(
 336                "CONVERT_TZ", e.this, e.args.get("zone"), "'UTC'"
 337            ),
 338            exp.DiToDate: lambda self,
 339            e: f"STR_TO_DATE({self.sql(e, 'this')}, {SingleStore.DATEINT_FORMAT})",
 340            exp.DateToDi: lambda self,
 341            e: f"(DATE_FORMAT({self.sql(e, 'this')}, {SingleStore.DATEINT_FORMAT}) :> INT)",
 342            exp.TsOrDiToDi: lambda self,
 343            e: f"(DATE_FORMAT({self.sql(e, 'this')}, {SingleStore.DATEINT_FORMAT}) :> INT)",
 344            exp.Time: unsupported_args("zone")(lambda self, e: f"{self.sql(e, 'this')} :> TIME"),
 345            exp.DatetimeAdd: _remove_ts_or_ds_to_date(date_add_sql("ADD")),
 346            exp.DatetimeTrunc: unsupported_args("zone")(timestamptrunc_sql()),
 347            exp.DatetimeSub: date_add_interval_sql("DATE", "SUB"),
 348            exp.DatetimeDiff: timestampdiff_sql,
 349            exp.DateTrunc: unsupported_args("zone")(timestamptrunc_sql()),
 350            exp.DateDiff: unsupported_args("zone")(
 351                lambda self, e: timestampdiff_sql(self, e)
 352                if e.unit is not None
 353                else self.func("DATEDIFF", e.this, e.expression)
 354            ),
 355            exp.TsOrDsDiff: lambda self, e: timestampdiff_sql(self, e)
 356            if e.unit is not None
 357            else self.func("DATEDIFF", e.this, e.expression),
 358            exp.TimestampTrunc: unsupported_args("zone")(timestamptrunc_sql()),
 359            exp.CurrentDatetime: lambda self, e: self.sql(
 360                cast_to_time6(
 361                    exp.CurrentTimestamp(this=exp.Literal.number(6)), exp.DataType.Type.DATETIME
 362                )
 363            ),
 364            exp.JSONExtract: unsupported_args(
 365                "only_json_types",
 366                "expressions",
 367                "variant_extract",
 368                "json_query",
 369                "option",
 370                "quote",
 371                "on_condition",
 372                "requires_json",
 373            )(json_extract_segments("JSON_EXTRACT_JSON")),
 374            exp.JSONBExtract: json_extract_segments("BSON_EXTRACT_BSON"),
 375            exp.JSONPathKey: json_path_key_only_name,
 376            exp.JSONPathSubscript: lambda self, e: self.json_path_part(e.this),
 377            exp.JSONPathRoot: lambda *_: "",
 378            exp.JSONFormat: unsupported_args("options", "is_json")(rename_func("JSON_PRETTY")),
 379            exp.JSONArrayAgg: unsupported_args("null_handling", "return_type", "strict")(
 380                lambda self, e: self.func("JSON_AGG", e.this, suffix=f"{self.sql(e, 'order')})")
 381            ),
 382            exp.JSONArray: unsupported_args("null_handling", "return_type", "strict")(
 383                rename_func("JSON_BUILD_ARRAY")
 384            ),
 385            exp.JSONBExists: lambda self, e: self.func(
 386                "BSON_MATCH_ANY_EXISTS", e.this, e.args.get("path")
 387            ),
 388            exp.JSONExists: unsupported_args("passing", "on_condition")(
 389                lambda self, e: self.func("JSON_MATCH_ANY_EXISTS", e.this, e.args.get("path"))
 390            ),
 391            exp.JSONObject: unsupported_args(
 392                "null_handling", "unique_keys", "return_type", "encoding"
 393            )(rename_func("JSON_BUILD_OBJECT")),
 394            exp.DayOfWeekIso: lambda self, e: f"(({self.func('DAYOFWEEK', e.this)} % 7) + 1)",
 395            exp.DayOfMonth: rename_func("DAY"),
 396            exp.Hll: rename_func("APPROX_COUNT_DISTINCT"),
 397            exp.ApproxDistinct: rename_func("APPROX_COUNT_DISTINCT"),
 398            exp.CountIf: count_if_to_sum,
 399            exp.LogicalOr: lambda self, e: f"MAX(ABS({self.sql(e, 'this')}))",
 400            exp.LogicalAnd: lambda self, e: f"MIN(ABS({self.sql(e, 'this')}))",
 401            exp.ApproxQuantile: unsupported_args("accuracy", "weight")(
 402                lambda self, e: self.func(
 403                    "APPROX_PERCENTILE",
 404                    e.this,
 405                    e.args.get("quantile"),
 406                    e.args.get("error_tolerance"),
 407                )
 408            ),
 409            exp.Variance: rename_func("VAR_SAMP"),
 410            exp.VariancePop: rename_func("VAR_POP"),
 411            exp.Xor: bool_xor_sql,
 412            exp.Cbrt: lambda self, e: self.sql(
 413                exp.Pow(this=e.this, expression=exp.Literal.number(1) / exp.Literal.number(3))
 414            ),
 415            exp.RegexpLike: lambda self, e: self.binary(e, "RLIKE"),
 416            exp.Repeat: lambda self, e: self.func(
 417                "LPAD",
 418                exp.Literal.string(""),
 419                exp.Mul(this=self.func("LENGTH", e.this), expression=e.args.get("times")),
 420                e.this,
 421            ),
 422            exp.IsAscii: lambda self, e: f"({self.sql(e, 'this')} RLIKE '^[\x00-\x7f]*$')",
 423            exp.MD5Digest: lambda self, e: self.func("UNHEX", self.func("MD5", e.this)),
 424            exp.Chr: rename_func("CHAR"),
 425            exp.Contains: rename_func("INSTR"),
 426            exp.RegexpExtractAll: unsupported_args("position", "occurrence", "group")(
 427                lambda self, e: self.func(
 428                    "REGEXP_MATCH",
 429                    e.this,
 430                    e.expression,
 431                    e.args.get("parameters"),
 432                )
 433            ),
 434            exp.RegexpExtract: unsupported_args("group")(
 435                lambda self, e: self.func(
 436                    "REGEXP_SUBSTR",
 437                    e.this,
 438                    e.expression,
 439                    e.args.get("position"),
 440                    e.args.get("occurrence"),
 441                    e.args.get("parameters"),
 442                )
 443            ),
 444            exp.StartsWith: lambda self, e: self.func(
 445                "REGEXP_INSTR", e.this, self.func("CONCAT", exp.Literal.string("^"), e.expression)
 446            ),
 447            exp.FromBase: lambda self, e: self.func(
 448                "CONV", e.this, e.expression, exp.Literal.number(10)
 449            ),
 450            exp.RegexpILike: lambda self, e: self.binary(
 451                exp.RegexpLike(
 452                    this=exp.Lower(this=e.this),
 453                    expression=exp.Lower(this=e.expression),
 454                ),
 455                "RLIKE",
 456            ),
 457            exp.Stuff: lambda self, e: self.func(
 458                "CONCAT",
 459                self.func("SUBSTRING", e.this, exp.Literal.number(1), e.args.get("start") - 1),
 460                e.expression,
 461                self.func("SUBSTRING", e.this, e.args.get("start") + e.args.get("length")),
 462            ),
 463            exp.Reduce: unsupported_args("finish")(
 464                lambda self, e: self.func(
 465                    "REDUCE", e.args.get("initial"), e.this, e.args.get("merge")
 466                )
 467            ),
 468            exp.MatchAgainst: unsupported_args("modifier")(
 469                lambda self, e: super().matchagainst_sql(e)
 470            ),
 471        }
 472        TRANSFORMS.pop(exp.JSONExtractScalar)
 473        TRANSFORMS.pop(exp.CurrentDate)
 474
 475        UNSUPPORTED_TYPES = {
 476            exp.DataType.Type.ARRAY,
 477            exp.DataType.Type.AGGREGATEFUNCTION,
 478            exp.DataType.Type.SIMPLEAGGREGATEFUNCTION,
 479            exp.DataType.Type.BIGSERIAL,
 480            exp.DataType.Type.BPCHAR,
 481            exp.DataType.Type.DATEMULTIRANGE,
 482            exp.DataType.Type.DATERANGE,
 483            exp.DataType.Type.DYNAMIC,
 484            exp.DataType.Type.HLLSKETCH,
 485            exp.DataType.Type.HSTORE,
 486            exp.DataType.Type.IMAGE,
 487            exp.DataType.Type.INET,
 488            exp.DataType.Type.INT128,
 489            exp.DataType.Type.INT256,
 490            exp.DataType.Type.INT4MULTIRANGE,
 491            exp.DataType.Type.INT4RANGE,
 492            exp.DataType.Type.INT8MULTIRANGE,
 493            exp.DataType.Type.INT8RANGE,
 494            exp.DataType.Type.INTERVAL,
 495            exp.DataType.Type.IPADDRESS,
 496            exp.DataType.Type.IPPREFIX,
 497            exp.DataType.Type.IPV4,
 498            exp.DataType.Type.IPV6,
 499            exp.DataType.Type.LIST,
 500            exp.DataType.Type.MAP,
 501            exp.DataType.Type.LOWCARDINALITY,
 502            exp.DataType.Type.MONEY,
 503            exp.DataType.Type.MULTILINESTRING,
 504            exp.DataType.Type.NAME,
 505            exp.DataType.Type.NESTED,
 506            exp.DataType.Type.NOTHING,
 507            exp.DataType.Type.NULL,
 508            exp.DataType.Type.NUMMULTIRANGE,
 509            exp.DataType.Type.NUMRANGE,
 510            exp.DataType.Type.OBJECT,
 511            exp.DataType.Type.RANGE,
 512            exp.DataType.Type.ROWVERSION,
 513            exp.DataType.Type.SERIAL,
 514            exp.DataType.Type.SMALLSERIAL,
 515            exp.DataType.Type.SMALLMONEY,
 516            exp.DataType.Type.STRUCT,
 517            exp.DataType.Type.SUPER,
 518            exp.DataType.Type.TIMETZ,
 519            exp.DataType.Type.TIMESTAMPNTZ,
 520            exp.DataType.Type.TIMESTAMPLTZ,
 521            exp.DataType.Type.TIMESTAMPTZ,
 522            exp.DataType.Type.TIMESTAMP_NS,
 523            exp.DataType.Type.TSMULTIRANGE,
 524            exp.DataType.Type.TSRANGE,
 525            exp.DataType.Type.TSTZMULTIRANGE,
 526            exp.DataType.Type.TSTZRANGE,
 527            exp.DataType.Type.UINT128,
 528            exp.DataType.Type.UINT256,
 529            exp.DataType.Type.UNION,
 530            exp.DataType.Type.UNKNOWN,
 531            exp.DataType.Type.USERDEFINED,
 532            exp.DataType.Type.UUID,
 533            exp.DataType.Type.VARIANT,
 534            exp.DataType.Type.XML,
 535            exp.DataType.Type.TDIGEST,
 536        }
 537
 538        TYPE_MAPPING = {
 539            **MySQL.Generator.TYPE_MAPPING,
 540            exp.DataType.Type.BIGDECIMAL: "DECIMAL",
 541            exp.DataType.Type.BIT: "BOOLEAN",
 542            exp.DataType.Type.DATE32: "DATE",
 543            exp.DataType.Type.DATETIME64: "DATETIME",
 544            exp.DataType.Type.DECIMAL32: "DECIMAL",
 545            exp.DataType.Type.DECIMAL64: "DECIMAL",
 546            exp.DataType.Type.DECIMAL128: "DECIMAL",
 547            exp.DataType.Type.DECIMAL256: "DECIMAL",
 548            exp.DataType.Type.ENUM8: "ENUM",
 549            exp.DataType.Type.ENUM16: "ENUM",
 550            exp.DataType.Type.FIXEDSTRING: "TEXT",
 551            exp.DataType.Type.GEOMETRY: "GEOGRAPHY",
 552            exp.DataType.Type.POINT: "GEOGRAPHYPOINT",
 553            exp.DataType.Type.RING: "GEOGRAPHY",
 554            exp.DataType.Type.LINESTRING: "GEOGRAPHY",
 555            exp.DataType.Type.POLYGON: "GEOGRAPHY",
 556            exp.DataType.Type.MULTIPOLYGON: "GEOGRAPHY",
 557            exp.DataType.Type.JSONB: "BSON",
 558            exp.DataType.Type.TIMESTAMP: "TIMESTAMP",
 559            exp.DataType.Type.TIMESTAMP_S: "TIMESTAMP",
 560            exp.DataType.Type.TIMESTAMP_MS: "TIMESTAMP(6)",
 561        }
 562
 563        # https://docs.singlestore.com/cloud/reference/sql-reference/restricted-keywords/list-of-restricted-keywords/
 564        RESERVED_KEYWORDS = {
 565            "abs",
 566            "absolute",
 567            "access",
 568            "account",
 569            "acos",
 570            "action",
 571            "add",
 572            "adddate",
 573            "addtime",
 574            "admin",
 575            "aes_decrypt",
 576            "aes_encrypt",
 577            "after",
 578            "against",
 579            "aggregate",
 580            "aggregates",
 581            "aggregator",
 582            "aggregator_id",
 583            "aggregator_plan_hash",
 584            "aggregators",
 585            "algorithm",
 586            "all",
 587            "also",
 588            "alter",
 589            "always",
 590            "analyse",
 591            "analyze",
 592            "and",
 593            "anti_join",
 594            "any",
 595            "any_value",
 596            "approx_count_distinct",
 597            "approx_count_distinct_accumulate",
 598            "approx_count_distinct_combine",
 599            "approx_count_distinct_estimate",
 600            "approx_geography_intersects",
 601            "approx_percentile",
 602            "arghistory",
 603            "arrange",
 604            "arrangement",
 605            "array",
 606            "as",
 607            "asc",
 608            "ascii",
 609            "asensitive",
 610            "asin",
 611            "asm",
 612            "assertion",
 613            "assignment",
 614            "ast",
 615            "asymmetric",
 616            "async",
 617            "at",
 618            "atan",
 619            "atan2",
 620            "attach",
 621            "attribute",
 622            "authorization",
 623            "auto",
 624            "auto_increment",
 625            "auto_reprovision",
 626            "autostats",
 627            "autostats_cardinality_mode",
 628            "autostats_enabled",
 629            "autostats_histogram_mode",
 630            "autostats_sampling",
 631            "availability",
 632            "avg",
 633            "avg_row_length",
 634            "avro",
 635            "azure",
 636            "background",
 637            "_background_threads_for_cleanup",
 638            "backup",
 639            "backup_history",
 640            "backup_id",
 641            "backward",
 642            "batch",
 643            "batches",
 644            "batch_interval",
 645            "_batch_size_limit",
 646            "before",
 647            "begin",
 648            "between",
 649            "bigint",
 650            "bin",
 651            "binary",
 652            "_binary",
 653            "bit",
 654            "bit_and",
 655            "bit_count",
 656            "bit_or",
 657            "bit_xor",
 658            "blob",
 659            "bool",
 660            "boolean",
 661            "bootstrap",
 662            "both",
 663            "_bt",
 664            "btree",
 665            "bucket_count",
 666            "by",
 667            "byte",
 668            "byte_length",
 669            "cache",
 670            "call",
 671            "call_for_pipeline",
 672            "called",
 673            "capture",
 674            "cascade",
 675            "cascaded",
 676            "case",
 677            "cast",
 678            "catalog",
 679            "ceil",
 680            "ceiling",
 681            "chain",
 682            "change",
 683            "char",
 684            "character",
 685            "characteristics",
 686            "character_length",
 687            "char_length",
 688            "charset",
 689            "check",
 690            "checkpoint",
 691            "_check_can_connect",
 692            "_check_consistency",
 693            "checksum",
 694            "_checksum",
 695            "class",
 696            "clear",
 697            "client",
 698            "client_found_rows",
 699            "close",
 700            "cluster",
 701            "clustered",
 702            "cnf",
 703            "coalesce",
 704            "coercibility",
 705            "collate",
 706            "collation",
 707            "collect",
 708            "column",
 709            "columnar",
 710            "columns",
 711            "columnstore",
 712            "columnstore_segment_rows",
 713            "comment",
 714            "comments",
 715            "commit",
 716            "committed",
 717            "_commit_log_tail",
 718            "committed",
 719            "compact",
 720            "compile",
 721            "compressed",
 722            "compression",
 723            "concat",
 724            "concat_ws",
 725            "concurrent",
 726            "concurrently",
 727            "condition",
 728            "configuration",
 729            "connection",
 730            "connection_id",
 731            "connections",
 732            "config",
 733            "constraint",
 734            "constraints",
 735            "content",
 736            "continue",
 737            "_continue_replay",
 738            "conv",
 739            "conversion",
 740            "convert",
 741            "convert_tz",
 742            "copy",
 743            "_core",
 744            "cos",
 745            "cost",
 746            "cot",
 747            "count",
 748            "create",
 749            "credentials",
 750            "cross",
 751            "cube",
 752            "csv",
 753            "cume_dist",
 754            "curdate",
 755            "current",
 756            "current_catalog",
 757            "current_date",
 758            "current_role",
 759            "current_schema",
 760            "current_security_groups",
 761            "current_security_roles",
 762            "current_time",
 763            "current_timestamp",
 764            "current_user",
 765            "cursor",
 766            "curtime",
 767            "cycle",
 768            "data",
 769            "database",
 770            "databases",
 771            "date",
 772            "date_add",
 773            "datediff",
 774            "date_format",
 775            "date_sub",
 776            "date_trunc",
 777            "datetime",
 778            "day",
 779            "day_hour",
 780            "day_microsecond",
 781            "day_minute",
 782            "dayname",
 783            "dayofmonth",
 784            "dayofweek",
 785            "dayofyear",
 786            "day_second",
 787            "deallocate",
 788            "dec",
 789            "decimal",
 790            "declare",
 791            "decode",
 792            "default",
 793            "defaults",
 794            "deferrable",
 795            "deferred",
 796            "defined",
 797            "definer",
 798            "degrees",
 799            "delayed",
 800            "delay_key_write",
 801            "delete",
 802            "delimiter",
 803            "delimiters",
 804            "dense_rank",
 805            "desc",
 806            "describe",
 807            "detach",
 808            "deterministic",
 809            "dictionary",
 810            "differential",
 811            "directory",
 812            "disable",
 813            "discard",
 814            "_disconnect",
 815            "disk",
 816            "distinct",
 817            "distinctrow",
 818            "distributed_joins",
 819            "div",
 820            "do",
 821            "document",
 822            "domain",
 823            "dot_product",
 824            "double",
 825            "drop",
 826            "_drop_profile",
 827            "dual",
 828            "dump",
 829            "duplicate",
 830            "dynamic",
 831            "earliest",
 832            "each",
 833            "echo",
 834            "election",
 835            "else",
 836            "elseif",
 837            "elt",
 838            "enable",
 839            "enclosed",
 840            "encoding",
 841            "encrypted",
 842            "end",
 843            "engine",
 844            "engines",
 845            "enum",
 846            "errors",
 847            "escape",
 848            "escaped",
 849            "estimate",
 850            "euclidean_distance",
 851            "event",
 852            "events",
 853            "except",
 854            "exclude",
 855            "excluding",
 856            "exclusive",
 857            "execute",
 858            "exists",
 859            "exit",
 860            "exp",
 861            "explain",
 862            "extended",
 863            "extension",
 864            "external",
 865            "external_host",
 866            "external_port",
 867            "extract",
 868            "extractor",
 869            "extractors",
 870            "extra_join",
 871            "_failover",
 872            "failed_login_attempts",
 873            "failure",
 874            "false",
 875            "family",
 876            "fault",
 877            "fetch",
 878            "field",
 879            "fields",
 880            "file",
 881            "files",
 882            "fill",
 883            "first",
 884            "first_value",
 885            "fix_alter",
 886            "fixed",
 887            "float",
 888            "float4",
 889            "float8",
 890            "floor",
 891            "flush",
 892            "following",
 893            "for",
 894            "force",
 895            "force_compiled_mode",
 896            "force_interpreter_mode",
 897            "foreground",
 898            "foreign",
 899            "format",
 900            "forward",
 901            "found_rows",
 902            "freeze",
 903            "from",
 904            "from_base64",
 905            "from_days",
 906            "from_unixtime",
 907            "fs",
 908            "_fsync",
 909            "full",
 910            "fulltext",
 911            "function",
 912            "functions",
 913            "gc",
 914            "gcs",
 915            "get_format",
 916            "_gc",
 917            "_gcx",
 918            "generate",
 919            "geography",
 920            "geography_area",
 921            "geography_contains",
 922            "geography_distance",
 923            "geography_intersects",
 924            "geography_latitude",
 925            "geography_length",
 926            "geography_longitude",
 927            "geographypoint",
 928            "geography_point",
 929            "geography_within_distance",
 930            "geometry",
 931            "geometry_area",
 932            "geometry_contains",
 933            "geometry_distance",
 934            "geometry_filter",
 935            "geometry_intersects",
 936            "geometry_length",
 937            "geometrypoint",
 938            "geometry_point",
 939            "geometry_within_distance",
 940            "geometry_x",
 941            "geometry_y",
 942            "global",
 943            "_global_version_timestamp",
 944            "grant",
 945            "granted",
 946            "grants",
 947            "greatest",
 948            "group",
 949            "grouping",
 950            "groups",
 951            "group_concat",
 952            "gzip",
 953            "handle",
 954            "handler",
 955            "hard_cpu_limit_percentage",
 956            "hash",
 957            "has_temp_tables",
 958            "having",
 959            "hdfs",
 960            "header",
 961            "heartbeat_no_logging",
 962            "hex",
 963            "highlight",
 964            "high_priority",
 965            "hold",
 966            "holding",
 967            "host",
 968            "hosts",
 969            "hour",
 970            "hour_microsecond",
 971            "hour_minute",
 972            "hour_second",
 973            "identified",
 974            "identity",
 975            "if",
 976            "ifnull",
 977            "ignore",
 978            "ilike",
 979            "immediate",
 980            "immutable",
 981            "implicit",
 982            "import",
 983            "in",
 984            "including",
 985            "increment",
 986            "incremental",
 987            "index",
 988            "indexes",
 989            "inet_aton",
 990            "inet_ntoa",
 991            "inet6_aton",
 992            "inet6_ntoa",
 993            "infile",
 994            "inherit",
 995            "inherits",
 996            "_init_profile",
 997            "init",
 998            "initcap",
 999            "initialize",
1000            "initially",
1001            "inject",
1002            "inline",
1003            "inner",
1004            "inout",
1005            "input",
1006            "insensitive",
1007            "insert",
1008            "insert_method",
1009            "instance",
1010            "instead",
1011            "instr",
1012            "int",
1013            "int1",
1014            "int2",
1015            "int3",
1016            "int4",
1017            "int8",
1018            "integer",
1019            "_internal_dynamic_typecast",
1020            "interpreter_mode",
1021            "intersect",
1022            "interval",
1023            "into",
1024            "invoker",
1025            "is",
1026            "isnull",
1027            "isolation",
1028            "iterate",
1029            "join",
1030            "json",
1031            "json_agg",
1032            "json_array_contains_double",
1033            "json_array_contains_json",
1034            "json_array_contains_string",
1035            "json_array_push_double",
1036            "json_array_push_json",
1037            "json_array_push_string",
1038            "json_delete_key",
1039            "json_extract_double",
1040            "json_extract_json",
1041            "json_extract_string",
1042            "json_extract_bigint",
1043            "json_get_type",
1044            "json_length",
1045            "json_set_double",
1046            "json_set_json",
1047            "json_set_string",
1048            "json_splice_double",
1049            "json_splice_json",
1050            "json_splice_string",
1051            "kafka",
1052            "key",
1053            "key_block_size",
1054            "keys",
1055            "kill",
1056            "killall",
1057            "label",
1058            "lag",
1059            "language",
1060            "large",
1061            "last",
1062            "last_day",
1063            "last_insert_id",
1064            "last_value",
1065            "lateral",
1066            "latest",
1067            "lc_collate",
1068            "lc_ctype",
1069            "lcase",
1070            "lead",
1071            "leading",
1072            "leaf",
1073            "leakproof",
1074            "least",
1075            "leave",
1076            "leaves",
1077            "left",
1078            "length",
1079            "level",
1080            "license",
1081            "like",
1082            "limit",
1083            "lines",
1084            "listen",
1085            "llvm",
1086            "ln",
1087            "load",
1088            "loaddata_where",
1089            "_load",
1090            "local",
1091            "localtime",
1092            "localtimestamp",
1093            "locate",
1094            "location",
1095            "lock",
1096            "log",
1097            "log10",
1098            "log2",
1099            "long",
1100            "longblob",
1101            "longtext",
1102            "loop",
1103            "lower",
1104            "low_priority",
1105            "lpad",
1106            "_ls",
1107            "ltrim",
1108            "lz4",
1109            "management",
1110            "_management_thread",
1111            "mapping",
1112            "master",
1113            "match",
1114            "materialized",
1115            "max",
1116            "maxvalue",
1117            "max_concurrency",
1118            "max_errors",
1119            "max_partitions_per_batch",
1120            "max_queue_depth",
1121            "max_retries_per_batch_partition",
1122            "max_rows",
1123            "mbc",
1124            "md5",
1125            "mpl",
1126            "median",
1127            "mediumblob",
1128            "mediumint",
1129            "mediumtext",
1130            "member",
1131            "memory",
1132            "memory_percentage",
1133            "_memsql_table_id_lookup",
1134            "memsql",
1135            "memsql_deserialize",
1136            "memsql_imitating_kafka",
1137            "memsql_serialize",
1138            "merge",
1139            "metadata",
1140            "microsecond",
1141            "middleint",
1142            "min",
1143            "min_rows",
1144            "minus",
1145            "minute",
1146            "minute_microsecond",
1147            "minute_second",
1148            "minvalue",
1149            "mod",
1150            "mode",
1151            "model",
1152            "modifies",
1153            "modify",
1154            "month",
1155            "monthname",
1156            "months_between",
1157            "move",
1158            "mpl",
1159            "names",
1160            "named",
1161            "namespace",
1162            "national",
1163            "natural",
1164            "nchar",
1165            "next",
1166            "no",
1167            "node",
1168            "none",
1169            "no_query_rewrite",
1170            "noparam",
1171            "not",
1172            "nothing",
1173            "notify",
1174            "now",
1175            "nowait",
1176            "no_write_to_binlog",
1177            "no_query_rewrite",
1178            "norely",
1179            "nth_value",
1180            "ntile",
1181            "null",
1182            "nullcols",
1183            "nullif",
1184            "nulls",
1185            "numeric",
1186            "nvarchar",
1187            "object",
1188            "octet_length",
1189            "of",
1190            "off",
1191            "offline",
1192            "offset",
1193            "offsets",
1194            "oids",
1195            "on",
1196            "online",
1197            "only",
1198            "open",
1199            "operator",
1200            "optimization",
1201            "optimize",
1202            "optimizer",
1203            "optimizer_state",
1204            "option",
1205            "options",
1206            "optionally",
1207            "or",
1208            "order",
1209            "ordered_serialize",
1210            "orphan",
1211            "out",
1212            "out_of_order",
1213            "outer",
1214            "outfile",
1215            "over",
1216            "overlaps",
1217            "overlay",
1218            "owned",
1219            "owner",
1220            "pack_keys",
1221            "paired",
1222            "parser",
1223            "parquet",
1224            "partial",
1225            "partition",
1226            "partition_id",
1227            "partitioning",
1228            "partitions",
1229            "passing",
1230            "password",
1231            "password_lock_time",
1232            "parser",
1233            "pause",
1234            "_pause_replay",
1235            "percent_rank",
1236            "percentile_cont",
1237            "percentile_disc",
1238            "periodic",
1239            "persisted",
1240            "pi",
1241            "pipeline",
1242            "pipelines",
1243            "pivot",
1244            "placing",
1245            "plan",
1246            "plans",
1247            "plancache",
1248            "plugins",
1249            "pool",
1250            "pools",
1251            "port",
1252            "position",
1253            "pow",
1254            "power",
1255            "preceding",
1256            "precision",
1257            "prepare",
1258            "prepared",
1259            "preserve",
1260            "primary",
1261            "prior",
1262            "privileges",
1263            "procedural",
1264            "procedure",
1265            "procedures",
1266            "process",
1267            "processlist",
1268            "profile",
1269            "profiles",
1270            "program",
1271            "promote",
1272            "proxy",
1273            "purge",
1274            "quarter",
1275            "queries",
1276            "query",
1277            "query_timeout",
1278            "queue",
1279            "quote",
1280            "radians",
1281            "rand",
1282            "range",
1283            "rank",
1284            "read",
1285            "_read",
1286            "reads",
1287            "real",
1288            "reassign",
1289            "rebalance",
1290            "recheck",
1291            "record",
1292            "recursive",
1293            "redundancy",
1294            "redundant",
1295            "ref",
1296            "reference",
1297            "references",
1298            "refresh",
1299            "regexp",
1300            "reindex",
1301            "relative",
1302            "release",
1303            "reload",
1304            "rely",
1305            "remote",
1306            "remove",
1307            "rename",
1308            "repair",
1309            "_repair_table",
1310            "repeat",
1311            "repeatable",
1312            "_repl",
1313            "_reprovisioning",
1314            "replace",
1315            "replica",
1316            "replicate",
1317            "replicating",
1318            "replication",
1319            "durability",
1320            "require",
1321            "resource",
1322            "resource_pool",
1323            "reset",
1324            "restart",
1325            "restore",
1326            "restrict",
1327            "result",
1328            "_resurrect",
1329            "retry",
1330            "return",
1331            "returning",
1332            "returns",
1333            "reverse",
1334            "revoke",
1335            "rg_pool",
1336            "right",
1337            "right_anti_join",
1338            "right_semi_join",
1339            "right_straight_join",
1340            "rlike",
1341            "role",
1342            "roles",
1343            "rollback",
1344            "rollup",
1345            "round",
1346            "routine",
1347            "row",
1348            "row_count",
1349            "row_format",
1350            "row_number",
1351            "rows",
1352            "rowstore",
1353            "rule",
1354            "rpad",
1355            "_rpc",
1356            "rtrim",
1357            "running",
1358            "s3",
1359            "safe",
1360            "save",
1361            "savepoint",
1362            "scalar",
1363            "schema",
1364            "schemas",
1365            "schema_binding",
1366            "scroll",
1367            "search",
1368            "second",
1369            "second_microsecond",
1370            "sec_to_time",
1371            "security",
1372            "select",
1373            "semi_join",
1374            "_send_threads",
1375            "sensitive",
1376            "separator",
1377            "sequence",
1378            "sequences",
1379            "serial",
1380            "serializable",
1381            "series",
1382            "service_user",
1383            "server",
1384            "session",
1385            "session_user",
1386            "set",
1387            "setof",
1388            "security_lists_intersect",
1389            "sha",
1390            "sha1",
1391            "sha2",
1392            "shard",
1393            "sharded",
1394            "sharded_id",
1395            "share",
1396            "show",
1397            "shutdown",
1398            "sigmoid",
1399            "sign",
1400            "signal",
1401            "similar",
1402            "simple",
1403            "site",
1404            "signed",
1405            "sin",
1406            "skip",
1407            "skipped_batches",
1408            "sleep",
1409            "_sleep",
1410            "smallint",
1411            "snapshot",
1412            "_snapshot",
1413            "_snapshots",
1414            "soft_cpu_limit_percentage",
1415            "some",
1416            "soname",
1417            "sparse",
1418            "spatial",
1419            "spatial_check_index",
1420            "specific",
1421            "split",
1422            "sql",
1423            "sql_big_result",
1424            "sql_buffer_result",
1425            "sql_cache",
1426            "sql_calc_found_rows",
1427            "sqlexception",
1428            "sql_mode",
1429            "sql_no_cache",
1430            "sql_no_logging",
1431            "sql_small_result",
1432            "sqlstate",
1433            "sqlwarning",
1434            "sqrt",
1435            "ssl",
1436            "stable",
1437            "standalone",
1438            "start",
1439            "starting",
1440            "state",
1441            "statement",
1442            "statistics",
1443            "stats",
1444            "status",
1445            "std",
1446            "stddev",
1447            "stddev_pop",
1448            "stddev_samp",
1449            "stdin",
1450            "stdout",
1451            "stop",
1452            "storage",
1453            "str_to_date",
1454            "straight_join",
1455            "strict",
1456            "string",
1457            "strip",
1458            "subdate",
1459            "substr",
1460            "substring",
1461            "substring_index",
1462            "success",
1463            "sum",
1464            "super",
1465            "symmetric",
1466            "sync_snapshot",
1467            "sync",
1468            "_sync",
1469            "_sync2",
1470            "_sync_partitions",
1471            "_sync_snapshot",
1472            "synchronize",
1473            "sysid",
1474            "system",
1475            "table",
1476            "table_checksum",
1477            "tables",
1478            "tablespace",
1479            "tags",
1480            "tan",
1481            "target_size",
1482            "task",
1483            "temp",
1484            "template",
1485            "temporary",
1486            "temptable",
1487            "_term_bump",
1488            "terminate",
1489            "terminated",
1490            "test",
1491            "text",
1492            "then",
1493            "time",
1494            "timediff",
1495            "time_bucket",
1496            "time_format",
1497            "timeout",
1498            "timestamp",
1499            "timestampadd",
1500            "timestampdiff",
1501            "timezone",
1502            "time_to_sec",
1503            "tinyblob",
1504            "tinyint",
1505            "tinytext",
1506            "to",
1507            "to_base64",
1508            "to_char",
1509            "to_date",
1510            "to_days",
1511            "to_json",
1512            "to_number",
1513            "to_seconds",
1514            "to_timestamp",
1515            "tracelogs",
1516            "traditional",
1517            "trailing",
1518            "transform",
1519            "transaction",
1520            "_transactions_experimental",
1521            "treat",
1522            "trigger",
1523            "triggers",
1524            "trim",
1525            "true",
1526            "trunc",
1527            "truncate",
1528            "trusted",
1529            "two_phase",
1530            "_twopcid",
1531            "type",
1532            "types",
1533            "ucase",
1534            "unbounded",
1535            "uncommitted",
1536            "undefined",
1537            "undo",
1538            "unencrypted",
1539            "unenforced",
1540            "unhex",
1541            "unhold",
1542            "unicode",
1543            "union",
1544            "unique",
1545            "_unittest",
1546            "unix_timestamp",
1547            "unknown",
1548            "unlisten",
1549            "_unload",
1550            "unlock",
1551            "unlogged",
1552            "unpivot",
1553            "unsigned",
1554            "until",
1555            "update",
1556            "upgrade",
1557            "upper",
1558            "usage",
1559            "use",
1560            "user",
1561            "users",
1562            "using",
1563            "utc_date",
1564            "utc_time",
1565            "utc_timestamp",
1566            "_utf8",
1567            "vacuum",
1568            "valid",
1569            "validate",
1570            "validator",
1571            "value",
1572            "values",
1573            "varbinary",
1574            "varchar",
1575            "varcharacter",
1576            "variables",
1577            "variadic",
1578            "variance",
1579            "var_pop",
1580            "var_samp",
1581            "varying",
1582            "vector_sub",
1583            "verbose",
1584            "version",
1585            "view",
1586            "void",
1587            "volatile",
1588            "voting",
1589            "wait",
1590            "_wake",
1591            "warnings",
1592            "week",
1593            "weekday",
1594            "weekofyear",
1595            "when",
1596            "where",
1597            "while",
1598            "whitespace",
1599            "window",
1600            "with",
1601            "without",
1602            "within",
1603            "_wm_heartbeat",
1604            "work",
1605            "workload",
1606            "wrapper",
1607            "write",
1608            "xact_id",
1609            "xor",
1610            "year",
1611            "year_month",
1612            "yes",
1613            "zerofill",
1614            "zone",
1615        }
1616
1617        def jsonextractscalar_sql(self, expression: exp.JSONExtractScalar) -> str:
1618            json_type = expression.args.get("json_type")
1619            func_name = "JSON_EXTRACT_JSON" if json_type is None else f"JSON_EXTRACT_{json_type}"
1620            return json_extract_segments(func_name)(self, expression)
1621
1622        def jsonbextractscalar_sql(self, expression: exp.JSONBExtractScalar) -> str:
1623            json_type = expression.args.get("json_type")
1624            func_name = "BSON_EXTRACT_BSON" if json_type is None else f"BSON_EXTRACT_{json_type}"
1625            return json_extract_segments(func_name)(self, expression)
1626
1627        def jsonextractarray_sql(self, expression: exp.JSONExtractArray) -> str:
1628            self.unsupported("Arrays are not supported in SingleStore")
1629            return self.function_fallback_sql(expression)
1630
1631        @unsupported_args("on_condition")
1632        def jsonvalue_sql(self, expression: exp.JSONValue) -> str:
1633            res: exp.Expression = exp.JSONExtractScalar(
1634                this=expression.this,
1635                expression=expression.args.get("path"),
1636                json_type="STRING",
1637            )
1638
1639            returning = expression.args.get("returning")
1640            if returning is not None:
1641                res = exp.Cast(this=res, to=returning)
1642
1643            return self.sql(res)
1644
1645        def all_sql(self, expression: exp.All) -> str:
1646            self.unsupported("ALL subquery predicate is not supported in SingleStore")
1647            return super().all_sql(expression)
1648
1649        def jsonarraycontains_sql(self, expression: exp.JSONArrayContains) -> str:
1650            json_type = expression.text("json_type").upper()
1651
1652            if json_type:
1653                return self.func(
1654                    f"JSON_ARRAY_CONTAINS_{json_type}", expression.expression, expression.this
1655                )
1656
1657            return self.func(
1658                "JSON_ARRAY_CONTAINS_JSON",
1659                expression.expression,
1660                self.func("TO_JSON", expression.this),
1661            )
1662
1663        @unsupported_args("kind", "nested", "values")
1664        def datatype_sql(self, expression: exp.DataType) -> str:
1665            if expression.is_type(exp.DataType.Type.VARBINARY) and not expression.expressions:
1666                # `VARBINARY` must always have a size - if it doesn't, we always generate `BLOB`
1667                return "BLOB"
1668            if expression.is_type(
1669                exp.DataType.Type.DECIMAL32,
1670                exp.DataType.Type.DECIMAL64,
1671                exp.DataType.Type.DECIMAL128,
1672                exp.DataType.Type.DECIMAL256,
1673            ):
1674                scale = self.expressions(expression, flat=True)
1675
1676                if expression.is_type(exp.DataType.Type.DECIMAL32):
1677                    precision = "9"
1678                elif expression.is_type(exp.DataType.Type.DECIMAL64):
1679                    precision = "18"
1680                elif expression.is_type(exp.DataType.Type.DECIMAL128):
1681                    precision = "38"
1682                else:
1683                    # 65 is a maximum precision supported in SingleStore
1684                    precision = "65"
1685                if scale is not None:
1686                    return f"DECIMAL({precision}, {scale[0]})"
1687                else:
1688                    return f"DECIMAL({precision})"
1689
1690            return super().datatype_sql(expression)
1691
1692        def collate_sql(self, expression: exp.Collate) -> str:
1693            # SingleStore does not support setting a collation for column in the SELECT query,
1694            # so we cast column to a LONGTEXT type with specific collation
1695            return self.binary(expression, ":> LONGTEXT COLLATE")
1696
1697        def currentdate_sql(self, expression: exp.CurrentDate) -> str:
1698            timezone = expression.this
1699            if timezone:
1700                if isinstance(timezone, exp.Literal) and timezone.name.lower() == "utc":
1701                    return self.func("UTC_DATE")
1702                self.unsupported("CurrentDate with timezone is not supported in SingleStore")
1703
1704            return self.func("CURRENT_DATE")
1705
1706        def currenttime_sql(self, expression: exp.CurrentTime) -> str:
1707            arg = expression.this
1708            if arg:
1709                if isinstance(arg, exp.Literal) and arg.name.lower() == "utc":
1710                    return self.func("UTC_TIME")
1711                if isinstance(arg, exp.Literal) and arg.is_number:
1712                    return self.func("CURRENT_TIME", arg)
1713                self.unsupported("CurrentTime with timezone is not supported in SingleStore")
1714
1715            return self.func("CURRENT_TIME")
1716
1717        def currenttimestamp_sql(self, expression: exp.CurrentTimestamp) -> str:
1718            arg = expression.this
1719            if arg:
1720                if isinstance(arg, exp.Literal) and arg.name.lower() == "utc":
1721                    return self.func("UTC_TIMESTAMP")
1722                if isinstance(arg, exp.Literal) and arg.is_number:
1723                    return self.func("CURRENT_TIMESTAMP", arg)
1724                self.unsupported("CurrentTimestamp with timezone is not supported in SingleStore")
1725
1726            return self.func("CURRENT_TIMESTAMP")
1727
1728        def standardhash_sql(self, expression: exp.StandardHash) -> str:
1729            hash_function = expression.expression
1730            if hash_function is None:
1731                return self.func("SHA", expression.this)
1732            if isinstance(hash_function, exp.Literal):
1733                if hash_function.name.lower() == "sha":
1734                    return self.func("SHA", expression.this)
1735                if hash_function.name.lower() == "md5":
1736                    return self.func("MD5", expression.this)
1737
1738                self.unsupported(
1739                    f"{hash_function.this} hash method is not supported in SingleStore"
1740                )
1741                return self.func("SHA", expression.this)
1742
1743            self.unsupported("STANDARD_HASH function is not supported in SingleStore")
1744            return self.func("SHA", expression.this)

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

Arguments:
  • pretty: Whether 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 to normalize identifiers to lowercase. Default: False.
  • pad: The pad size in a formatted string. For example, this affects the indentation of a projection in a query, relative to its nesting level. Default: 2.
  • indent: The indentation size in a formatted string. For example, this affects the indentation of subqueries and filters under a WHERE clause. Default: 2.
  • normalize_functions: How to normalize 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: Whether 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 to preserve comments in the output SQL code. Default: True
SUPPORTS_UESCAPE = False
NULL_ORDERING_SUPPORTED = True
MATCH_AGAINST_TABLE_PREFIX = 'TABLE '
@staticmethod
def UNICODE_SUBSTITUTE(m: re.Match[str]) -> str:
258        @staticmethod
259        def _unicode_substitute(m: re.Match[str]) -> str:
260            # Interpret the number as hex and convert it to the Unicode string
261            return chr(int(m.group(1), 16))
TRANSFORMS = {<class 'sqlglot.expressions.JSONPathKey'>: <function json_path_key_only_name>, <class 'sqlglot.expressions.JSONPathRoot'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.JSONPathSubscript'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.AllowedValuesProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.AnalyzeColumns'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.AnalyzeWith'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ArrayContainsAll'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ArrayOverlaps'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.AutoRefreshProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.BackupProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CaseSpecificColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Ceil'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CharacterSetColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CharacterSetProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ClusteredColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CollateColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CommentColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ConnectByRoot'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ConvertToCharset'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CopyGrantsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CredentialsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.DateFormatColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.DefaultColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.DynamicProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.EmptyProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.EncodeColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.EnviromentProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.EphemeralColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ExcludeColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ExecuteAsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Except'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ExternalProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Floor'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Get'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.GlobalProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.HeapProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.IcebergProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.InheritsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.InlineLengthColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.InputModelProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Intersect'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.IntervalSpan'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Int64'>: <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.NonClusteredColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.NoPrimaryIndexProperty'>: <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.Operator'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.OutputModelProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.PathColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.PartitionedByBucket'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.PartitionByTruncate'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.PivotAny'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.PositionalColumn'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ProjectionPolicyColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Put'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.RemoteWithConnectionModelProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ReturnsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SampleProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SecureProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SecurityProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SetConfigProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SetProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SettingsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SharingProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SqlReadWriteProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SqlSecurityProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.StabilityProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Stream'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.StreamingTableProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.StrictProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SwapTable'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.TableColumn'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Tags'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.TemporaryProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.TitleColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ToMap'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ToTableProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.TransformModelProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.TransientProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Union'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.UnloggedProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.UsingTemplateProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.UsingData'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Uuid'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.UppercaseColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.UtcDate'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.UtcTime'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.UtcTimestamp'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.VarMap'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ViewAttributeProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.VolatileProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.WeekStart'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.WithJournalTableProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.WithProcedureOptions'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.WithSchemaBindingProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.WithOperator'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ForceProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ArrayAgg'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.BitwiseAndAgg'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.BitwiseOrAgg'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.BitwiseXorAgg'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.BitwiseCountAgg'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.DateDiff'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.DateAdd'>: <function _remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.DateStrToDate'>: <function datestrtodate_sql>, <class 'sqlglot.expressions.DateSub'>: <function _remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.DateTrunc'>: <function timestamptrunc_sql.<locals>._timestamptrunc_sql>, <class 'sqlglot.expressions.Day'>: <function _remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.DayOfMonth'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.DayOfWeek'>: <function _remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.DayOfYear'>: <function _remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.GroupConcat'>: <function MySQL.Generator.<lambda>>, <class 'sqlglot.expressions.ILike'>: <function no_ilike_sql>, <class 'sqlglot.expressions.Length'>: <function length_or_char_length_sql>, <class 'sqlglot.expressions.LogicalOr'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.LogicalAnd'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.Max'>: <function max_or_greatest>, <class 'sqlglot.expressions.Min'>: <function min_or_least>, <class 'sqlglot.expressions.Month'>: <function _remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.NullSafeEQ'>: <function MySQL.Generator.<lambda>>, <class 'sqlglot.expressions.NullSafeNEQ'>: <function MySQL.Generator.<lambda>>, <class 'sqlglot.expressions.NumberToStr'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.Pivot'>: <function no_pivot_sql>, <class 'sqlglot.expressions.Select'>: <function preprocess.<locals>._to_sql>, <class 'sqlglot.expressions.StrPosition'>: <function MySQL.Generator.<lambda>>, <class 'sqlglot.expressions.StrToDate'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.StrToTime'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.Stuff'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.TableSample'>: <function no_tablesample_sql>, <class 'sqlglot.expressions.TimeFromParts'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.TimestampAdd'>: <function date_add_interval_sql.<locals>.func>, <class 'sqlglot.expressions.TimestampDiff'>: <function MySQL.Generator.<lambda>>, <class 'sqlglot.expressions.TimestampSub'>: <function date_add_interval_sql.<locals>.func>, <class 'sqlglot.expressions.TimeStrToUnix'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.TimeStrToTime'>: <function MySQL.Generator.<lambda>>, <class 'sqlglot.expressions.TimeToStr'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.Trim'>: <function trim_sql>, <class 'sqlglot.expressions.TryCast'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.TsOrDsAdd'>: <function date_add_sql.<locals>.func>, <class 'sqlglot.expressions.TsOrDsDiff'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.TsOrDsToDate'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.Unicode'>: <function MySQL.Generator.<lambda>>, <class 'sqlglot.expressions.UnixToTime'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.Week'>: <function _remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.WeekOfYear'>: <function _remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.Year'>: <function _remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.ToChar'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.Date'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.Cast'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.CastToStrType'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.StrToUnix'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.TimeToUnix'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.UnixSeconds'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.UnixToStr'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.UnixToTimeStr'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.DateBin'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.TimeStrToDate'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.FromTimeZone'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.DiToDate'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.DateToDi'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.TsOrDiToDi'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.Time'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.DatetimeAdd'>: <function _remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.DatetimeTrunc'>: <function timestamptrunc_sql.<locals>._timestamptrunc_sql>, <class 'sqlglot.expressions.DatetimeSub'>: <function date_add_interval_sql.<locals>.func>, <class 'sqlglot.expressions.DatetimeDiff'>: <function timestampdiff_sql>, <class 'sqlglot.expressions.TimestampTrunc'>: <function timestamptrunc_sql.<locals>._timestamptrunc_sql>, <class 'sqlglot.expressions.CurrentDatetime'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.JSONExtract'>: <function json_extract_segments.<locals>._json_extract_segments>, <class 'sqlglot.expressions.JSONBExtract'>: <function json_extract_segments.<locals>._json_extract_segments>, <class 'sqlglot.expressions.JSONFormat'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.JSONArrayAgg'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.JSONArray'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.JSONBExists'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.JSONExists'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.JSONObject'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.DayOfWeekIso'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.Hll'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.ApproxDistinct'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.CountIf'>: <function count_if_to_sum>, <class 'sqlglot.expressions.ApproxQuantile'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.Variance'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.VariancePop'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.Xor'>: <function bool_xor_sql>, <class 'sqlglot.expressions.Cbrt'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.RegexpLike'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.Repeat'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.IsAscii'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.MD5Digest'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.Chr'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.Contains'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.RegexpExtractAll'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.RegexpExtract'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.StartsWith'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.FromBase'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.RegexpILike'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.Reduce'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.MatchAgainst'>: <function SingleStore.Generator.<lambda>>}
UNSUPPORTED_TYPES = {<Type.TSRANGE: 'TSRANGE'>, <Type.IPPREFIX: 'IPPREFIX'>, <Type.DATERANGE: 'DATERANGE'>, <Type.ROWVERSION: 'ROWVERSION'>, <Type.VARIANT: 'VARIANT'>, <Type.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <Type.IPV6: 'IPV6'>, <Type.TIMETZ: 'TIMETZ'>, <Type.INT8RANGE: 'INT8RANGE'>, <Type.NESTED: 'NESTED'>, <Type.OBJECT: 'OBJECT'>, <Type.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <Type.INET: 'INET'>, <Type.IPADDRESS: 'IPADDRESS'>, <Type.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <Type.INT256: 'INT256'>, <Type.UNKNOWN: 'UNKNOWN'>, <Type.NAME: 'NAME'>, <Type.ARRAY: 'ARRAY'>, <Type.BPCHAR: 'BPCHAR'>, <Type.SERIAL: 'SERIAL'>, <Type.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <Type.XML: 'XML'>, <Type.UINT256: 'UINT256'>, <Type.SMALLMONEY: 'SMALLMONEY'>, <Type.INTERVAL: 'INTERVAL'>, <Type.UINT128: 'UINT128'>, <Type.RANGE: 'RANGE'>, <Type.NOTHING: 'NOTHING'>, <Type.UUID: 'UUID'>, <Type.TSMULTIRANGE: 'TSMULTIRANGE'>, <Type.USERDEFINED: 'USER-DEFINED'>, <Type.IPV4: 'IPV4'>, <Type.HSTORE: 'HSTORE'>, <Type.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <Type.MAP: 'MAP'>, <Type.INT4RANGE: 'INT4RANGE'>, <Type.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <Type.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <Type.SMALLSERIAL: 'SMALLSERIAL'>, <Type.HLLSKETCH: 'HLLSKETCH'>, <Type.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <Type.UNION: 'UNION'>, <Type.INT128: 'INT128'>, <Type.SUPER: 'SUPER'>, <Type.TDIGEST: 'TDIGEST'>, <Type.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <Type.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <Type.NULL: 'NULL'>, <Type.BIGSERIAL: 'BIGSERIAL'>, <Type.DYNAMIC: 'DYNAMIC'>, <Type.NUMRANGE: 'NUMRANGE'>, <Type.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <Type.LOWCARDINALITY: 'LOWCARDINALITY'>, <Type.MONEY: 'MONEY'>, <Type.LIST: 'LIST'>, <Type.MULTILINESTRING: 'MULTILINESTRING'>, <Type.IMAGE: 'IMAGE'>, <Type.TSTZRANGE: 'TSTZRANGE'>, <Type.STRUCT: 'STRUCT'>}
TYPE_MAPPING = {<Type.DATETIME2: 'DATETIME2'>: 'DATETIME', <Type.NCHAR: 'NCHAR'>: 'CHAR', <Type.NVARCHAR: 'NVARCHAR'>: 'VARCHAR', <Type.INET: 'INET'>: 'INET', <Type.ROWVERSION: 'ROWVERSION'>: 'VARBINARY', <Type.SMALLDATETIME: 'SMALLDATETIME'>: 'DATETIME', <Type.UBIGINT: 'UBIGINT'>: 'BIGINT', <Type.UINT: 'UINT'>: 'INT', <Type.UMEDIUMINT: 'UMEDIUMINT'>: 'MEDIUMINT', <Type.USMALLINT: 'USMALLINT'>: 'SMALLINT', <Type.UTINYINT: 'UTINYINT'>: 'TINYINT', <Type.UDECIMAL: 'UDECIMAL'>: 'DECIMAL', <Type.UDOUBLE: 'UDOUBLE'>: 'DOUBLE', <Type.TIMESTAMP: 'TIMESTAMP'>: 'TIMESTAMP', <Type.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>: 'DATETIME', <Type.TIMESTAMPTZ: 'TIMESTAMPTZ'>: 'TIMESTAMP', <Type.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>: 'TIMESTAMP', <Type.BIGDECIMAL: 'BIGDECIMAL'>: 'DECIMAL', <Type.BIT: 'BIT'>: 'BOOLEAN', <Type.DATE32: 'DATE32'>: 'DATE', <Type.DATETIME64: 'DATETIME64'>: 'DATETIME', <Type.DECIMAL32: 'DECIMAL32'>: 'DECIMAL', <Type.DECIMAL64: 'DECIMAL64'>: 'DECIMAL', <Type.DECIMAL128: 'DECIMAL128'>: 'DECIMAL', <Type.DECIMAL256: 'DECIMAL256'>: 'DECIMAL', <Type.ENUM8: 'ENUM8'>: 'ENUM', <Type.ENUM16: 'ENUM16'>: 'ENUM', <Type.FIXEDSTRING: 'FIXEDSTRING'>: 'TEXT', <Type.GEOMETRY: 'GEOMETRY'>: 'GEOGRAPHY', <Type.POINT: 'POINT'>: 'GEOGRAPHYPOINT', <Type.RING: 'RING'>: 'GEOGRAPHY', <Type.LINESTRING: 'LINESTRING'>: 'GEOGRAPHY', <Type.POLYGON: 'POLYGON'>: 'GEOGRAPHY', <Type.MULTIPOLYGON: 'MULTIPOLYGON'>: 'GEOGRAPHY', <Type.JSONB: 'JSONB'>: 'BSON', <Type.TIMESTAMP_S: 'TIMESTAMP_S'>: 'TIMESTAMP', <Type.TIMESTAMP_MS: 'TIMESTAMP_MS'>: 'TIMESTAMP(6)'}
RESERVED_KEYWORDS = {'float8', 'uncommitted', 'types', 'rpad', 'variadic', 'geography_intersects', 'json_array_contains_double', 'queries', 'grant', 'sha1', 'current_schema', 'remove', 'unhold', 'session', 'describe', 'geometry_filter', '_sync_partitions', 'discard', 'level', 'on', 'between', 'account', '_memsql_table_id_lookup', 'alter', 'assignment', 'insensitive', 'kafka', 'geometry_intersects', 'partitions', 'where', 'geographypoint', 'connection', 'decimal', 'modify', 'unknown', 'local', 'running', 'also', 'rule', 'int3', 'truncate', 'smallint', 'algorithm', 'test', 'geometry_x', 'strip', 'enclosed', 'treat', 'replace', 'fulltext', 'strict', 'with', 'cache', 'object', 'substr', 'instead', 'sparse', 'target_size', 'date', 'exclusive', 'key', 'right_anti_join', 'event', 'encoding', 'replication', 'triggers', 'inherit', 'external_port', 'differential', 'against', 'prepared', 'in', 'current_timestamp', 'columns', 'zerofill', 'minvalue', 'int8', '_load', 'mbc', 'mpl', 'json_array_contains_string', 'characteristics', 'convert_tz', 'handler', 'stop', 'auto_increment', 'function', 'varchar', 'end', 'rank', '_check_consistency', 'avg_row_length', 'forward', 'window', 'cast', 'redundancy', 'always', 'minute', 'precision', 'definer', '_global_version_timestamp', 'unique', 'pool', '_wm_heartbeat', 'boolean', 'ltrim', 'collation', 'periodic', 'sqlwarning', 'trunc', 'current_date', 'infile', 'inout', 'character_length', 'skip', 'overlaps', 'geography_point', 'hour_microsecond', 'max_rows', 'bootstrap', 'sql', 'backup', 'is', 'save', 'ref', 'columnstore_segment_rows', 'resource', 'require', 'byte_length', 'holding', 'day_hour', 'pi', 'ignore', 'deallocate', 'redundant', 'stddev_pop', 'extended', 'now', 'spatial', 'rg_pool', 'retry', 'over', 'label', 'serializable', 'sql_no_cache', 'when', 'program', 'sum', 'maxvalue', 'stddev_samp', 'passing', 'current_catalog', 'arrange', 'approx_count_distinct', 'time_bucket', 'approx_count_distinct_combine', 'revoke', 'input', 'concat', 'addtime', 'log10', 'instance', 'json_splice_json', 'autostats_histogram_mode', 'content', 'row_count', 'approx_count_distinct_estimate', 'ifnull', 'json_extract_bigint', 'column', 'long', 'checkpoint', 'signal', 'overlay', 'operator', 'do', 'hex', 'distinct', 'read', 'plancache', 'master', 'nvarchar', 'rlike', 'azure', 'result', 'tablespace', 'utc_time', 'fields', 'election', 'right_semi_join', 'temporary', 'no', 'numeric', 'admin', 'day_microsecond', 'acos', 'unbounded', 'extractor', 'preserve', 'bit_and', 'sharded_id', 'type', 'sql_mode', 'json_agg', '_repair_table', 'row_number', 'trailing', 'change', 'force', 'found_rows', 'listen', 'geography_contains', 'timestampadd', 'geography_length', 'paired', 'synchronize', 'template', 'dayofyear', 'subdate', 'xact_id', 'asin', 'inet_aton', 'optimization', 'table_checksum', 'search', 'tracelogs', 'xor', 'unlisten', '_transactions_experimental', 'from_base64', 'no_query_rewrite', 'conv', 'div', 'btree', 'lock', 'refresh', 'second_microsecond', '_batch_size_limit', 'header', 'cume_dist', 'geography_longitude', 'parser', 'optimizer', 'ucase', 'config', 'reads', 'within', 'sql_small_result', 'directory', 'databases', 'int', 'unpivot', 'compact', 'engines', 'plan', 'chain', 'memsql_deserialize', 'node', 'rand', 'promote', 'any_value', 'shutdown', 'queue', 'json_delete_key', 'loaddata_where', 'names', 'curdate', 'charset', 'array', 'all', '_fsync', '_gcx', 'series', 'attach', 'json_set_double', 'to_number', 'show', 'authorization', 'offline', 'initially', 'concurrently', 'language', 'hard_cpu_limit_percentage', 'force_compiled_mode', 'plugins', 'low_priority', 'geometry_y', 'none', 'asc', 'materialized', 'reload', 'compressed', 'gcs', 'fix_alter', 'large', 'placing', 'scroll', 'elt', 'bigint', 'location', 'fs', 'cycle', 'trim', 'varcharacter', 'options', 'foreign', 'partitioning', 'procedure', 'clustered', 'grants', 'storage', 'host', 'of', '_pause_replay', 'bucket_count', 'success', 'to_days', 'count', 'sign', 'delay_key_write', 'join', 'repeat', 'detach', 'backward', '_failover', 'escape', 'else', 'return', 'datetime', '_read', 'inet6_ntoa', 'engine', 'tinyblob', 'returns', 'backup_id', 'hdfs', 'lateral', 'natural', '_snapshots', 'json_splice_string', 'sql_calc_found_rows', 'session_user', 'stdout', 'distributed_joins', 'nchar', 'year_month', 'procedures', 'mode', 'mediumtext', 'escaped', 'partition_id', 'undefined', 'leaf', 'flush', 'delete', 'failed_login_attempts', 'llvm', 'only', 'percent_rank', 'verbose', 'max_retries_per_batch_partition', 'partial', '_term_bump', '_ls', 'decode', 'domain', 'quote', 'traditional', 'parquet', 'groups', 'external', 'data', 'signed', 'declare', 'varbinary', 'case', 'format', 'using', 'leaves', 'errors', 'inherits', 'arghistory', 'after', 'recheck', 'sigmoid', 'hour_minute', 'unicode', 'reindex', 'table', '_unload', 'offset', 'durability', 'tables', 'text', 'estimate', 'insert', 'aggregators', 'orphan', '_unittest', 'write', 'max_concurrency', 'sql_no_logging', 'batch_interval', 'outer', 'longblob', 'profile', 'repair', 'call_for_pipeline', 'set', 'day_minute', '_background_threads_for_cleanup', 'for', 'privileges', 'week', 'unenforced', 'stdin', 'byte', 'yes', 'conversion', 'rows', 'specific', 'order', 'partition', 'log2', 'use', 'disable', 'out_of_order', 'loop', 'real', 'nullcols', 'ceil', 'geometry_length', 'to', 'memory', 'restrict', 'character', 'attribute', 'to_timestamp', 'create', 'access', 'union', 'roles', 'value', 'extractors', 'row', 'and', 'microsecond', 'replicating', 'convert', 'files', 'substring_index', 'process', 'release', 'sql_cache', 'nullif', 'comment', 'latest', 'commit', 'password', 'pipeline', 'lpad', 'max', 'leave', 'copy', 'memory_percentage', 'radians', 'minute_microsecond', 'inet_ntoa', 'having', 'optionally', 'national', 'mediumint', 'min', 'external_host', 'schema_binding', 'deterministic', 'median', 'timezone', 'geography_within_distance', 'availability', 'weekday', 'cluster', 'autostats_enabled', 'async', 'returning', 'class', 'stddev', 'day', 'lz4', 'gzip', 'credentials', 'geometry', 'indexes', 'owned', '_rpc', 'procedural', 'reference', 'csv', 'safe', 'hold', 'greatest', 'until', 'query', 'whitespace', 'get_format', 'constraint', 'foreground', 'owner', 'current_time', 'first_value', 'variables', 'month', 'capture', 'similar', 'dot_product', 'call', 'sensitive', '_twopcid', 'unix_timestamp', 'autostats_sampling', 'deferrable', 'earliest', 'high_priority', 'limit', 'lc_collate', 'pivot', 'compression', 'weekofyear', 'char_length', 'processlist', 'generate', 'increment', 'lag', 'has_temp_tables', 'degrees', 'trusted', 'query_timeout', 'zone', 'desc', 'analyse', 'split', 'backup_history', 'load', 'straight_join', 'sysid', 'int1', 'min_rows', 'aggregates', 'start', 'anti_join', 'sec_to_time', 'group_concat', 'inject', 'view', 'as', 'upgrade', 'or', 'ast', 'localtime', 'unsigned', 'true', 'stable', 'close', 'bit_count', 'field', 'from', 'memsql_serialize', 'online', 'geography_distance', 'to_base64', 'shard', 'row_format', 'cot', 'dictionary', 'option', 'utc_date', 'invoker', 'arrangement', 'ceiling', '_resurrect', 'scalar', 'namespace', 'check', 'dual', 'percentile_disc', 'including', 'json_get_type', 'spatial_check_index', 'fetch', 'longtext', 'rollup', 'inner', 'integer', 'force_interpreter_mode', 'server', 'index', '_continue_replay', 'extension', 'validator', 'proxy', 'json_set_string', 'standalone', 'connection_id', 'inet6_aton', 'not', 'implicit', 'geometry_within_distance', 'wrapper', 'bit_xor', 'string', 'separator', 'from_days', '_binary', 'super', 'geography_area', 'named', 'memsql', 'ascii', 'current_role', 'grouping', 'validate', 'aggregator_plan_hash', 'iterate', 'sqrt', 'extract', 'users', 'percentile_cont', 'rely', 'schema', 'intersect', 'savepoint', 'oids', 'ordered_serialize', 'granted', 'plans', 'geometry_distance', 'terminate', 'date_sub', 'hour', '_check_can_connect', 'sql_big_result', 'std', 'length', 'reset', 'notify', 'drop', 'each', 'timestamp', 'ssl', 'soname', 'monthname', 'both', 'localtimestamp', 'failure', 'pow', 'statistics', 'collect', 'preceding', 'clear', 'tinyint', 'model', 'substring', 'deferred', 'defaults', 'incremental', 'sqlstate', 'stats', 'metadata', 'reverse', 'identified', 'current_security_groups', 'sha2', 'modifies', 'sync_snapshot', 'timediff', 'concurrent', 'float4', 'symmetric', 'cos', 'no_write_to_binlog', 'cursor', 'cross', 'bin', 'asymmetric', 'nowait', 'family', 'asm', 'rowstore', 'schemas', 'disk', 'update', 'sleep', 'identity', 'delimiters', 'background', 'adddate', 'exclude', 'references', 'resource_pool', 'mapping', 'reassign', 'max_errors', 'analyze', 'pipelines', 'document', '_core', 'next', 'called', 'exp', 'rename', 'tags', 'rtrim', 'defined', 'excluding', 'least', '_internal_dynamic_typecast', 'json_set_json', 'cube', 'aggregator_id', 'binary', 'fill', 'power', 'ntile', 'merge', 'void', 'connections', 'pack_keys', 'sharded', 'add', 'coercibility', 'locate', 'sqlexception', 'system', 'password_lock_time', 'client_found_rows', 'heartbeat_no_logging', 'status', 'concat_ws', 'optimizer_state', 'trigger', 'values', 'curtime', 'record', 'left', 'role', 'warnings', 'lines', 'geometrypoint', 'vacuum', 'last_insert_id', 'highlight', 'condition', 'hour_second', 'float', '_management_thread', 'two_phase', 'batch', 'utc_timestamp', 'geography_latitude', 'quarter', 'asensitive', 'database', 'dayofmonth', 'json_array_push_double', 'without', 'before', 'collate', 'auto_reprovision', 'skipped_batches', '_init_profile', 'starting', 'dayname', 'to_json', 'unencrypted', 'interval', 'begin', 'time_to_sec', 'client', 'restore', 'full', 'current_security_roles', 'user', 'delayed', 'aes_encrypt', 'nth_value', 'inline', 'time_format', 'columnar', 'like', 'nulls', 'extra_join', 'member', 'optimize', 'site', 'distinctrow', 'state', 'var_samp', '_utf8', 'json_array_push_json', 'log', 'columnstore', 'max_partitions_per_batch', 'serial', 'kill', 'fault', 'aggregate', 'date_trunc', 'gc', '_sync', 'terminated', 'ln', 'memsql_imitating_kafka', 'freeze', 'right', 'timestampdiff', 'datediff', 'atan2', 'encrypted', 'exit', 'int2', 'day_second', 'bool', 'int4', 'blob', 'aes_decrypt', 'middleint', 'dump', '_send_threads', 'task', 'geometry_point', 'sin', 'euclidean_distance', 'minus', 'open', 'unlock', 'at', 'initcap', 'json_splice_double', 'variance', 'approx_percentile', 'undo', 'lc_ctype', 'md5', 'temp', 'floor', 'from_unixtime', 'json', 'default', '_bt', 'abs', 'year', 'sync', 'remote', 'timeout', 'cascade', 'position', 'purge', 'hash', 'rollback', 'approx_geography_intersects', 'null', 'snapshot', 'json_extract_double', 'current_user', 'octet_length', 'enable', 'temptable', 'bit', 'mod', 'security', 'then', 'routine', 'atan', 'select', 'to_char', 'compile', 'duplicate', 'immediate', 'relative', 'geometry_area', 'security_lists_intersect', 'pools', 'management', 'months_between', 'continue', 'var_pop', 'immutable', 'semi_join', 'assertion', 'right_straight_join', 'batches', 'cost', 's3', 'rebalance', '_repl', 'autostats', 'json_array_contains_json', 'persisted', 'json_extract_json', 'outfile', 'aggregator', 'following', 'lcase', 'profiles', 'initialize', 'killall', 'wait', '_commit_log_tail', 'avg', 'auto', 'dayofweek', 'checksum', 'catalog', 'last_value', 'committed', 'cascaded', '_gc', 'statement', 'dec', 'import', 'share', 'round', 'mediumblob', 'tinytext', 'file', 'some', 'key_block_size', 'constraints', 'false', 'leading', 'coalesce', 'instr', 'valid', 'last', 'port', 'restart', 'geography', 'fixed', 'echo', 'to_date', 'replica', 'global', 'work', 'ilike', 'sql_buffer_result', '_drop_profile', 'offsets', 'exists', '_checksum', 'usage', 'lower', 'date_add', 'insert_method', 'execute', 'by', 'absolute', 'simple', 'comments', 'license', 'sequence', 'soft_cpu_limit_percentage', 'sequences', 'pause', 'second', 'isolation', 'leakproof', 'if', 'date_format', '_snapshot', 'prior', 'functions', 'noparam', 'avro', 'events', 'to_seconds', 'init', 'action', 'lead', 'prepare', '_reprovisioning', 'char', 'any', 'elseif', 'transform', '_sleep', 'dense_rank', 'double', 'service_user', 'handle', 'into', 'transaction', 'json_extract_string', 'setof', 'volatile', 'cnf', 'while', 'approx_count_distinct_accumulate', 'json_length', 'minute_second', 'delimiter', 'out', 'norely', 'recursive', 'move', 'time', 'str_to_date', 'off', 'varying', '_sync2', 'geometry_contains', '_sync_snapshot', 'json_array_push_string', 'unlogged', 'keys', 'match', 'replicate', '_disconnect', 'first', 'unhex', 'group', 'dynamic', 'voting', 'repeatable', 'isnull', 'hosts', 'except', 'explain', 'version', 'workload', 'bit_or', 'max_queue_depth', 'last_day', 'enum', 'nothing', 'configuration', 'autostats_cardinality_mode', 'range', 'upper', '_wake', 'primary', 'current', 'tan', 'interpreter_mode', 'sha', 'regexp', 'vector_sub'}
def jsonextractscalar_sql(self, expression: sqlglot.expressions.JSONExtractScalar) -> str:
1617        def jsonextractscalar_sql(self, expression: exp.JSONExtractScalar) -> str:
1618            json_type = expression.args.get("json_type")
1619            func_name = "JSON_EXTRACT_JSON" if json_type is None else f"JSON_EXTRACT_{json_type}"
1620            return json_extract_segments(func_name)(self, expression)
def jsonbextractscalar_sql(self, expression: sqlglot.expressions.JSONBExtractScalar) -> str:
1622        def jsonbextractscalar_sql(self, expression: exp.JSONBExtractScalar) -> str:
1623            json_type = expression.args.get("json_type")
1624            func_name = "BSON_EXTRACT_BSON" if json_type is None else f"BSON_EXTRACT_{json_type}"
1625            return json_extract_segments(func_name)(self, expression)
def jsonextractarray_sql(self, expression: sqlglot.expressions.JSONExtractArray) -> str:
1627        def jsonextractarray_sql(self, expression: exp.JSONExtractArray) -> str:
1628            self.unsupported("Arrays are not supported in SingleStore")
1629            return self.function_fallback_sql(expression)
@unsupported_args('on_condition')
def jsonvalue_sql(self, expression: sqlglot.expressions.JSONValue) -> str:
1631        @unsupported_args("on_condition")
1632        def jsonvalue_sql(self, expression: exp.JSONValue) -> str:
1633            res: exp.Expression = exp.JSONExtractScalar(
1634                this=expression.this,
1635                expression=expression.args.get("path"),
1636                json_type="STRING",
1637            )
1638
1639            returning = expression.args.get("returning")
1640            if returning is not None:
1641                res = exp.Cast(this=res, to=returning)
1642
1643            return self.sql(res)
def all_sql(self, expression: sqlglot.expressions.All) -> str:
1645        def all_sql(self, expression: exp.All) -> str:
1646            self.unsupported("ALL subquery predicate is not supported in SingleStore")
1647            return super().all_sql(expression)
def jsonarraycontains_sql(self, expression: sqlglot.expressions.JSONArrayContains) -> str:
1649        def jsonarraycontains_sql(self, expression: exp.JSONArrayContains) -> str:
1650            json_type = expression.text("json_type").upper()
1651
1652            if json_type:
1653                return self.func(
1654                    f"JSON_ARRAY_CONTAINS_{json_type}", expression.expression, expression.this
1655                )
1656
1657            return self.func(
1658                "JSON_ARRAY_CONTAINS_JSON",
1659                expression.expression,
1660                self.func("TO_JSON", expression.this),
1661            )
@unsupported_args('kind', 'nested', 'values')
def datatype_sql(self, expression: sqlglot.expressions.DataType) -> str:
1663        @unsupported_args("kind", "nested", "values")
1664        def datatype_sql(self, expression: exp.DataType) -> str:
1665            if expression.is_type(exp.DataType.Type.VARBINARY) and not expression.expressions:
1666                # `VARBINARY` must always have a size - if it doesn't, we always generate `BLOB`
1667                return "BLOB"
1668            if expression.is_type(
1669                exp.DataType.Type.DECIMAL32,
1670                exp.DataType.Type.DECIMAL64,
1671                exp.DataType.Type.DECIMAL128,
1672                exp.DataType.Type.DECIMAL256,
1673            ):
1674                scale = self.expressions(expression, flat=True)
1675
1676                if expression.is_type(exp.DataType.Type.DECIMAL32):
1677                    precision = "9"
1678                elif expression.is_type(exp.DataType.Type.DECIMAL64):
1679                    precision = "18"
1680                elif expression.is_type(exp.DataType.Type.DECIMAL128):
1681                    precision = "38"
1682                else:
1683                    # 65 is a maximum precision supported in SingleStore
1684                    precision = "65"
1685                if scale is not None:
1686                    return f"DECIMAL({precision}, {scale[0]})"
1687                else:
1688                    return f"DECIMAL({precision})"
1689
1690            return super().datatype_sql(expression)
def collate_sql(self, expression: sqlglot.expressions.Collate) -> str:
1692        def collate_sql(self, expression: exp.Collate) -> str:
1693            # SingleStore does not support setting a collation for column in the SELECT query,
1694            # so we cast column to a LONGTEXT type with specific collation
1695            return self.binary(expression, ":> LONGTEXT COLLATE")
def currentdate_sql(self, expression: sqlglot.expressions.CurrentDate) -> str:
1697        def currentdate_sql(self, expression: exp.CurrentDate) -> str:
1698            timezone = expression.this
1699            if timezone:
1700                if isinstance(timezone, exp.Literal) and timezone.name.lower() == "utc":
1701                    return self.func("UTC_DATE")
1702                self.unsupported("CurrentDate with timezone is not supported in SingleStore")
1703
1704            return self.func("CURRENT_DATE")
def currenttime_sql(self, expression: sqlglot.expressions.CurrentTime) -> str:
1706        def currenttime_sql(self, expression: exp.CurrentTime) -> str:
1707            arg = expression.this
1708            if arg:
1709                if isinstance(arg, exp.Literal) and arg.name.lower() == "utc":
1710                    return self.func("UTC_TIME")
1711                if isinstance(arg, exp.Literal) and arg.is_number:
1712                    return self.func("CURRENT_TIME", arg)
1713                self.unsupported("CurrentTime with timezone is not supported in SingleStore")
1714
1715            return self.func("CURRENT_TIME")
def currenttimestamp_sql(self, expression: sqlglot.expressions.CurrentTimestamp) -> str:
1717        def currenttimestamp_sql(self, expression: exp.CurrentTimestamp) -> str:
1718            arg = expression.this
1719            if arg:
1720                if isinstance(arg, exp.Literal) and arg.name.lower() == "utc":
1721                    return self.func("UTC_TIMESTAMP")
1722                if isinstance(arg, exp.Literal) and arg.is_number:
1723                    return self.func("CURRENT_TIMESTAMP", arg)
1724                self.unsupported("CurrentTimestamp with timezone is not supported in SingleStore")
1725
1726            return self.func("CURRENT_TIMESTAMP")
def standardhash_sql(self, expression: sqlglot.expressions.StandardHash) -> str:
1728        def standardhash_sql(self, expression: exp.StandardHash) -> str:
1729            hash_function = expression.expression
1730            if hash_function is None:
1731                return self.func("SHA", expression.this)
1732            if isinstance(hash_function, exp.Literal):
1733                if hash_function.name.lower() == "sha":
1734                    return self.func("SHA", expression.this)
1735                if hash_function.name.lower() == "md5":
1736                    return self.func("MD5", expression.this)
1737
1738                self.unsupported(
1739                    f"{hash_function.this} hash method is not supported in SingleStore"
1740                )
1741                return self.func("SHA", expression.this)
1742
1743            self.unsupported("STANDARD_HASH function is not supported in SingleStore")
1744            return self.func("SHA", expression.this)
SELECT_KINDS: Tuple[str, ...] = ()
TRY_SUPPORTED = False
SUPPORTS_DECODE_CASE = False
AFTER_HAVING_MODIFIER_TRANSFORMS = {'windows': <function Generator.<lambda>>, 'qualify': <function Generator.<lambda>>}
Inherited Members
sqlglot.generator.Generator
Generator
IGNORE_NULLS_IN_FUNC
EXCEPT_INTERSECT_SUPPORT_ALL_CLAUSE
CREATE_FUNCTION_RETURN_AS
MATCHED_BY_SOURCE
SINGLE_STRING_INTERVAL
RENAME_TABLE_WITH_DB
GROUPINGS_SEP
INDEX_ON
QUERY_HINTS
IS_BOOL_ALLOWED
LIMIT_IS_TOP
RETURNING_END
EXTRACT_ALLOWS_QUOTES
TZ_TO_WITH_TIME_ZONE
ALTER_TABLE_INCLUDE_COLUMN_KEYWORD
UNNEST_WITH_ORDINALITY
AGGREGATE_FILTER_SUPPORTED
SEMI_ANTI_JOIN_WITH_SIDE
COMPUTED_COLUMN_WITH_TYPE
SUPPORTS_TABLE_COPY
TABLESAMPLE_REQUIRES_PARENS
TABLESAMPLE_SIZE_IS_ROWS
TABLESAMPLE_KEYWORDS
TABLESAMPLE_WITH_METHOD
TABLESAMPLE_SEED_KEYWORD
COLLATE_IS_FUNC
DATA_TYPE_SPECIFIERS_ALLOWED
ENSURE_BOOLS
CTE_RECURSIVE_KEYWORD_REQUIRED
SUPPORTS_SINGLE_ARG_CONCAT
SUPPORTS_TABLE_ALIAS_COLUMNS
UNPIVOT_ALIASES_ARE_IDENTIFIERS
INSERT_OVERWRITE
SUPPORTS_SELECT_INTO
SUPPORTS_UNLOGGED_TABLES
SUPPORTS_CREATE_TABLE_LIKE
LIKE_PROPERTY_INSIDE_SCHEMA
MULTI_ARG_DISTINCT
JSON_PATH_SINGLE_QUOTE_ESCAPE
CAN_IMPLEMENT_ARRAY_ANY
SUPPORTS_WINDOW_EXCLUDE
SET_OP_MODIFIERS
COPY_PARAMS_ARE_WRAPPED
COPY_PARAMS_EQ_REQUIRED
COPY_HAS_INTO_KEYWORD
STAR_EXCEPT
HEX_FUNC
WITH_PROPERTIES_PREFIX
QUOTE_JSON_PATH
SUPPORTS_EXPLODING_PROJECTIONS
ARRAY_CONCAT_IS_VAR_LEN
SUPPORTS_CONVERT_TIMEZONE
SUPPORTS_UNIX_SECONDS
ALTER_SET_WRAPPED
NORMALIZE_EXTRACT_DATE_PARTS
ARRAY_SIZE_NAME
ALTER_SET_TYPE
ARRAY_SIZE_DIM_REQUIRED
SUPPORTS_BETWEEN_FLAGS
SUPPORTS_LIKE_QUANTIFIERS
TIME_PART_SINGULARS
TOKEN_MAPPING
STRUCT_DELIMITER
PARAMETER_TOKEN
NAMED_PLACEHOLDER_TOKEN
EXPRESSION_PRECEDES_PROPERTIES_CREATABLES
WITH_SEPARATED_COMMENTS
EXCLUDE_COMMENTS
UNWRAPPED_INTERVAL_VALUES
PARAMETERIZABLE_TEXT_TYPES
EXPRESSIONS_WITHOUT_NESTED_CTES
RESPECT_IGNORE_NULLS_UNSUPPORTED_EXPRESSIONS
SAFE_JSON_PATH_KEY_RE
SENTINEL_LINE_BREAK
pretty
identify
normalize
pad
unsupported_level
max_unsupported
leading_comma
max_text_width
comments
dialect
normalize_functions
unsupported_messages
generate
preprocess
unsupported
sep
seg
sanitize_comment
maybe_comment
wrap
no_identify
normalize_func
indent
sql
uncache_sql
cache_sql
characterset_sql
column_parts
column_sql
columnposition_sql
columndef_sql
columnconstraint_sql
autoincrementcolumnconstraint_sql
compresscolumnconstraint_sql
generatedasidentitycolumnconstraint_sql
generatedasrowcolumnconstraint_sql
periodforsystemtimeconstraint_sql
notnullcolumnconstraint_sql
primarykeycolumnconstraint_sql
uniquecolumnconstraint_sql
createable_sql
create_sql
sequenceproperties_sql
clone_sql
describe_sql
heredoc_sql
prepend_ctes
with_sql
cte_sql
tablealias_sql
bitstring_sql
hexstring_sql
bytestring_sql
unicodestring_sql
rawstring_sql
datatypeparam_sql
directory_sql
delete_sql
drop_sql
set_operation
set_operations
fetch_sql
limitoptions_sql
filter_sql
hint_sql
indexparameters_sql
index_sql
identifier_sql
hex_sql
lowerhex_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
partitionboundspec_sql
partitionedofproperty_sql
lockingproperty_sql
withdataproperty_sql
withsystemversioningproperty_sql
insert_sql
introducer_sql
kill_sql
pseudotype_sql
objectidentifier_sql
onconflict_sql
returning_sql
rowformatdelimitedproperty_sql
withtablehint_sql
indextablehint_sql
historicaldata_sql
table_parts
table_sql
tablefromrows_sql
tablesample_sql
pivot_sql
version_sql
tuple_sql
update_sql
values_sql
var_sql
into_sql
from_sql
groupingsets_sql
rollup_sql
cube_sql
group_sql
having_sql
connect_sql
prior_sql
join_sql
lambda_sql
lateral_op
lateral_sql
limit_sql
offset_sql
setitem_sql
set_sql
queryband_sql
pragma_sql
lock_sql
literal_sql
escape_str
loaddata_sql
null_sql
boolean_sql
order_sql
withfill_sql
cluster_sql
distribute_sql
sort_sql
ordered_sql
matchrecognizemeasure_sql
matchrecognize_sql
query_modifiers
options_modifier
for_modifiers
queryoption_sql
offset_limit_modifiers
after_limit_modifiers
select_sql
schema_sql
schema_columns_sql
star_sql
parameter_sql
sessionparameter_sql
placeholder_sql
subquery_sql
qualify_sql
unnest_sql
prewhere_sql
where_sql
window_sql
partition_by_sql
windowspec_sql
withingroup_sql
between_sql
bracket_offset_expressions
bracket_sql
any_sql
exists_sql
case_sql
constraint_sql
nextvaluefor_sql
trim_sql
convert_concat_args
concat_sql
concatws_sql
check_sql
foreignkey_sql
primarykey_sql
if_sql
matchagainst_sql
jsonkeyvalue_sql
jsonpath_sql
json_path_part
formatjson_sql
formatphrase_sql
jsonobject_sql
jsonobjectagg_sql
jsonarray_sql
jsonarrayagg_sql
jsoncolumndef_sql
jsonschema_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
pivotalias_sql
aliases_sql
atindex_sql
fromtimezone_sql
add_sql
and_sql
or_sql
xor_sql
connector_sql
bitwiseand_sql
bitwiseleftshift_sql
bitwisenot_sql
bitwiseor_sql
bitwiserightshift_sql
bitwisexor_sql
command_sql
comment_sql
mergetreettlaction_sql
mergetreettl_sql
transaction_sql
commit_sql
rollback_sql
alterindex_sql
alterdiststyle_sql
altersortkey_sql
alterrename_sql
renamecolumn_sql
alterset_sql
alter_sql
altersession_sql
add_column_sql
droppartition_sql
addconstraint_sql
addpartition_sql
distinct_sql
ignorenulls_sql
respectnulls_sql
havingmax_sql
intdiv_sql
div_sql
safedivide_sql
overlaps_sql
distance_sql
dot_sql
eq_sql
propertyeq_sql
escape_sql
glob_sql
gt_sql
gte_sql
is_sql
like_sql
ilike_sql
similarto_sql
lt_sql
lte_sql
mod_sql
mul_sql
neq_sql
nullsafeeq_sql
nullsafeneq_sql
slice_sql
sub_sql
trycast_sql
jsoncast_sql
try_sql
log_sql
use_sql
binary
ceil_floor
function_fallback_sql
func
format_args
too_wide
format_time
expressions
op_expressions
naked_property
tag_sql
token_sql
userdefinedfunction_sql
joinhint_sql
kwarg_sql
when_sql
whens_sql
merge_sql
tochar_sql
tonumber_sql
dictproperty_sql
dictrange_sql
dictsubproperty_sql
duplicatekeyproperty_sql
uniquekeyproperty_sql
distributedbyproperty_sql
oncluster_sql
clusteredbyproperty_sql
anyvalue_sql
querytransform_sql
indexconstraintoption_sql
checkcolumnconstraint_sql
indexcolumnconstraint_sql
nvl2_sql
comprehension_sql
columnprefix_sql
opclass_sql
predict_sql
generateembedding_sql
featuresattime_sql
vectorsearch_sql
forin_sql
refresh_sql
toarray_sql
tsordstotime_sql
tsordstotimestamp_sql
tsordstodatetime_sql
tsordstodate_sql
unixdate_sql
lastday_sql
dateadd_sql
arrayany_sql
struct_sql
partitionrange_sql
truncatetable_sql
convert_sql
copyparameter_sql
credentials_sql
copy_sql
semicolon_sql
datadeletionproperty_sql
maskingpolicycolumnconstraint_sql
gapfill_sql
scope_resolution
scoperesolution_sql
parsejson_sql
rand_sql
changes_sql
pad_sql
summarize_sql
explodinggenerateseries_sql
arrayconcat_sql
json_sql
conditionalinsert_sql
multitableinserts_sql
oncondition_sql
jsonextractquote_sql
jsonexists_sql
arrayagg_sql
apply_sql
grant_sql
revoke_sql
grantprivilege_sql
grantprincipal_sql
columns_sql
overlay_sql
todouble_sql
string_sql
median_sql
overflowtruncatebehavior_sql
unixseconds_sql
arraysize_sql
attach_sql
detach_sql
attachoption_sql
watermarkcolumnconstraint_sql
encodeproperty_sql
includeproperty_sql
xmlelement_sql
xmlkeyvalueoption_sql
partitionbyrangeproperty_sql
partitionbyrangepropertydynamic_sql
unpivotcolumns_sql
analyzesample_sql
analyzestatistics_sql
analyzehistogram_sql
analyzedelete_sql
analyzelistchainedrows_sql
analyzevalidate_sql
analyze_sql
xmltable_sql
xmlnamespace_sql
export_sql
declare_sql
declareitem_sql
recursivewithsearch_sql
parameterizedagg_sql
anonymousaggfunc_sql
combinedaggfunc_sql
combinedparameterizedagg_sql
get_put_sql
translatecharacters_sql
decodecase_sql
semanticview_sql
getextract_sql
datefromunixdate_sql
space_sql
buildproperty_sql
refreshtriggerproperty_sql
sqlglot.dialects.mysql.MySQL.Generator
INTERVAL_ALLOWS_PLURAL_FORM
LOCKING_READS_SUPPORTED
JOIN_HINTS
TABLE_HINTS
DUPLICATE_KEY_UPDATE_WITH_SET
QUERY_HINT_SEP
VALUES_AS_TABLE
NVL2_SUPPORTED
LAST_DAY_SUPPORTS_DATE_PART
JSON_TYPE_REQUIRED_FOR_EXTRACTION
JSON_PATH_BRACKETED_KEY_SUPPORTED
JSON_KEY_VALUE_PAIR_SEP
SUPPORTS_TO_NUMBER
PARSE_JSON_NAME
PAD_FILL_PATTERN_IS_REQUIRED
WRAP_DERIVED_VALUES
VARCHAR_REQUIRES_SIZE
SUPPORTS_MEDIAN
UNSIGNED_TYPE_MAPPING
TIMESTAMP_TYPE_MAPPING
PROPERTIES_LOCATION
LIMIT_FETCH
LIMIT_ONLY_LITERALS
CHAR_CAST_MAPPING
SIGNED_CAST_MAPPING
CAST_MAPPING
TIMESTAMP_FUNC_TYPES
computedcolumnconstraint_sql
array_sql
arraycontainsall_sql
dpipe_sql
extract_sql
cast_sql
show_sql
altercolumn_sql
chr_sql
timestamptrunc_sql
converttimezone_sql
attimezone_sql
isascii_sql
currentschema_sql