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

VECTOR_TYPE_ALIASES = {'I8': 'TINYINT', 'I16': 'SMALLINT', 'I32': 'INT', 'I64': 'BIGINT', 'F32': 'FLOAT', 'F64': 'DOUBLE'}
INVERSE_VECTOR_TYPE_ALIASES = {'TINYINT': 'I8', 'SMALLINT': 'I16', 'INT': 'I32', 'BIGINT': 'I64', 'FLOAT': 'F32', 'DOUBLE': 'F64'}
VALID_INTERVAL_UNITS: Set[str] = {'MONTH', 'MICROSECS', 'MONTHS', 'QUARTERS', 'WEEKOFYEAR', 'TIMEZONE_MINUTE', 'D', 'MON', 'MSECOND', 'YEAR', 'DW', 'MILLISECON', 'TIMEZONE_HOUR', 'YEAR_MONTH', 'HOUR_MICROSECOND', 'DOY', 'MS', 'C', 'MILLENIUM', 'NSEC', 'YEARS', 'WEEKOFYEAR_ISO', 'HOURS', 'NS', 'MICROSECOND', 'DECADES', 'M', 'SECONDS', 'EPOCH_SECONDS', 'MILLISECS', 'EPOCH_MILLISECONDS', 'EPOCH_SECOND', 'QUARTER', 'NANOSECS', 'WEEKOFYEARISO', 'YY', 'MSECONDS', 'YRS', 'WK', 'SECS', 'MILLISECONDS', 'WOY', 'WEEKDAY', 'TZH', 'YYY', 'WEEK_ISO', 'MINUTES', 'MSEC', 'HOUR_MINUTE', 'DAYOFMONTH', 'NANOSEC', 'DEC', 'HR', 'MILLISECOND', 'MIN', 'MONS', 'QTRS', 'EPOCH_MICROSECONDS', 'H', 'DAY', 'SECOND', 'CENTS', 'EPOCH_MILLISECOND', 'US', 'MIL', 'HOUR_SECOND', 'MINUTE', 'DECADE', 'DAYOFYEAR', 'EPOCH_NANOSECOND', 'DAY_HOUR', 'TZM', 'WEEKISO', 'DECS', 'S', 'DAY_SECOND', 'WEEK', 'MICROSEC', 'MINS', 'YYYY', 'CENTURY', 'YR', 'USEC', 'CENTURIES', 'DAYOFWEEKISO', 'DAYOFWEEK', 'MINUTE_SECOND', 'DAYS', 'MINUTE_MICROSECOND', 'WEEKDAY_ISO', 'Y', 'MM', 'SEC', 'DY', 'DOW', 'MI', 'CENT', 'USECS', 'EPOCH_MICROSECOND', 'Q', 'SECOND_MICROSECOND', 'MILLISEC', 'EPOCH', 'QTR', 'DD', 'DAY_MINUTE', 'MILLENIA', 'DW_ISO', 'NSECOND', 'DAY_MICROSECOND', 'MICROSECONDS', 'W', 'USECONDS', 'DOW_ISO', 'EPOCH_NANOSECONDS', 'DAY OF YEAR', 'HOUR', 'NSECONDS', 'USECOND', 'MSECS', 'HH', 'HRS', 'NANOSECOND', 'WY', 'DAY OF WEEK', 'MILS'}
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):
70    class Tokenizer(MySQL.Tokenizer):
71        BYTE_STRINGS = [("e'", "'"), ("E'", "'")]
72
73        KEYWORDS = {
74            **MySQL.Tokenizer.KEYWORDS,
75            "BSON": TokenType.JSONB,
76            "GEOGRAPHYPOINT": TokenType.GEOGRAPHYPOINT,
77            "TIMESTAMP": TokenType.TIMESTAMP,
78            "UTC_DATE": TokenType.UTC_DATE,
79            "UTC_TIME": TokenType.UTC_TIME,
80            "UTC_TIMESTAMP": TokenType.UTC_TIMESTAMP,
81            ":>": TokenType.COLON_GT,
82            "!:>": TokenType.NCOLON_GT,
83            "::$": TokenType.DCOLONDOLLAR,
84            "::%": TokenType.DCOLONPERCENT,
85        }
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'>, 'MOD': <TokenType.MOD: 'MOD'>, 'SEPARATOR': <TokenType.SEPARATOR: 'SEPARATOR'>, 'SERIAL': <TokenType.SERIAL: 'SERIAL'>, 'SIGNED': <TokenType.BIGINT: 'BIGINT'>, 'SIGNED INTEGER': <TokenType.BIGINT: 'BIGINT'>, 'SOUNDS LIKE': <TokenType.SOUNDS_LIKE: 'SOUNDS_LIKE'>, 'START': <TokenType.BEGIN: 'BEGIN'>, '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):
 87    class Parser(MySQL.Parser):
 88        FUNCTIONS = {
 89            **MySQL.Parser.FUNCTIONS,
 90            "TO_DATE": build_formatted_time(exp.TsOrDsToDate, "singlestore"),
 91            "TO_TIMESTAMP": build_formatted_time(exp.StrToTime, "singlestore"),
 92            "TO_CHAR": build_formatted_time(exp.ToChar, "singlestore"),
 93            "STR_TO_DATE": build_formatted_time(exp.StrToDate, "mysql"),
 94            "DATE_FORMAT": build_formatted_time(exp.TimeToStr, "mysql"),
 95            # The first argument of following functions is converted to TIME(6)
 96            # This is needed because exp.TimeToStr is converted to DATE_FORMAT
 97            # which interprets the first argument as DATETIME and fails to parse
 98            # string literals like '12:05:47' without a date part.
 99            "TIME_FORMAT": lambda args: exp.TimeToStr(
100                this=cast_to_time6(seq_get(args, 0)),
101                format=MySQL.format_time(seq_get(args, 1)),
102            ),
103            "HOUR": lambda args: exp.cast(
104                exp.TimeToStr(
105                    this=cast_to_time6(seq_get(args, 0)),
106                    format=MySQL.format_time(exp.Literal.string("%k")),
107                ),
108                DataType.Type.INT,
109            ),
110            "MICROSECOND": lambda args: exp.cast(
111                exp.TimeToStr(
112                    this=cast_to_time6(seq_get(args, 0)),
113                    format=MySQL.format_time(exp.Literal.string("%f")),
114                ),
115                DataType.Type.INT,
116            ),
117            "SECOND": lambda args: exp.cast(
118                exp.TimeToStr(
119                    this=cast_to_time6(seq_get(args, 0)),
120                    format=MySQL.format_time(exp.Literal.string("%s")),
121                ),
122                DataType.Type.INT,
123            ),
124            "MINUTE": lambda args: exp.cast(
125                exp.TimeToStr(
126                    this=cast_to_time6(seq_get(args, 0)),
127                    format=MySQL.format_time(exp.Literal.string("%i")),
128                ),
129                DataType.Type.INT,
130            ),
131            "MONTHNAME": lambda args: exp.TimeToStr(
132                this=seq_get(args, 0),
133                format=MySQL.format_time(exp.Literal.string("%M")),
134            ),
135            "WEEKDAY": lambda args: exp.paren(exp.DayOfWeek(this=seq_get(args, 0)) + 5, copy=False)
136            % 7,
137            "UNIX_TIMESTAMP": exp.StrToUnix.from_arg_list,
138            "FROM_UNIXTIME": build_formatted_time(exp.UnixToTime, "mysql"),
139            "TIME_BUCKET": lambda args: exp.DateBin(
140                this=seq_get(args, 0),
141                expression=seq_get(args, 1),
142                origin=seq_get(args, 2),
143            ),
144            "BSON_EXTRACT_BSON": build_json_extract_path(exp.JSONBExtract),
145            "BSON_EXTRACT_STRING": build_json_extract_path(
146                exp.JSONBExtractScalar, json_type="STRING"
147            ),
148            "BSON_EXTRACT_DOUBLE": build_json_extract_path(
149                exp.JSONBExtractScalar, json_type="DOUBLE"
150            ),
151            "BSON_EXTRACT_BIGINT": build_json_extract_path(
152                exp.JSONBExtractScalar, json_type="BIGINT"
153            ),
154            "JSON_EXTRACT_JSON": build_json_extract_path(exp.JSONExtract),
155            "JSON_EXTRACT_STRING": build_json_extract_path(
156                exp.JSONExtractScalar, json_type="STRING"
157            ),
158            "JSON_EXTRACT_DOUBLE": build_json_extract_path(
159                exp.JSONExtractScalar, json_type="DOUBLE"
160            ),
161            "JSON_EXTRACT_BIGINT": build_json_extract_path(
162                exp.JSONExtractScalar, json_type="BIGINT"
163            ),
164            "JSON_ARRAY_CONTAINS_STRING": lambda args: exp.JSONArrayContains(
165                this=seq_get(args, 1),
166                expression=seq_get(args, 0),
167                json_type="STRING",
168            ),
169            "JSON_ARRAY_CONTAINS_DOUBLE": lambda args: exp.JSONArrayContains(
170                this=seq_get(args, 1),
171                expression=seq_get(args, 0),
172                json_type="DOUBLE",
173            ),
174            "JSON_ARRAY_CONTAINS_JSON": lambda args: exp.JSONArrayContains(
175                this=seq_get(args, 1),
176                expression=seq_get(args, 0),
177                json_type="JSON",
178            ),
179            "JSON_PRETTY": exp.JSONFormat.from_arg_list,
180            "JSON_BUILD_ARRAY": lambda args: exp.JSONArray(expressions=args),
181            "JSON_BUILD_OBJECT": lambda args: exp.JSONObject(expressions=args),
182            "DATE": exp.Date.from_arg_list,
183            "DAYNAME": lambda args: exp.TimeToStr(
184                this=seq_get(args, 0),
185                format=MySQL.format_time(exp.Literal.string("%W")),
186            ),
187            "TIMESTAMPDIFF": lambda args: exp.TimestampDiff(
188                this=seq_get(args, 2),
189                expression=seq_get(args, 1),
190                unit=seq_get(args, 0),
191            ),
192            "APPROX_COUNT_DISTINCT": exp.Hll.from_arg_list,
193            "APPROX_PERCENTILE": lambda args, dialect: exp.ApproxQuantile(
194                this=seq_get(args, 0),
195                quantile=seq_get(args, 1),
196                error_tolerance=seq_get(args, 2),
197            ),
198            "VARIANCE": exp.VariancePop.from_arg_list,
199            "INSTR": exp.Contains.from_arg_list,
200            "REGEXP_MATCH": lambda args: exp.RegexpExtractAll(
201                this=seq_get(args, 0),
202                expression=seq_get(args, 1),
203                parameters=seq_get(args, 2),
204            ),
205            "REGEXP_SUBSTR": lambda args: exp.RegexpExtract(
206                this=seq_get(args, 0),
207                expression=seq_get(args, 1),
208                position=seq_get(args, 2),
209                occurrence=seq_get(args, 3),
210                parameters=seq_get(args, 4),
211            ),
212            "REDUCE": lambda args: exp.Reduce(
213                initial=seq_get(args, 0),
214                this=seq_get(args, 1),
215                merge=seq_get(args, 2),
216            ),
217        }
218
219        FUNCTION_PARSERS: t.Dict[str, t.Callable] = {
220            **MySQL.Parser.FUNCTION_PARSERS,
221            "JSON_AGG": lambda self: exp.JSONArrayAgg(
222                this=self._parse_term(),
223                order=self._parse_order(),
224            ),
225        }
226
227        NO_PAREN_FUNCTIONS = {
228            **MySQL.Parser.NO_PAREN_FUNCTIONS,
229            TokenType.UTC_DATE: exp.UtcDate,
230            TokenType.UTC_TIME: exp.UtcTime,
231            TokenType.UTC_TIMESTAMP: exp.UtcTimestamp,
232        }
233
234        CAST_COLUMN_OPERATORS = {TokenType.COLON_GT, TokenType.NCOLON_GT}
235
236        COLUMN_OPERATORS = {
237            **MySQL.Parser.COLUMN_OPERATORS,
238            TokenType.COLON_GT: lambda self, this, to: self.expression(
239                exp.Cast,
240                this=this,
241                to=to,
242            ),
243            TokenType.NCOLON_GT: lambda self, this, to: self.expression(
244                exp.TryCast,
245                this=this,
246                to=to,
247            ),
248            TokenType.DCOLON: lambda self, this, path: build_json_extract_path(exp.JSONExtract)(
249                [this, exp.Literal.string(path.name)]
250            ),
251            TokenType.DCOLONDOLLAR: lambda self, this, path: build_json_extract_path(
252                exp.JSONExtractScalar, json_type="STRING"
253            )([this, exp.Literal.string(path.name)]),
254            TokenType.DCOLONPERCENT: lambda self, this, path: build_json_extract_path(
255                exp.JSONExtractScalar, json_type="DOUBLE"
256            )([this, exp.Literal.string(path.name)]),
257        }
258        COLUMN_OPERATORS.pop(TokenType.ARROW)
259        COLUMN_OPERATORS.pop(TokenType.DARROW)
260        COLUMN_OPERATORS.pop(TokenType.HASH_ARROW)
261        COLUMN_OPERATORS.pop(TokenType.DHASH_ARROW)
262        COLUMN_OPERATORS.pop(TokenType.PLACEHOLDER)
263
264        SHOW_PARSERS = {
265            **MySQL.Parser.SHOW_PARSERS,
266            "AGGREGATES": _show_parser("AGGREGATES"),
267            "CDC EXTRACTOR POOL": _show_parser("CDC EXTRACTOR POOL"),
268            "CREATE AGGREGATE": _show_parser("CREATE AGGREGATE", target=True),
269            "CREATE PIPELINE": _show_parser("CREATE PIPELINE", target=True),
270            "CREATE PROJECTION": _show_parser("CREATE PROJECTION", target=True),
271            "DATABASE STATUS": _show_parser("DATABASE STATUS"),
272            "DISTRIBUTED_PLANCACHE STATUS": _show_parser("DISTRIBUTED_PLANCACHE STATUS"),
273            "FULLTEXT SERVICE METRICS LOCAL": _show_parser("FULLTEXT SERVICE METRICS LOCAL"),
274            "FULLTEXT SERVICE METRICS FOR NODE": _show_parser(
275                "FULLTEXT SERVICE METRICS FOR NODE", target=True
276            ),
277            "FULLTEXT SERVICE STATUS": _show_parser("FULLTEXT SERVICE STATUS"),
278            "FUNCTIONS": _show_parser("FUNCTIONS"),
279            "GROUPS": _show_parser("GROUPS"),
280            "GROUPS FOR ROLE": _show_parser("GROUPS FOR ROLE", target=True),
281            "GROUPS FOR USER": _show_parser("GROUPS FOR USER", target=True),
282            "INDEXES": _show_parser("INDEX", target="FROM"),
283            "KEYS": _show_parser("INDEX", target="FROM"),
284            "LINKS": _show_parser("LINKS", target="ON"),
285            "LOAD ERRORS": _show_parser("LOAD ERRORS"),
286            "LOAD WARNINGS": _show_parser("LOAD WARNINGS"),
287            "PARTITIONS": _show_parser("PARTITIONS", target="ON"),
288            "PIPELINES": _show_parser("PIPELINES"),
289            "PLAN": _show_parser("PLAN", target=True),
290            "PLANCACHE": _show_parser("PLANCACHE"),
291            "PROCEDURES": _show_parser("PROCEDURES"),
292            "PROJECTIONS": _show_parser("PROJECTIONS", target="ON TABLE"),
293            "REPLICATION STATUS": _show_parser("REPLICATION STATUS"),
294            "REPRODUCTION": _show_parser("REPRODUCTION"),
295            "RESOURCE POOLS": _show_parser("RESOURCE POOLS"),
296            "ROLES": _show_parser("ROLES"),
297            "ROLES FOR USER": _show_parser("ROLES FOR USER", target=True),
298            "ROLES FOR GROUP": _show_parser("ROLES FOR GROUP", target=True),
299            "STATUS EXTENDED": _show_parser("STATUS EXTENDED"),
300            "USERS": _show_parser("USERS"),
301            "USERS FOR ROLE": _show_parser("USERS FOR ROLE", target=True),
302            "USERS FOR GROUP": _show_parser("USERS FOR GROUP", target=True),
303        }
304
305        ALTER_PARSERS = {
306            **MySQL.Parser.ALTER_PARSERS,
307            "CHANGE": lambda self: self.expression(
308                exp.RenameColumn, this=self._parse_column(), to=self._parse_column()
309            ),
310        }
311
312        def _parse_vector_expressions(
313            self, expressions: t.List[exp.Expression]
314        ) -> t.List[exp.Expression]:
315            type_name = expressions[1].name.upper()
316            if type_name in self.dialect.VECTOR_TYPE_ALIASES:
317                type_name = self.dialect.VECTOR_TYPE_ALIASES[type_name]
318
319            return [exp.DataType.build(type_name, dialect=self.dialect), expressions[0]]

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 = {'AI_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.AIAgg'>>, 'AI_CLASSIFY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.AIClassify'>>, 'AI_SUMMARIZE_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.AISummarizeAgg'>>, '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'>>, 'BASE64_DECODE_BINARY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Base64DecodeBinary'>>, 'BASE64_DECODE_STRING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Base64DecodeString'>>, 'BASE64_ENCODE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Base64Encode'>>, 'BIT_LENGTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.BitLength'>>, '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'>>, 'COLLATION': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Collation'>>, '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'>>, 'COMPRESS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Compress'>>, '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'>>, 'COS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Cos'>>, 'COSH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Cosh'>>, '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'>>, 'DECOMPRESS_BINARY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DecompressBinary'>>, 'DECOMPRESS_STRING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DecompressString'>>, 'DEGREES': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Degrees'>>, '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'>>, 'FACTORIAL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Factorial'>>, '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>, 'HEX_DECODE_STRING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.HexDecodeString'>>, 'HEX_ENCODE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.HexEncode'>>, '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'>>, 'J_S_O_N_B_CONTAINS_ALL_TOP_KEYS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONBContainsAllTopKeys'>>, 'J_S_O_N_B_CONTAINS_ANY_TOP_KEYS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONBContainsAnyTopKeys'>>, 'J_S_O_N_B_DELETE_AT_PATH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONBDeleteAtPath'>>, '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'>>, 'JAROWINKLER_SIMILARITY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JarowinklerSimilarity'>>, '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'>>, 'M_D5_NUMBER_LOWER64': <bound method Func.from_arg_list of <class 'sqlglot.expressions.MD5NumberLower64'>>, 'M_D5_NUMBER_UPPER64': <bound method Func.from_arg_list of <class 'sqlglot.expressions.MD5NumberUpper64'>>, 'M_L_FORECAST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.MLForecast'>>, 'M_L_TRANSLATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.MLTranslate'>>, '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_IP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ParseIp'>>, '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'>>, 'PARSE_URL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ParseUrl'>>, '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_COUNT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpCount'>>, '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_FULL_MATCH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpFullMatch'>>, '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'>>, 'RTRIMMED_LENGTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RtrimmedLength'>>, 'SHA': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SHA'>>, 'SHA1': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SHA'>>, 'S_H_A1_DIGEST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SHA1Digest'>>, 'SHA2': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SHA2'>>, 'S_H_A2_DIGEST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SHA2Digest'>>, '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'>>, 'SEARCH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Search'>>, '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'>>, 'SOUNDEX_P123': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SoundexP123'>>, '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'>>, 'TAN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Tan'>>, '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_BASE64_DECODE_BINARY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TryBase64DecodeBinary'>>, 'TRY_BASE64_DECODE_STRING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TryBase64DecodeString'>>, 'TRY_CAST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TryCast'>>, 'TRY_HEX_DECODE_BINARY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TryHexDecodeBinary'>>, 'TRY_HEX_DECODE_STRING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TryHexDecodeString'>>, '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>>, 'SUBSTR': <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.COLON_GT: 'COLON_GT'>, <TokenType.NCOLON_GT: 'NCOLON_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>>}
SHOW_PARSERS = {'BINARY LOGS': <function _show_parser.<locals>._parse>, 'MASTER LOGS': <function _show_parser.<locals>._parse>, 'BINLOG EVENTS': <function _show_parser.<locals>._parse>, 'CHARACTER SET': <function _show_parser.<locals>._parse>, 'CHARSET': <function _show_parser.<locals>._parse>, 'COLLATION': <function _show_parser.<locals>._parse>, 'FULL COLUMNS': <function _show_parser.<locals>._parse>, 'COLUMNS': <function _show_parser.<locals>._parse>, 'CREATE DATABASE': <function _show_parser.<locals>._parse>, 'CREATE EVENT': <function _show_parser.<locals>._parse>, 'CREATE FUNCTION': <function _show_parser.<locals>._parse>, 'CREATE PROCEDURE': <function _show_parser.<locals>._parse>, 'CREATE TABLE': <function _show_parser.<locals>._parse>, 'CREATE TRIGGER': <function _show_parser.<locals>._parse>, 'CREATE VIEW': <function _show_parser.<locals>._parse>, 'DATABASES': <function _show_parser.<locals>._parse>, 'SCHEMAS': <function _show_parser.<locals>._parse>, 'ENGINE': <function _show_parser.<locals>._parse>, 'STORAGE ENGINES': <function _show_parser.<locals>._parse>, 'ENGINES': <function _show_parser.<locals>._parse>, 'ERRORS': <function _show_parser.<locals>._parse>, 'EVENTS': <function _show_parser.<locals>._parse>, 'FUNCTION CODE': <function _show_parser.<locals>._parse>, 'FUNCTION STATUS': <function _show_parser.<locals>._parse>, 'GRANTS': <function _show_parser.<locals>._parse>, 'INDEX': <function _show_parser.<locals>._parse>, 'MASTER STATUS': <function _show_parser.<locals>._parse>, 'OPEN TABLES': <function _show_parser.<locals>._parse>, 'PLUGINS': <function _show_parser.<locals>._parse>, 'PROCEDURE CODE': <function _show_parser.<locals>._parse>, 'PROCEDURE STATUS': <function _show_parser.<locals>._parse>, 'PRIVILEGES': <function _show_parser.<locals>._parse>, 'FULL PROCESSLIST': <function _show_parser.<locals>._parse>, 'PROCESSLIST': <function _show_parser.<locals>._parse>, 'PROFILE': <function _show_parser.<locals>._parse>, 'PROFILES': <function _show_parser.<locals>._parse>, 'RELAYLOG EVENTS': <function _show_parser.<locals>._parse>, 'REPLICAS': <function _show_parser.<locals>._parse>, 'SLAVE HOSTS': <function _show_parser.<locals>._parse>, 'REPLICA STATUS': <function _show_parser.<locals>._parse>, 'SLAVE STATUS': <function _show_parser.<locals>._parse>, 'GLOBAL STATUS': <function _show_parser.<locals>._parse>, 'SESSION STATUS': <function _show_parser.<locals>._parse>, 'STATUS': <function _show_parser.<locals>._parse>, 'TABLE STATUS': <function _show_parser.<locals>._parse>, 'FULL TABLES': <function _show_parser.<locals>._parse>, 'TABLES': <function _show_parser.<locals>._parse>, 'TRIGGERS': <function _show_parser.<locals>._parse>, 'GLOBAL VARIABLES': <function _show_parser.<locals>._parse>, 'SESSION VARIABLES': <function _show_parser.<locals>._parse>, 'VARIABLES': <function _show_parser.<locals>._parse>, 'WARNINGS': <function _show_parser.<locals>._parse>, 'AGGREGATES': <function _show_parser.<locals>._parse>, 'CDC EXTRACTOR POOL': <function _show_parser.<locals>._parse>, 'CREATE AGGREGATE': <function _show_parser.<locals>._parse>, 'CREATE PIPELINE': <function _show_parser.<locals>._parse>, 'CREATE PROJECTION': <function _show_parser.<locals>._parse>, 'DATABASE STATUS': <function _show_parser.<locals>._parse>, 'DISTRIBUTED_PLANCACHE STATUS': <function _show_parser.<locals>._parse>, 'FULLTEXT SERVICE METRICS LOCAL': <function _show_parser.<locals>._parse>, 'FULLTEXT SERVICE METRICS FOR NODE': <function _show_parser.<locals>._parse>, 'FULLTEXT SERVICE STATUS': <function _show_parser.<locals>._parse>, 'FUNCTIONS': <function _show_parser.<locals>._parse>, 'GROUPS': <function _show_parser.<locals>._parse>, 'GROUPS FOR ROLE': <function _show_parser.<locals>._parse>, 'GROUPS FOR USER': <function _show_parser.<locals>._parse>, 'INDEXES': <function _show_parser.<locals>._parse>, 'KEYS': <function _show_parser.<locals>._parse>, 'LINKS': <function _show_parser.<locals>._parse>, 'LOAD ERRORS': <function _show_parser.<locals>._parse>, 'LOAD WARNINGS': <function _show_parser.<locals>._parse>, 'PARTITIONS': <function _show_parser.<locals>._parse>, 'PIPELINES': <function _show_parser.<locals>._parse>, 'PLAN': <function _show_parser.<locals>._parse>, 'PLANCACHE': <function _show_parser.<locals>._parse>, 'PROCEDURES': <function _show_parser.<locals>._parse>, 'PROJECTIONS': <function _show_parser.<locals>._parse>, 'REPLICATION STATUS': <function _show_parser.<locals>._parse>, 'REPRODUCTION': <function _show_parser.<locals>._parse>, 'RESOURCE POOLS': <function _show_parser.<locals>._parse>, 'ROLES': <function _show_parser.<locals>._parse>, 'ROLES FOR USER': <function _show_parser.<locals>._parse>, 'ROLES FOR GROUP': <function _show_parser.<locals>._parse>, 'STATUS EXTENDED': <function _show_parser.<locals>._parse>, 'USERS': <function _show_parser.<locals>._parse>, 'USERS FOR ROLE': <function _show_parser.<locals>._parse>, 'USERS FOR GROUP': <function _show_parser.<locals>._parse>}
ALTER_PARSERS = {'ADD': <function Parser.<lambda>>, 'AS': <function Parser.<lambda>>, 'ALTER': <function Parser.<lambda>>, 'CLUSTER BY': <function Parser.<lambda>>, 'DELETE': <function Parser.<lambda>>, 'DROP': <function Parser.<lambda>>, 'RENAME': <function Parser.<lambda>>, 'SET': <function Parser.<lambda>>, 'SWAP': <function Parser.<lambda>>, 'MODIFY': <function MySQL.Parser.<lambda>>, 'CHANGE': <function SingleStore.Parser.<lambda>>}
TABLE_ALIAS_TOKENS = {<TokenType.INDEX: 'INDEX'>, <TokenType.POINT: 'POINT'>, <TokenType.INT256: 'INT256'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.DECIMAL64: 'DECIMAL64'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.DATE32: 'DATE32'>, <TokenType.TABLE: 'TABLE'>, <TokenType.DYNAMIC: 'DYNAMIC'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.YEAR: 'YEAR'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.CHAR: 'CHAR'>, <TokenType.COPY: 'COPY'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.NOTHING: 'NOTHING'>, <TokenType.ENUM: 'ENUM'>, <TokenType.NESTED: 'NESTED'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, <TokenType.FILTER: 'FILTER'>, <TokenType.IPV6: 'IPV6'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.MONEY: 'MONEY'>, <TokenType.RANGE: 'RANGE'>, <TokenType.LOAD: 'LOAD'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.MODEL: 'MODEL'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.CACHE: 'CACHE'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.EXPORT: 'EXPORT'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.MULTILINESTRING: 'MULTILINESTRING'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.DECIMAL32: 'DECIMAL32'>, <TokenType.OFFSET: 'OFFSET'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.INT128: 'INT128'>, <TokenType.UPDATE: 'UPDATE'>, <TokenType.IPV4: 'IPV4'>, <TokenType.MAP: 'MAP'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.ATTACH: 'ATTACH'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.APPLY: 'APPLY'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.DECIMAL256: 'DECIMAL256'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.LIMIT: 'LIMIT'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.TIME: 'TIME'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.KEEP: 'KEEP'>, <TokenType.TOP: 'TOP'>, <TokenType.DATE: 'DATE'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.GEOGRAPHYPOINT: 'GEOGRAPHYPOINT'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.LIST: 'LIST'>, <TokenType.RING: 'RING'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.SHOW: 'SHOW'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.RENAME: 'RENAME'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.VOID: 'VOID'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.SUPER: 'SUPER'>, <TokenType.MULTIPOLYGON: 'MULTIPOLYGON'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.DECIMAL128: 'DECIMAL128'>, <TokenType.SEMI: 'SEMI'>, <TokenType.END: 'END'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.INT: 'INT'>, <TokenType.STAGE: 'STAGE'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.ALL: 'ALL'>, <TokenType.DIV: 'DIV'>, <TokenType.WAREHOUSE: 'WAREHOUSE'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.MERGE: 'MERGE'>, <TokenType.FALSE: 'FALSE'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.TRUE: 'TRUE'>, <TokenType.NAME: 'NAME'>, <TokenType.NULL: 'NULL'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.NEXT: 'NEXT'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.JSON: 'JSON'>, <TokenType.SINK: 'SINK'>, <TokenType.TEXT: 'TEXT'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.SOME: 'SOME'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.NAMESPACE: 'NAMESPACE'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.UDOUBLE: 'UDOUBLE'>, <TokenType.KILL: 'KILL'>, <TokenType.SESSION: 'SESSION'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.ASC: 'ASC'>, <TokenType.DATETIME2: 'DATETIME2'>, <TokenType.UINT128: 'UINT128'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.VAR: 'VAR'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.ROWS: 'ROWS'>, <TokenType.SET: 'SET'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.SMALLDATETIME: 'SMALLDATETIME'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.ANY: 'ANY'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.BIT: 'BIT'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.UINT: 'UINT'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.SEMANTIC_VIEW: 'SEMANTIC_VIEW'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.JSONB: 'JSONB'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.ANTI: 'ANTI'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.DESC: 'DESC'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.UINT256: 'UINT256'>, <TokenType.IS: 'IS'>, <TokenType.TAG: 'TAG'>, <TokenType.ROW: 'ROW'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.CASE: 'CASE'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.SOURCE: 'SOURCE'>, <TokenType.DELETE: 'DELETE'>, <TokenType.FIRST: 'FIRST'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.FINAL: 'FINAL'>, <TokenType.INET: 'INET'>, <TokenType.GET: 'GET'>, <TokenType.DETACH: 'DETACH'>, <TokenType.POLYGON: 'POLYGON'>, <TokenType.ROLLUP: 'ROLLUP'>, <TokenType.VIEW: 'VIEW'>, <TokenType.LINESTRING: 'LINESTRING'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.XML: 'XML'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.STREAMLIT: 'STREAMLIT'>, <TokenType.CUBE: 'CUBE'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.UUID: 'UUID'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.ESCAPE: 'ESCAPE'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.VECTOR: 'VECTOR'>, <TokenType.FILE_FORMAT: 'FILE_FORMAT'>, <TokenType.BLOB: 'BLOB'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.CURRENT_SCHEMA: 'CURRENT_SCHEMA'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.BINARY: 'BINARY'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.PUT: 'PUT'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.COMMENT: 'COMMENT'>}
ID_VAR_TOKENS = {<TokenType.RIGHT: 'RIGHT'>, <TokenType.INDEX: 'INDEX'>, <TokenType.POINT: 'POINT'>, <TokenType.INT256: 'INT256'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.DECIMAL64: 'DECIMAL64'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.DATE32: 'DATE32'>, <TokenType.TABLE: 'TABLE'>, <TokenType.DYNAMIC: 'DYNAMIC'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.YEAR: 'YEAR'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.CHAR: 'CHAR'>, <TokenType.COPY: 'COPY'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.NOTHING: 'NOTHING'>, <TokenType.ENUM: 'ENUM'>, <TokenType.NESTED: 'NESTED'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, <TokenType.FILTER: 'FILTER'>, <TokenType.IPV6: 'IPV6'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.MONEY: 'MONEY'>, <TokenType.RANGE: 'RANGE'>, <TokenType.LOAD: 'LOAD'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.MODEL: 'MODEL'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.CACHE: 'CACHE'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.EXPORT: 'EXPORT'>, <TokenType.NATURAL: 'NATURAL'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.FULL: 'FULL'>, <TokenType.MULTILINESTRING: 'MULTILINESTRING'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.DECIMAL32: 'DECIMAL32'>, <TokenType.OFFSET: 'OFFSET'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.LEFT: 'LEFT'>, <TokenType.INT128: 'INT128'>, <TokenType.UPDATE: 'UPDATE'>, <TokenType.IPV4: 'IPV4'>, <TokenType.MAP: 'MAP'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.ATTACH: 'ATTACH'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.APPLY: 'APPLY'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.DECIMAL256: 'DECIMAL256'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.LIMIT: 'LIMIT'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.USE: 'USE'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.TIME: 'TIME'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.KEEP: 'KEEP'>, <TokenType.TOP: 'TOP'>, <TokenType.DATE: 'DATE'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.GEOGRAPHYPOINT: 'GEOGRAPHYPOINT'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.LIST: 'LIST'>, <TokenType.RING: 'RING'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.SHOW: 'SHOW'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.RENAME: 'RENAME'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.VOID: 'VOID'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.SUPER: 'SUPER'>, <TokenType.SEMI: 'SEMI'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.MULTIPOLYGON: 'MULTIPOLYGON'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.DECIMAL128: 'DECIMAL128'>, <TokenType.END: 'END'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.INT: 'INT'>, <TokenType.STAGE: 'STAGE'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.ALL: 'ALL'>, <TokenType.WINDOW: 'WINDOW'>, <TokenType.DIV: 'DIV'>, <TokenType.WAREHOUSE: 'WAREHOUSE'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.MERGE: 'MERGE'>, <TokenType.FALSE: 'FALSE'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.TRUE: 'TRUE'>, <TokenType.NAME: 'NAME'>, <TokenType.NULL: 'NULL'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.NEXT: 'NEXT'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.JSON: 'JSON'>, <TokenType.SINK: 'SINK'>, <TokenType.LOCK: 'LOCK'>, <TokenType.TEXT: 'TEXT'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.SOME: 'SOME'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.NAMESPACE: 'NAMESPACE'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.UDOUBLE: 'UDOUBLE'>, <TokenType.KILL: 'KILL'>, <TokenType.SESSION: 'SESSION'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.ASC: 'ASC'>, <TokenType.DATETIME2: 'DATETIME2'>, <TokenType.UINT128: 'UINT128'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.VAR: 'VAR'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.ROWS: 'ROWS'>, <TokenType.SET: 'SET'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.SMALLDATETIME: 'SMALLDATETIME'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.ANY: 'ANY'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.ASOF: 'ASOF'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.BIT: 'BIT'>, <TokenType.UINT: 'UINT'>, <TokenType.SEMANTIC_VIEW: 'SEMANTIC_VIEW'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.JSONB: 'JSONB'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.ANTI: 'ANTI'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.DESC: 'DESC'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.UINT256: 'UINT256'>, <TokenType.IS: 'IS'>, <TokenType.TAG: 'TAG'>, <TokenType.ROW: 'ROW'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.CASE: 'CASE'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.SOURCE: 'SOURCE'>, <TokenType.DELETE: 'DELETE'>, <TokenType.FIRST: 'FIRST'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.FINAL: 'FINAL'>, <TokenType.INET: 'INET'>, <TokenType.GET: 'GET'>, <TokenType.DETACH: 'DETACH'>, <TokenType.POLYGON: 'POLYGON'>, <TokenType.ROLLUP: 'ROLLUP'>, <TokenType.VIEW: 'VIEW'>, <TokenType.LINESTRING: 'LINESTRING'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.XML: 'XML'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.STREAMLIT: 'STREAMLIT'>, <TokenType.CUBE: 'CUBE'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.UUID: 'UUID'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.ESCAPE: 'ESCAPE'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.VECTOR: 'VECTOR'>, <TokenType.FILE_FORMAT: 'FILE_FORMAT'>, <TokenType.BLOB: 'BLOB'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.CURRENT_SCHEMA: 'CURRENT_SCHEMA'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.BINARY: 'BINARY'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.PUT: 'PUT'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.COMMENT: 'COMMENT'>}
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}, 'AGGREGATE': {0: True}, 'PIPELINE': {0: True}, 'PROJECTION': {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, 'EXTENDED': {0: True}}, 'TABLE': {'STATUS': {0: True}}, 'TABLES': {0: True}, 'TRIGGERS': {0: True}, 'VARIABLES': {0: True}, 'WARNINGS': {0: True}, 'AGGREGATES': {0: True}, 'CDC': {'EXTRACTOR': {'POOL': {0: True}}}, 'DATABASE': {'STATUS': {0: True}}, 'DISTRIBUTED_PLANCACHE': {'STATUS': {0: True}}, 'FULLTEXT': {'SERVICE': {'METRICS': {'LOCAL': {0: True}, 'FOR': {'NODE': {0: True}}}, 'STATUS': {0: True}}}, 'FUNCTIONS': {0: True}, 'GROUPS': {0: True, 'FOR': {'ROLE': {0: True}, 'USER': {0: True}}}, 'INDEXES': {0: True}, 'KEYS': {0: True}, 'LINKS': {0: True}, 'LOAD': {'ERRORS': {0: True}, 'WARNINGS': {0: True}}, 'PARTITIONS': {0: True}, 'PIPELINES': {0: True}, 'PLAN': {0: True}, 'PLANCACHE': {0: True}, 'PROCEDURES': {0: True}, 'PROJECTIONS': {0: True}, 'REPLICATION': {'STATUS': {0: True}}, 'REPRODUCTION': {0: True}, 'RESOURCE': {'POOLS': {0: True}}, 'ROLES': {0: True, 'FOR': {'USER': {0: True}, 'GROUP': {0: True}}}, 'USERS': {0: True, 'FOR': {'ROLE': {0: True}, 'GROUP': {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
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
ALTER_TABLE_PARTITIONS
JOINS_HAVE_EQUAL_PRECEDENCE
ZONE_AWARE_TIMESTAMP_CONSTRUCTOR
MAP_KEYS_ARE_ARBITRARY_EXPRESSIONS
JSON_EXTRACT_REQUIRES_JSON_EXPRESSION
ADD_JOIN_ON_TRUE
SUPPORTS_OMITTED_INTERVAL_SPAN_UNIT
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
PROPERTY_PARSERS
SET_PARSERS
CONSTRAINT_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):
 321    class Generator(MySQL.Generator):
 322        SUPPORTS_UESCAPE = False
 323        NULL_ORDERING_SUPPORTED = True
 324        MATCH_AGAINST_TABLE_PREFIX = "TABLE "
 325
 326        @staticmethod
 327        def _unicode_substitute(m: re.Match[str]) -> str:
 328            # Interpret the number as hex and convert it to the Unicode string
 329            return chr(int(m.group(1), 16))
 330
 331        UNICODE_SUBSTITUTE: t.Optional[t.Callable[[re.Match[str]], str]] = _unicode_substitute
 332
 333        SUPPORTED_JSON_PATH_PARTS = {
 334            exp.JSONPathKey,
 335            exp.JSONPathRoot,
 336            exp.JSONPathSubscript,
 337        }
 338
 339        TRANSFORMS = {
 340            **MySQL.Generator.TRANSFORMS,
 341            exp.TsOrDsToDate: lambda self, e: self.func("TO_DATE", e.this, self.format_time(e))
 342            if e.args.get("format")
 343            else self.func("DATE", e.this),
 344            exp.StrToTime: lambda self, e: self.func("TO_TIMESTAMP", e.this, self.format_time(e)),
 345            exp.ToChar: lambda self, e: self.func("TO_CHAR", e.this, self.format_time(e)),
 346            exp.StrToDate: lambda self, e: self.func(
 347                "STR_TO_DATE",
 348                e.this,
 349                self.format_time(
 350                    e,
 351                    inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING,
 352                    inverse_time_trie=MySQL.INVERSE_TIME_TRIE,
 353                ),
 354            ),
 355            exp.TimeToStr: lambda self, e: self.func(
 356                "DATE_FORMAT",
 357                e.this,
 358                self.format_time(
 359                    e,
 360                    inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING,
 361                    inverse_time_trie=MySQL.INVERSE_TIME_TRIE,
 362                ),
 363            ),
 364            exp.Date: unsupported_args("zone", "expressions")(rename_func("DATE")),
 365            exp.Cast: unsupported_args("format", "action", "default")(
 366                lambda self, e: f"{self.sql(e, 'this')} :> {self.sql(e, 'to')}"
 367            ),
 368            exp.TryCast: unsupported_args("format", "action", "default")(
 369                lambda self, e: f"{self.sql(e, 'this')} !:> {self.sql(e, 'to')}"
 370            ),
 371            exp.CastToStrType: lambda self, e: self.sql(
 372                exp.cast(e.this, DataType.build(e.args["to"].name))
 373            ),
 374            exp.StrToUnix: unsupported_args("format")(rename_func("UNIX_TIMESTAMP")),
 375            exp.TimeToUnix: rename_func("UNIX_TIMESTAMP"),
 376            exp.TimeStrToUnix: rename_func("UNIX_TIMESTAMP"),
 377            exp.UnixSeconds: rename_func("UNIX_TIMESTAMP"),
 378            exp.UnixToStr: lambda self, e: self.func(
 379                "FROM_UNIXTIME",
 380                e.this,
 381                self.format_time(
 382                    e,
 383                    inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING,
 384                    inverse_time_trie=MySQL.INVERSE_TIME_TRIE,
 385                ),
 386            ),
 387            exp.UnixToTime: unsupported_args("scale", "zone", "hours", "minutes")(
 388                lambda self, e: self.func(
 389                    "FROM_UNIXTIME",
 390                    e.this,
 391                    self.format_time(
 392                        e,
 393                        inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING,
 394                        inverse_time_trie=MySQL.INVERSE_TIME_TRIE,
 395                    ),
 396                ),
 397            ),
 398            exp.UnixToTimeStr: lambda self, e: f"FROM_UNIXTIME({self.sql(e, 'this')}) :> TEXT",
 399            exp.DateBin: unsupported_args("unit", "zone")(
 400                lambda self, e: self.func("TIME_BUCKET", e.this, e.expression, e.args.get("origin"))
 401            ),
 402            exp.TimeStrToDate: lambda self, e: self.sql(exp.cast(e.this, exp.DataType.Type.DATE)),
 403            exp.FromTimeZone: lambda self, e: self.func(
 404                "CONVERT_TZ", e.this, e.args.get("zone"), "'UTC'"
 405            ),
 406            exp.DiToDate: lambda self,
 407            e: f"STR_TO_DATE({self.sql(e, 'this')}, {SingleStore.DATEINT_FORMAT})",
 408            exp.DateToDi: lambda self,
 409            e: f"(DATE_FORMAT({self.sql(e, 'this')}, {SingleStore.DATEINT_FORMAT}) :> INT)",
 410            exp.TsOrDiToDi: lambda self,
 411            e: f"(DATE_FORMAT({self.sql(e, 'this')}, {SingleStore.DATEINT_FORMAT}) :> INT)",
 412            exp.Time: unsupported_args("zone")(lambda self, e: f"{self.sql(e, 'this')} :> TIME"),
 413            exp.DatetimeAdd: _remove_ts_or_ds_to_date(date_add_sql("ADD")),
 414            exp.DatetimeTrunc: unsupported_args("zone")(timestamptrunc_sql()),
 415            exp.DatetimeSub: date_add_interval_sql("DATE", "SUB"),
 416            exp.DatetimeDiff: timestampdiff_sql,
 417            exp.DateTrunc: unsupported_args("zone")(timestamptrunc_sql()),
 418            exp.DateDiff: unsupported_args("zone")(
 419                lambda self, e: timestampdiff_sql(self, e)
 420                if e.unit is not None
 421                else self.func("DATEDIFF", e.this, e.expression)
 422            ),
 423            exp.TsOrDsDiff: lambda self, e: timestampdiff_sql(self, e)
 424            if e.unit is not None
 425            else self.func("DATEDIFF", e.this, e.expression),
 426            exp.TimestampTrunc: unsupported_args("zone")(timestamptrunc_sql()),
 427            exp.CurrentDatetime: lambda self, e: self.sql(
 428                cast_to_time6(
 429                    exp.CurrentTimestamp(this=exp.Literal.number(6)), exp.DataType.Type.DATETIME
 430                )
 431            ),
 432            exp.JSONExtract: unsupported_args(
 433                "only_json_types",
 434                "expressions",
 435                "variant_extract",
 436                "json_query",
 437                "option",
 438                "quote",
 439                "on_condition",
 440                "requires_json",
 441            )(json_extract_segments("JSON_EXTRACT_JSON")),
 442            exp.JSONBExtract: json_extract_segments("BSON_EXTRACT_BSON"),
 443            exp.JSONPathKey: json_path_key_only_name,
 444            exp.JSONPathSubscript: lambda self, e: self.json_path_part(e.this),
 445            exp.JSONPathRoot: lambda *_: "",
 446            exp.JSONFormat: unsupported_args("options", "is_json")(rename_func("JSON_PRETTY")),
 447            exp.JSONArrayAgg: unsupported_args("null_handling", "return_type", "strict")(
 448                lambda self, e: self.func("JSON_AGG", e.this, suffix=f"{self.sql(e, 'order')})")
 449            ),
 450            exp.JSONArray: unsupported_args("null_handling", "return_type", "strict")(
 451                rename_func("JSON_BUILD_ARRAY")
 452            ),
 453            exp.JSONBExists: lambda self, e: self.func(
 454                "BSON_MATCH_ANY_EXISTS", e.this, e.args.get("path")
 455            ),
 456            exp.JSONExists: unsupported_args("passing", "on_condition")(
 457                lambda self, e: self.func("JSON_MATCH_ANY_EXISTS", e.this, e.args.get("path"))
 458            ),
 459            exp.JSONObject: unsupported_args(
 460                "null_handling", "unique_keys", "return_type", "encoding"
 461            )(rename_func("JSON_BUILD_OBJECT")),
 462            exp.DayOfWeekIso: lambda self, e: f"(({self.func('DAYOFWEEK', e.this)} % 7) + 1)",
 463            exp.DayOfMonth: rename_func("DAY"),
 464            exp.Hll: rename_func("APPROX_COUNT_DISTINCT"),
 465            exp.ApproxDistinct: rename_func("APPROX_COUNT_DISTINCT"),
 466            exp.CountIf: count_if_to_sum,
 467            exp.LogicalOr: lambda self, e: f"MAX(ABS({self.sql(e, 'this')}))",
 468            exp.LogicalAnd: lambda self, e: f"MIN(ABS({self.sql(e, 'this')}))",
 469            exp.ApproxQuantile: unsupported_args("accuracy", "weight")(
 470                lambda self, e: self.func(
 471                    "APPROX_PERCENTILE",
 472                    e.this,
 473                    e.args.get("quantile"),
 474                    e.args.get("error_tolerance"),
 475                )
 476            ),
 477            exp.Variance: rename_func("VAR_SAMP"),
 478            exp.VariancePop: rename_func("VAR_POP"),
 479            exp.Xor: bool_xor_sql,
 480            exp.Cbrt: lambda self, e: self.sql(
 481                exp.Pow(this=e.this, expression=exp.Literal.number(1) / exp.Literal.number(3))
 482            ),
 483            exp.RegexpLike: lambda self, e: self.binary(e, "RLIKE"),
 484            exp.Repeat: lambda self, e: self.func(
 485                "LPAD",
 486                exp.Literal.string(""),
 487                exp.Mul(this=self.func("LENGTH", e.this), expression=e.args.get("times")),
 488                e.this,
 489            ),
 490            exp.IsAscii: lambda self, e: f"({self.sql(e, 'this')} RLIKE '^[\x00-\x7f]*$')",
 491            exp.MD5Digest: lambda self, e: self.func("UNHEX", self.func("MD5", e.this)),
 492            exp.Chr: rename_func("CHAR"),
 493            exp.Contains: rename_func("INSTR"),
 494            exp.RegexpExtractAll: unsupported_args("position", "occurrence", "group")(
 495                lambda self, e: self.func(
 496                    "REGEXP_MATCH",
 497                    e.this,
 498                    e.expression,
 499                    e.args.get("parameters"),
 500                )
 501            ),
 502            exp.RegexpExtract: unsupported_args("group")(
 503                lambda self, e: self.func(
 504                    "REGEXP_SUBSTR",
 505                    e.this,
 506                    e.expression,
 507                    e.args.get("position"),
 508                    e.args.get("occurrence"),
 509                    e.args.get("parameters"),
 510                )
 511            ),
 512            exp.StartsWith: lambda self, e: self.func(
 513                "REGEXP_INSTR", e.this, self.func("CONCAT", exp.Literal.string("^"), e.expression)
 514            ),
 515            exp.FromBase: lambda self, e: self.func(
 516                "CONV", e.this, e.expression, exp.Literal.number(10)
 517            ),
 518            exp.RegexpILike: lambda self, e: self.binary(
 519                exp.RegexpLike(
 520                    this=exp.Lower(this=e.this),
 521                    expression=exp.Lower(this=e.expression),
 522                ),
 523                "RLIKE",
 524            ),
 525            exp.Stuff: lambda self, e: self.func(
 526                "CONCAT",
 527                self.func("SUBSTRING", e.this, exp.Literal.number(1), e.args.get("start") - 1),
 528                e.expression,
 529                self.func("SUBSTRING", e.this, e.args.get("start") + e.args.get("length")),
 530            ),
 531            exp.National: lambda self, e: self.national_sql(e, prefix=""),
 532            exp.Reduce: unsupported_args("finish")(
 533                lambda self, e: self.func(
 534                    "REDUCE", e.args.get("initial"), e.this, e.args.get("merge")
 535                )
 536            ),
 537            exp.MatchAgainst: unsupported_args("modifier")(
 538                lambda self, e: super().matchagainst_sql(e)
 539            ),
 540            exp.Show: unsupported_args(
 541                "history",
 542                "terse",
 543                "offset",
 544                "starts_with",
 545                "limit",
 546                "from",
 547                "scope",
 548                "scope_kind",
 549                "mutex",
 550                "query",
 551                "channel",
 552                "log",
 553                "types",
 554                "privileges",
 555            )(lambda self, e: super().show_sql(e)),
 556            exp.Describe: unsupported_args(
 557                "style",
 558                "kind",
 559                "expressions",
 560                "partition",
 561                "format",
 562            )(lambda self, e: super().describe_sql(e)),
 563        }
 564        TRANSFORMS.pop(exp.JSONExtractScalar)
 565        TRANSFORMS.pop(exp.CurrentDate)
 566
 567        UNSUPPORTED_TYPES = {
 568            exp.DataType.Type.ARRAY,
 569            exp.DataType.Type.AGGREGATEFUNCTION,
 570            exp.DataType.Type.SIMPLEAGGREGATEFUNCTION,
 571            exp.DataType.Type.BIGSERIAL,
 572            exp.DataType.Type.BPCHAR,
 573            exp.DataType.Type.DATEMULTIRANGE,
 574            exp.DataType.Type.DATERANGE,
 575            exp.DataType.Type.DYNAMIC,
 576            exp.DataType.Type.HLLSKETCH,
 577            exp.DataType.Type.HSTORE,
 578            exp.DataType.Type.IMAGE,
 579            exp.DataType.Type.INET,
 580            exp.DataType.Type.INT128,
 581            exp.DataType.Type.INT256,
 582            exp.DataType.Type.INT4MULTIRANGE,
 583            exp.DataType.Type.INT4RANGE,
 584            exp.DataType.Type.INT8MULTIRANGE,
 585            exp.DataType.Type.INT8RANGE,
 586            exp.DataType.Type.INTERVAL,
 587            exp.DataType.Type.IPADDRESS,
 588            exp.DataType.Type.IPPREFIX,
 589            exp.DataType.Type.IPV4,
 590            exp.DataType.Type.IPV6,
 591            exp.DataType.Type.LIST,
 592            exp.DataType.Type.MAP,
 593            exp.DataType.Type.LOWCARDINALITY,
 594            exp.DataType.Type.MONEY,
 595            exp.DataType.Type.MULTILINESTRING,
 596            exp.DataType.Type.NAME,
 597            exp.DataType.Type.NESTED,
 598            exp.DataType.Type.NOTHING,
 599            exp.DataType.Type.NULL,
 600            exp.DataType.Type.NUMMULTIRANGE,
 601            exp.DataType.Type.NUMRANGE,
 602            exp.DataType.Type.OBJECT,
 603            exp.DataType.Type.RANGE,
 604            exp.DataType.Type.ROWVERSION,
 605            exp.DataType.Type.SERIAL,
 606            exp.DataType.Type.SMALLSERIAL,
 607            exp.DataType.Type.SMALLMONEY,
 608            exp.DataType.Type.STRUCT,
 609            exp.DataType.Type.SUPER,
 610            exp.DataType.Type.TIMETZ,
 611            exp.DataType.Type.TIMESTAMPNTZ,
 612            exp.DataType.Type.TIMESTAMPLTZ,
 613            exp.DataType.Type.TIMESTAMPTZ,
 614            exp.DataType.Type.TIMESTAMP_NS,
 615            exp.DataType.Type.TSMULTIRANGE,
 616            exp.DataType.Type.TSRANGE,
 617            exp.DataType.Type.TSTZMULTIRANGE,
 618            exp.DataType.Type.TSTZRANGE,
 619            exp.DataType.Type.UINT128,
 620            exp.DataType.Type.UINT256,
 621            exp.DataType.Type.UNION,
 622            exp.DataType.Type.UNKNOWN,
 623            exp.DataType.Type.USERDEFINED,
 624            exp.DataType.Type.UUID,
 625            exp.DataType.Type.VARIANT,
 626            exp.DataType.Type.XML,
 627            exp.DataType.Type.TDIGEST,
 628        }
 629
 630        TYPE_MAPPING = {
 631            **MySQL.Generator.TYPE_MAPPING,
 632            exp.DataType.Type.BIGDECIMAL: "DECIMAL",
 633            exp.DataType.Type.BIT: "BOOLEAN",
 634            exp.DataType.Type.DATE32: "DATE",
 635            exp.DataType.Type.DATETIME64: "DATETIME",
 636            exp.DataType.Type.DECIMAL32: "DECIMAL",
 637            exp.DataType.Type.DECIMAL64: "DECIMAL",
 638            exp.DataType.Type.DECIMAL128: "DECIMAL",
 639            exp.DataType.Type.DECIMAL256: "DECIMAL",
 640            exp.DataType.Type.ENUM8: "ENUM",
 641            exp.DataType.Type.ENUM16: "ENUM",
 642            exp.DataType.Type.FIXEDSTRING: "TEXT",
 643            exp.DataType.Type.GEOMETRY: "GEOGRAPHY",
 644            exp.DataType.Type.POINT: "GEOGRAPHYPOINT",
 645            exp.DataType.Type.RING: "GEOGRAPHY",
 646            exp.DataType.Type.LINESTRING: "GEOGRAPHY",
 647            exp.DataType.Type.POLYGON: "GEOGRAPHY",
 648            exp.DataType.Type.MULTIPOLYGON: "GEOGRAPHY",
 649            exp.DataType.Type.JSONB: "BSON",
 650            exp.DataType.Type.TIMESTAMP: "TIMESTAMP",
 651            exp.DataType.Type.TIMESTAMP_S: "TIMESTAMP",
 652            exp.DataType.Type.TIMESTAMP_MS: "TIMESTAMP(6)",
 653        }
 654
 655        # https://docs.singlestore.com/cloud/reference/sql-reference/restricted-keywords/list-of-restricted-keywords/
 656        RESERVED_KEYWORDS = {
 657            "abs",
 658            "absolute",
 659            "access",
 660            "account",
 661            "acos",
 662            "action",
 663            "add",
 664            "adddate",
 665            "addtime",
 666            "admin",
 667            "aes_decrypt",
 668            "aes_encrypt",
 669            "after",
 670            "against",
 671            "aggregate",
 672            "aggregates",
 673            "aggregator",
 674            "aggregator_id",
 675            "aggregator_plan_hash",
 676            "aggregators",
 677            "algorithm",
 678            "all",
 679            "also",
 680            "alter",
 681            "always",
 682            "analyse",
 683            "analyze",
 684            "and",
 685            "anti_join",
 686            "any",
 687            "any_value",
 688            "approx_count_distinct",
 689            "approx_count_distinct_accumulate",
 690            "approx_count_distinct_combine",
 691            "approx_count_distinct_estimate",
 692            "approx_geography_intersects",
 693            "approx_percentile",
 694            "arghistory",
 695            "arrange",
 696            "arrangement",
 697            "array",
 698            "as",
 699            "asc",
 700            "ascii",
 701            "asensitive",
 702            "asin",
 703            "asm",
 704            "assertion",
 705            "assignment",
 706            "ast",
 707            "asymmetric",
 708            "async",
 709            "at",
 710            "atan",
 711            "atan2",
 712            "attach",
 713            "attribute",
 714            "authorization",
 715            "auto",
 716            "auto_increment",
 717            "auto_reprovision",
 718            "autostats",
 719            "autostats_cardinality_mode",
 720            "autostats_enabled",
 721            "autostats_histogram_mode",
 722            "autostats_sampling",
 723            "availability",
 724            "avg",
 725            "avg_row_length",
 726            "avro",
 727            "azure",
 728            "background",
 729            "_background_threads_for_cleanup",
 730            "backup",
 731            "backup_history",
 732            "backup_id",
 733            "backward",
 734            "batch",
 735            "batches",
 736            "batch_interval",
 737            "_batch_size_limit",
 738            "before",
 739            "begin",
 740            "between",
 741            "bigint",
 742            "bin",
 743            "binary",
 744            "_binary",
 745            "bit",
 746            "bit_and",
 747            "bit_count",
 748            "bit_or",
 749            "bit_xor",
 750            "blob",
 751            "bool",
 752            "boolean",
 753            "bootstrap",
 754            "both",
 755            "_bt",
 756            "btree",
 757            "bucket_count",
 758            "by",
 759            "byte",
 760            "byte_length",
 761            "cache",
 762            "call",
 763            "call_for_pipeline",
 764            "called",
 765            "capture",
 766            "cascade",
 767            "cascaded",
 768            "case",
 769            "cast",
 770            "catalog",
 771            "ceil",
 772            "ceiling",
 773            "chain",
 774            "change",
 775            "char",
 776            "character",
 777            "characteristics",
 778            "character_length",
 779            "char_length",
 780            "charset",
 781            "check",
 782            "checkpoint",
 783            "_check_can_connect",
 784            "_check_consistency",
 785            "checksum",
 786            "_checksum",
 787            "class",
 788            "clear",
 789            "client",
 790            "client_found_rows",
 791            "close",
 792            "cluster",
 793            "clustered",
 794            "cnf",
 795            "coalesce",
 796            "coercibility",
 797            "collate",
 798            "collation",
 799            "collect",
 800            "column",
 801            "columnar",
 802            "columns",
 803            "columnstore",
 804            "columnstore_segment_rows",
 805            "comment",
 806            "comments",
 807            "commit",
 808            "committed",
 809            "_commit_log_tail",
 810            "committed",
 811            "compact",
 812            "compile",
 813            "compressed",
 814            "compression",
 815            "concat",
 816            "concat_ws",
 817            "concurrent",
 818            "concurrently",
 819            "condition",
 820            "configuration",
 821            "connection",
 822            "connection_id",
 823            "connections",
 824            "config",
 825            "constraint",
 826            "constraints",
 827            "content",
 828            "continue",
 829            "_continue_replay",
 830            "conv",
 831            "conversion",
 832            "convert",
 833            "convert_tz",
 834            "copy",
 835            "_core",
 836            "cos",
 837            "cost",
 838            "cot",
 839            "count",
 840            "create",
 841            "credentials",
 842            "cross",
 843            "cube",
 844            "csv",
 845            "cume_dist",
 846            "curdate",
 847            "current",
 848            "current_catalog",
 849            "current_date",
 850            "current_role",
 851            "current_schema",
 852            "current_security_groups",
 853            "current_security_roles",
 854            "current_time",
 855            "current_timestamp",
 856            "current_user",
 857            "cursor",
 858            "curtime",
 859            "cycle",
 860            "data",
 861            "database",
 862            "databases",
 863            "date",
 864            "date_add",
 865            "datediff",
 866            "date_format",
 867            "date_sub",
 868            "date_trunc",
 869            "datetime",
 870            "day",
 871            "day_hour",
 872            "day_microsecond",
 873            "day_minute",
 874            "dayname",
 875            "dayofmonth",
 876            "dayofweek",
 877            "dayofyear",
 878            "day_second",
 879            "deallocate",
 880            "dec",
 881            "decimal",
 882            "declare",
 883            "decode",
 884            "default",
 885            "defaults",
 886            "deferrable",
 887            "deferred",
 888            "defined",
 889            "definer",
 890            "degrees",
 891            "delayed",
 892            "delay_key_write",
 893            "delete",
 894            "delimiter",
 895            "delimiters",
 896            "dense_rank",
 897            "desc",
 898            "describe",
 899            "detach",
 900            "deterministic",
 901            "dictionary",
 902            "differential",
 903            "directory",
 904            "disable",
 905            "discard",
 906            "_disconnect",
 907            "disk",
 908            "distinct",
 909            "distinctrow",
 910            "distributed_joins",
 911            "div",
 912            "do",
 913            "document",
 914            "domain",
 915            "dot_product",
 916            "double",
 917            "drop",
 918            "_drop_profile",
 919            "dual",
 920            "dump",
 921            "duplicate",
 922            "dynamic",
 923            "earliest",
 924            "each",
 925            "echo",
 926            "election",
 927            "else",
 928            "elseif",
 929            "elt",
 930            "enable",
 931            "enclosed",
 932            "encoding",
 933            "encrypted",
 934            "end",
 935            "engine",
 936            "engines",
 937            "enum",
 938            "errors",
 939            "escape",
 940            "escaped",
 941            "estimate",
 942            "euclidean_distance",
 943            "event",
 944            "events",
 945            "except",
 946            "exclude",
 947            "excluding",
 948            "exclusive",
 949            "execute",
 950            "exists",
 951            "exit",
 952            "exp",
 953            "explain",
 954            "extended",
 955            "extension",
 956            "external",
 957            "external_host",
 958            "external_port",
 959            "extract",
 960            "extractor",
 961            "extractors",
 962            "extra_join",
 963            "_failover",
 964            "failed_login_attempts",
 965            "failure",
 966            "false",
 967            "family",
 968            "fault",
 969            "fetch",
 970            "field",
 971            "fields",
 972            "file",
 973            "files",
 974            "fill",
 975            "first",
 976            "first_value",
 977            "fix_alter",
 978            "fixed",
 979            "float",
 980            "float4",
 981            "float8",
 982            "floor",
 983            "flush",
 984            "following",
 985            "for",
 986            "force",
 987            "force_compiled_mode",
 988            "force_interpreter_mode",
 989            "foreground",
 990            "foreign",
 991            "format",
 992            "forward",
 993            "found_rows",
 994            "freeze",
 995            "from",
 996            "from_base64",
 997            "from_days",
 998            "from_unixtime",
 999            "fs",
1000            "_fsync",
1001            "full",
1002            "fulltext",
1003            "function",
1004            "functions",
1005            "gc",
1006            "gcs",
1007            "get_format",
1008            "_gc",
1009            "_gcx",
1010            "generate",
1011            "geography",
1012            "geography_area",
1013            "geography_contains",
1014            "geography_distance",
1015            "geography_intersects",
1016            "geography_latitude",
1017            "geography_length",
1018            "geography_longitude",
1019            "geographypoint",
1020            "geography_point",
1021            "geography_within_distance",
1022            "geometry",
1023            "geometry_area",
1024            "geometry_contains",
1025            "geometry_distance",
1026            "geometry_filter",
1027            "geometry_intersects",
1028            "geometry_length",
1029            "geometrypoint",
1030            "geometry_point",
1031            "geometry_within_distance",
1032            "geometry_x",
1033            "geometry_y",
1034            "global",
1035            "_global_version_timestamp",
1036            "grant",
1037            "granted",
1038            "grants",
1039            "greatest",
1040            "group",
1041            "grouping",
1042            "groups",
1043            "group_concat",
1044            "gzip",
1045            "handle",
1046            "handler",
1047            "hard_cpu_limit_percentage",
1048            "hash",
1049            "has_temp_tables",
1050            "having",
1051            "hdfs",
1052            "header",
1053            "heartbeat_no_logging",
1054            "hex",
1055            "highlight",
1056            "high_priority",
1057            "hold",
1058            "holding",
1059            "host",
1060            "hosts",
1061            "hour",
1062            "hour_microsecond",
1063            "hour_minute",
1064            "hour_second",
1065            "identified",
1066            "identity",
1067            "if",
1068            "ifnull",
1069            "ignore",
1070            "ilike",
1071            "immediate",
1072            "immutable",
1073            "implicit",
1074            "import",
1075            "in",
1076            "including",
1077            "increment",
1078            "incremental",
1079            "index",
1080            "indexes",
1081            "inet_aton",
1082            "inet_ntoa",
1083            "inet6_aton",
1084            "inet6_ntoa",
1085            "infile",
1086            "inherit",
1087            "inherits",
1088            "_init_profile",
1089            "init",
1090            "initcap",
1091            "initialize",
1092            "initially",
1093            "inject",
1094            "inline",
1095            "inner",
1096            "inout",
1097            "input",
1098            "insensitive",
1099            "insert",
1100            "insert_method",
1101            "instance",
1102            "instead",
1103            "instr",
1104            "int",
1105            "int1",
1106            "int2",
1107            "int3",
1108            "int4",
1109            "int8",
1110            "integer",
1111            "_internal_dynamic_typecast",
1112            "interpreter_mode",
1113            "intersect",
1114            "interval",
1115            "into",
1116            "invoker",
1117            "is",
1118            "isnull",
1119            "isolation",
1120            "iterate",
1121            "join",
1122            "json",
1123            "json_agg",
1124            "json_array_contains_double",
1125            "json_array_contains_json",
1126            "json_array_contains_string",
1127            "json_array_push_double",
1128            "json_array_push_json",
1129            "json_array_push_string",
1130            "json_delete_key",
1131            "json_extract_double",
1132            "json_extract_json",
1133            "json_extract_string",
1134            "json_extract_bigint",
1135            "json_get_type",
1136            "json_length",
1137            "json_set_double",
1138            "json_set_json",
1139            "json_set_string",
1140            "json_splice_double",
1141            "json_splice_json",
1142            "json_splice_string",
1143            "kafka",
1144            "key",
1145            "key_block_size",
1146            "keys",
1147            "kill",
1148            "killall",
1149            "label",
1150            "lag",
1151            "language",
1152            "large",
1153            "last",
1154            "last_day",
1155            "last_insert_id",
1156            "last_value",
1157            "lateral",
1158            "latest",
1159            "lc_collate",
1160            "lc_ctype",
1161            "lcase",
1162            "lead",
1163            "leading",
1164            "leaf",
1165            "leakproof",
1166            "least",
1167            "leave",
1168            "leaves",
1169            "left",
1170            "length",
1171            "level",
1172            "license",
1173            "like",
1174            "limit",
1175            "lines",
1176            "listen",
1177            "llvm",
1178            "ln",
1179            "load",
1180            "loaddata_where",
1181            "_load",
1182            "local",
1183            "localtime",
1184            "localtimestamp",
1185            "locate",
1186            "location",
1187            "lock",
1188            "log",
1189            "log10",
1190            "log2",
1191            "long",
1192            "longblob",
1193            "longtext",
1194            "loop",
1195            "lower",
1196            "low_priority",
1197            "lpad",
1198            "_ls",
1199            "ltrim",
1200            "lz4",
1201            "management",
1202            "_management_thread",
1203            "mapping",
1204            "master",
1205            "match",
1206            "materialized",
1207            "max",
1208            "maxvalue",
1209            "max_concurrency",
1210            "max_errors",
1211            "max_partitions_per_batch",
1212            "max_queue_depth",
1213            "max_retries_per_batch_partition",
1214            "max_rows",
1215            "mbc",
1216            "md5",
1217            "mpl",
1218            "median",
1219            "mediumblob",
1220            "mediumint",
1221            "mediumtext",
1222            "member",
1223            "memory",
1224            "memory_percentage",
1225            "_memsql_table_id_lookup",
1226            "memsql",
1227            "memsql_deserialize",
1228            "memsql_imitating_kafka",
1229            "memsql_serialize",
1230            "merge",
1231            "metadata",
1232            "microsecond",
1233            "middleint",
1234            "min",
1235            "min_rows",
1236            "minus",
1237            "minute",
1238            "minute_microsecond",
1239            "minute_second",
1240            "minvalue",
1241            "mod",
1242            "mode",
1243            "model",
1244            "modifies",
1245            "modify",
1246            "month",
1247            "monthname",
1248            "months_between",
1249            "move",
1250            "mpl",
1251            "names",
1252            "named",
1253            "namespace",
1254            "national",
1255            "natural",
1256            "nchar",
1257            "next",
1258            "no",
1259            "node",
1260            "none",
1261            "no_query_rewrite",
1262            "noparam",
1263            "not",
1264            "nothing",
1265            "notify",
1266            "now",
1267            "nowait",
1268            "no_write_to_binlog",
1269            "no_query_rewrite",
1270            "norely",
1271            "nth_value",
1272            "ntile",
1273            "null",
1274            "nullcols",
1275            "nullif",
1276            "nulls",
1277            "numeric",
1278            "nvarchar",
1279            "object",
1280            "octet_length",
1281            "of",
1282            "off",
1283            "offline",
1284            "offset",
1285            "offsets",
1286            "oids",
1287            "on",
1288            "online",
1289            "only",
1290            "open",
1291            "operator",
1292            "optimization",
1293            "optimize",
1294            "optimizer",
1295            "optimizer_state",
1296            "option",
1297            "options",
1298            "optionally",
1299            "or",
1300            "order",
1301            "ordered_serialize",
1302            "orphan",
1303            "out",
1304            "out_of_order",
1305            "outer",
1306            "outfile",
1307            "over",
1308            "overlaps",
1309            "overlay",
1310            "owned",
1311            "owner",
1312            "pack_keys",
1313            "paired",
1314            "parser",
1315            "parquet",
1316            "partial",
1317            "partition",
1318            "partition_id",
1319            "partitioning",
1320            "partitions",
1321            "passing",
1322            "password",
1323            "password_lock_time",
1324            "parser",
1325            "pause",
1326            "_pause_replay",
1327            "percent_rank",
1328            "percentile_cont",
1329            "percentile_disc",
1330            "periodic",
1331            "persisted",
1332            "pi",
1333            "pipeline",
1334            "pipelines",
1335            "pivot",
1336            "placing",
1337            "plan",
1338            "plans",
1339            "plancache",
1340            "plugins",
1341            "pool",
1342            "pools",
1343            "port",
1344            "position",
1345            "pow",
1346            "power",
1347            "preceding",
1348            "precision",
1349            "prepare",
1350            "prepared",
1351            "preserve",
1352            "primary",
1353            "prior",
1354            "privileges",
1355            "procedural",
1356            "procedure",
1357            "procedures",
1358            "process",
1359            "processlist",
1360            "profile",
1361            "profiles",
1362            "program",
1363            "promote",
1364            "proxy",
1365            "purge",
1366            "quarter",
1367            "queries",
1368            "query",
1369            "query_timeout",
1370            "queue",
1371            "quote",
1372            "radians",
1373            "rand",
1374            "range",
1375            "rank",
1376            "read",
1377            "_read",
1378            "reads",
1379            "real",
1380            "reassign",
1381            "rebalance",
1382            "recheck",
1383            "record",
1384            "recursive",
1385            "redundancy",
1386            "redundant",
1387            "ref",
1388            "reference",
1389            "references",
1390            "refresh",
1391            "regexp",
1392            "reindex",
1393            "relative",
1394            "release",
1395            "reload",
1396            "rely",
1397            "remote",
1398            "remove",
1399            "rename",
1400            "repair",
1401            "_repair_table",
1402            "repeat",
1403            "repeatable",
1404            "_repl",
1405            "_reprovisioning",
1406            "replace",
1407            "replica",
1408            "replicate",
1409            "replicating",
1410            "replication",
1411            "durability",
1412            "require",
1413            "resource",
1414            "resource_pool",
1415            "reset",
1416            "restart",
1417            "restore",
1418            "restrict",
1419            "result",
1420            "_resurrect",
1421            "retry",
1422            "return",
1423            "returning",
1424            "returns",
1425            "reverse",
1426            "revoke",
1427            "rg_pool",
1428            "right",
1429            "right_anti_join",
1430            "right_semi_join",
1431            "right_straight_join",
1432            "rlike",
1433            "role",
1434            "roles",
1435            "rollback",
1436            "rollup",
1437            "round",
1438            "routine",
1439            "row",
1440            "row_count",
1441            "row_format",
1442            "row_number",
1443            "rows",
1444            "rowstore",
1445            "rule",
1446            "rpad",
1447            "_rpc",
1448            "rtrim",
1449            "running",
1450            "s3",
1451            "safe",
1452            "save",
1453            "savepoint",
1454            "scalar",
1455            "schema",
1456            "schemas",
1457            "schema_binding",
1458            "scroll",
1459            "search",
1460            "second",
1461            "second_microsecond",
1462            "sec_to_time",
1463            "security",
1464            "select",
1465            "semi_join",
1466            "_send_threads",
1467            "sensitive",
1468            "separator",
1469            "sequence",
1470            "sequences",
1471            "serial",
1472            "serializable",
1473            "series",
1474            "service_user",
1475            "server",
1476            "session",
1477            "session_user",
1478            "set",
1479            "setof",
1480            "security_lists_intersect",
1481            "sha",
1482            "sha1",
1483            "sha2",
1484            "shard",
1485            "sharded",
1486            "sharded_id",
1487            "share",
1488            "show",
1489            "shutdown",
1490            "sigmoid",
1491            "sign",
1492            "signal",
1493            "similar",
1494            "simple",
1495            "site",
1496            "signed",
1497            "sin",
1498            "skip",
1499            "skipped_batches",
1500            "sleep",
1501            "_sleep",
1502            "smallint",
1503            "snapshot",
1504            "_snapshot",
1505            "_snapshots",
1506            "soft_cpu_limit_percentage",
1507            "some",
1508            "soname",
1509            "sparse",
1510            "spatial",
1511            "spatial_check_index",
1512            "specific",
1513            "split",
1514            "sql",
1515            "sql_big_result",
1516            "sql_buffer_result",
1517            "sql_cache",
1518            "sql_calc_found_rows",
1519            "sqlexception",
1520            "sql_mode",
1521            "sql_no_cache",
1522            "sql_no_logging",
1523            "sql_small_result",
1524            "sqlstate",
1525            "sqlwarning",
1526            "sqrt",
1527            "ssl",
1528            "stable",
1529            "standalone",
1530            "start",
1531            "starting",
1532            "state",
1533            "statement",
1534            "statistics",
1535            "stats",
1536            "status",
1537            "std",
1538            "stddev",
1539            "stddev_pop",
1540            "stddev_samp",
1541            "stdin",
1542            "stdout",
1543            "stop",
1544            "storage",
1545            "str_to_date",
1546            "straight_join",
1547            "strict",
1548            "string",
1549            "strip",
1550            "subdate",
1551            "substr",
1552            "substring",
1553            "substring_index",
1554            "success",
1555            "sum",
1556            "super",
1557            "symmetric",
1558            "sync_snapshot",
1559            "sync",
1560            "_sync",
1561            "_sync2",
1562            "_sync_partitions",
1563            "_sync_snapshot",
1564            "synchronize",
1565            "sysid",
1566            "system",
1567            "table",
1568            "table_checksum",
1569            "tables",
1570            "tablespace",
1571            "tags",
1572            "tan",
1573            "target_size",
1574            "task",
1575            "temp",
1576            "template",
1577            "temporary",
1578            "temptable",
1579            "_term_bump",
1580            "terminate",
1581            "terminated",
1582            "test",
1583            "text",
1584            "then",
1585            "time",
1586            "timediff",
1587            "time_bucket",
1588            "time_format",
1589            "timeout",
1590            "timestamp",
1591            "timestampadd",
1592            "timestampdiff",
1593            "timezone",
1594            "time_to_sec",
1595            "tinyblob",
1596            "tinyint",
1597            "tinytext",
1598            "to",
1599            "to_base64",
1600            "to_char",
1601            "to_date",
1602            "to_days",
1603            "to_json",
1604            "to_number",
1605            "to_seconds",
1606            "to_timestamp",
1607            "tracelogs",
1608            "traditional",
1609            "trailing",
1610            "transform",
1611            "transaction",
1612            "_transactions_experimental",
1613            "treat",
1614            "trigger",
1615            "triggers",
1616            "trim",
1617            "true",
1618            "trunc",
1619            "truncate",
1620            "trusted",
1621            "two_phase",
1622            "_twopcid",
1623            "type",
1624            "types",
1625            "ucase",
1626            "unbounded",
1627            "uncommitted",
1628            "undefined",
1629            "undo",
1630            "unencrypted",
1631            "unenforced",
1632            "unhex",
1633            "unhold",
1634            "unicode",
1635            "union",
1636            "unique",
1637            "_unittest",
1638            "unix_timestamp",
1639            "unknown",
1640            "unlisten",
1641            "_unload",
1642            "unlock",
1643            "unlogged",
1644            "unpivot",
1645            "unsigned",
1646            "until",
1647            "update",
1648            "upgrade",
1649            "upper",
1650            "usage",
1651            "use",
1652            "user",
1653            "users",
1654            "using",
1655            "utc_date",
1656            "utc_time",
1657            "utc_timestamp",
1658            "_utf8",
1659            "vacuum",
1660            "valid",
1661            "validate",
1662            "validator",
1663            "value",
1664            "values",
1665            "varbinary",
1666            "varchar",
1667            "varcharacter",
1668            "variables",
1669            "variadic",
1670            "variance",
1671            "var_pop",
1672            "var_samp",
1673            "varying",
1674            "vector_sub",
1675            "verbose",
1676            "version",
1677            "view",
1678            "void",
1679            "volatile",
1680            "voting",
1681            "wait",
1682            "_wake",
1683            "warnings",
1684            "week",
1685            "weekday",
1686            "weekofyear",
1687            "when",
1688            "where",
1689            "while",
1690            "whitespace",
1691            "window",
1692            "with",
1693            "without",
1694            "within",
1695            "_wm_heartbeat",
1696            "work",
1697            "workload",
1698            "wrapper",
1699            "write",
1700            "xact_id",
1701            "xor",
1702            "year",
1703            "year_month",
1704            "yes",
1705            "zerofill",
1706            "zone",
1707        }
1708
1709        def jsonextractscalar_sql(self, expression: exp.JSONExtractScalar) -> str:
1710            json_type = expression.args.get("json_type")
1711            func_name = "JSON_EXTRACT_JSON" if json_type is None else f"JSON_EXTRACT_{json_type}"
1712            return json_extract_segments(func_name)(self, expression)
1713
1714        def jsonbextractscalar_sql(self, expression: exp.JSONBExtractScalar) -> str:
1715            json_type = expression.args.get("json_type")
1716            func_name = "BSON_EXTRACT_BSON" if json_type is None else f"BSON_EXTRACT_{json_type}"
1717            return json_extract_segments(func_name)(self, expression)
1718
1719        def jsonextractarray_sql(self, expression: exp.JSONExtractArray) -> str:
1720            self.unsupported("Arrays are not supported in SingleStore")
1721            return self.function_fallback_sql(expression)
1722
1723        @unsupported_args("on_condition")
1724        def jsonvalue_sql(self, expression: exp.JSONValue) -> str:
1725            res: exp.Expression = exp.JSONExtractScalar(
1726                this=expression.this,
1727                expression=expression.args.get("path"),
1728                json_type="STRING",
1729            )
1730
1731            returning = expression.args.get("returning")
1732            if returning is not None:
1733                res = exp.Cast(this=res, to=returning)
1734
1735            return self.sql(res)
1736
1737        def all_sql(self, expression: exp.All) -> str:
1738            self.unsupported("ALL subquery predicate is not supported in SingleStore")
1739            return super().all_sql(expression)
1740
1741        def jsonarraycontains_sql(self, expression: exp.JSONArrayContains) -> str:
1742            json_type = expression.text("json_type").upper()
1743
1744            if json_type:
1745                return self.func(
1746                    f"JSON_ARRAY_CONTAINS_{json_type}", expression.expression, expression.this
1747                )
1748
1749            return self.func(
1750                "JSON_ARRAY_CONTAINS_JSON",
1751                expression.expression,
1752                self.func("TO_JSON", expression.this),
1753            )
1754
1755        @unsupported_args("kind", "nested", "values")
1756        def datatype_sql(self, expression: exp.DataType) -> str:
1757            if expression.is_type(exp.DataType.Type.VARBINARY) and not expression.expressions:
1758                # `VARBINARY` must always have a size - if it doesn't, we always generate `BLOB`
1759                return "BLOB"
1760            if expression.is_type(
1761                exp.DataType.Type.DECIMAL32,
1762                exp.DataType.Type.DECIMAL64,
1763                exp.DataType.Type.DECIMAL128,
1764                exp.DataType.Type.DECIMAL256,
1765            ):
1766                scale = self.expressions(expression, flat=True)
1767
1768                if expression.is_type(exp.DataType.Type.DECIMAL32):
1769                    precision = "9"
1770                elif expression.is_type(exp.DataType.Type.DECIMAL64):
1771                    precision = "18"
1772                elif expression.is_type(exp.DataType.Type.DECIMAL128):
1773                    precision = "38"
1774                else:
1775                    # 65 is a maximum precision supported in SingleStore
1776                    precision = "65"
1777                if scale is not None:
1778                    return f"DECIMAL({precision}, {scale[0]})"
1779                else:
1780                    return f"DECIMAL({precision})"
1781            if expression.is_type(exp.DataType.Type.VECTOR):
1782                expressions = expression.expressions
1783                if len(expressions) == 2:
1784                    type_name = self.sql(expressions[0])
1785                    if type_name in self.dialect.INVERSE_VECTOR_TYPE_ALIASES:
1786                        type_name = self.dialect.INVERSE_VECTOR_TYPE_ALIASES[type_name]
1787
1788                    return f"VECTOR({self.sql(expressions[1])}, {type_name})"
1789
1790            return super().datatype_sql(expression)
1791
1792        def collate_sql(self, expression: exp.Collate) -> str:
1793            # SingleStore does not support setting a collation for column in the SELECT query,
1794            # so we cast column to a LONGTEXT type with specific collation
1795            return self.binary(expression, ":> LONGTEXT COLLATE")
1796
1797        def currentdate_sql(self, expression: exp.CurrentDate) -> str:
1798            timezone = expression.this
1799            if timezone:
1800                if isinstance(timezone, exp.Literal) and timezone.name.lower() == "utc":
1801                    return self.func("UTC_DATE")
1802                self.unsupported("CurrentDate with timezone is not supported in SingleStore")
1803
1804            return self.func("CURRENT_DATE")
1805
1806        def currenttime_sql(self, expression: exp.CurrentTime) -> str:
1807            arg = expression.this
1808            if arg:
1809                if isinstance(arg, exp.Literal) and arg.name.lower() == "utc":
1810                    return self.func("UTC_TIME")
1811                if isinstance(arg, exp.Literal) and arg.is_number:
1812                    return self.func("CURRENT_TIME", arg)
1813                self.unsupported("CurrentTime with timezone is not supported in SingleStore")
1814
1815            return self.func("CURRENT_TIME")
1816
1817        def currenttimestamp_sql(self, expression: exp.CurrentTimestamp) -> str:
1818            arg = expression.this
1819            if arg:
1820                if isinstance(arg, exp.Literal) and arg.name.lower() == "utc":
1821                    return self.func("UTC_TIMESTAMP")
1822                if isinstance(arg, exp.Literal) and arg.is_number:
1823                    return self.func("CURRENT_TIMESTAMP", arg)
1824                self.unsupported("CurrentTimestamp with timezone is not supported in SingleStore")
1825
1826            return self.func("CURRENT_TIMESTAMP")
1827
1828        def standardhash_sql(self, expression: exp.StandardHash) -> str:
1829            hash_function = expression.expression
1830            if hash_function is None:
1831                return self.func("SHA", expression.this)
1832            if isinstance(hash_function, exp.Literal):
1833                if hash_function.name.lower() == "sha":
1834                    return self.func("SHA", expression.this)
1835                if hash_function.name.lower() == "md5":
1836                    return self.func("MD5", expression.this)
1837
1838                self.unsupported(
1839                    f"{hash_function.this} hash method is not supported in SingleStore"
1840                )
1841                return self.func("SHA", expression.this)
1842
1843            self.unsupported("STANDARD_HASH function is not supported in SingleStore")
1844            return self.func("SHA", expression.this)
1845
1846        @unsupported_args("is_database", "exists", "cluster", "identity", "option", "partition")
1847        def truncatetable_sql(self, expression: exp.TruncateTable) -> str:
1848            statements = []
1849            for expression in expression.expressions:
1850                statements.append(f"TRUNCATE {self.sql(expression)}")
1851
1852            return "; ".join(statements)
1853
1854        @unsupported_args("exists")
1855        def renamecolumn_sql(self, expression: exp.RenameColumn) -> str:
1856            old_column = self.sql(expression, "this")
1857            new_column = self.sql(expression, "to")
1858            return f"CHANGE {old_column} {new_column}"
1859
1860        @unsupported_args("drop", "comment", "allow_null", "visible", "using")
1861        def altercolumn_sql(self, expression: exp.AlterColumn) -> str:
1862            alter = super().altercolumn_sql(expression)
1863
1864            collate = self.sql(expression, "collate")
1865            collate = f" COLLATE {collate}" if collate else ""
1866            return f"{alter}{collate}"
1867
1868        def computedcolumnconstraint_sql(self, expression: exp.ComputedColumnConstraint) -> str:
1869            this = self.sql(expression, "this")
1870            not_null = " NOT NULL" if expression.args.get("not_null") else ""
1871            type = self.sql(expression, "data_type") or "AUTO"
1872            return f"AS {this} PERSISTED {type}{not_null}"

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:
326        @staticmethod
327        def _unicode_substitute(m: re.Match[str]) -> str:
328            # Interpret the number as hex and convert it to the Unicode string
329            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.JSONBContainsAnyTopKeys'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.JSONBContainsAllTopKeys'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.JSONBDeleteAtPath'>: <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.National'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.Reduce'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.MatchAgainst'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.Show'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.Describe'>: <function SingleStore.Generator.<lambda>>}
UNSUPPORTED_TYPES = {<Type.TSRANGE: 'TSRANGE'>, <Type.UINT256: 'UINT256'>, <Type.NUMRANGE: 'NUMRANGE'>, <Type.INT4RANGE: 'INT4RANGE'>, <Type.USERDEFINED: 'USER-DEFINED'>, <Type.INT256: 'INT256'>, <Type.VARIANT: 'VARIANT'>, <Type.IPPREFIX: 'IPPREFIX'>, <Type.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <Type.STRUCT: 'STRUCT'>, <Type.HSTORE: 'HSTORE'>, <Type.DYNAMIC: 'DYNAMIC'>, <Type.HLLSKETCH: 'HLLSKETCH'>, <Type.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <Type.TSTZRANGE: 'TSTZRANGE'>, <Type.INET: 'INET'>, <Type.DATERANGE: 'DATERANGE'>, <Type.UNION: 'UNION'>, <Type.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <Type.TDIGEST: 'TDIGEST'>, <Type.NESTED: 'NESTED'>, <Type.NOTHING: 'NOTHING'>, <Type.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <Type.IPV6: 'IPV6'>, <Type.IPV4: 'IPV4'>, <Type.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <Type.XML: 'XML'>, <Type.UNKNOWN: 'UNKNOWN'>, <Type.TSMULTIRANGE: 'TSMULTIRANGE'>, <Type.LIST: 'LIST'>, <Type.OBJECT: 'OBJECT'>, <Type.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <Type.MONEY: 'MONEY'>, <Type.RANGE: 'RANGE'>, <Type.UUID: 'UUID'>, <Type.SUPER: 'SUPER'>, <Type.UINT128: 'UINT128'>, <Type.SMALLMONEY: 'SMALLMONEY'>, <Type.ARRAY: 'ARRAY'>, <Type.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <Type.SMALLSERIAL: 'SMALLSERIAL'>, <Type.LOWCARDINALITY: 'LOWCARDINALITY'>, <Type.TIMETZ: 'TIMETZ'>, <Type.MULTILINESTRING: 'MULTILINESTRING'>, <Type.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <Type.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <Type.BIGSERIAL: 'BIGSERIAL'>, <Type.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <Type.ROWVERSION: 'ROWVERSION'>, <Type.IPADDRESS: 'IPADDRESS'>, <Type.SERIAL: 'SERIAL'>, <Type.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <Type.BPCHAR: 'BPCHAR'>, <Type.INT8RANGE: 'INT8RANGE'>, <Type.IMAGE: 'IMAGE'>, <Type.INTERVAL: 'INTERVAL'>, <Type.INT128: 'INT128'>, <Type.MAP: 'MAP'>, <Type.NAME: 'NAME'>, <Type.NULL: 'NULL'>}
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 = {'query', 'row_number', 'geometry_length', 'stdout', 'double', 'listen', 'json_delete_key', 'stable', 'pipelines', 'column', 'grants', 'stddev_samp', 'intersect', 'standalone', 'validate', 'profile', 'time_to_sec', 'inject', 'pool', 'document', 'smallint', 'comment', 'next', 'utc_timestamp', 'orphan', 'system', 'dual', 'snapshot', 'geography_distance', 'import', 'owner', 'sql_big_result', 'interval', 'std', 'inout', 'delay_key_write', 'exclusive', 'last', 'geometry_area', 'mod', 'str_to_date', 'setof', 'validator', 'count', 'day_hour', 'minus', 'placing', 'paired', '_term_bump', 'substring_index', 'begin', 'range', 'sqlexception', 'hash', 'zone', 'engines', 'absolute', 'log2', 'including', 'noparam', 'geometry_filter', 'transaction', 'service_user', 'minute_microsecond', 'rtrim', 'group', 'var_pop', 'geometry_y', 'resource', 'exclude', 'usage', 'inner', 'position', '_disconnect', 'int8', 'union', 'full', 'timezone', 'where', 'nothing', 'all', 'dayname', 'initialize', 'redundancy', 'found_rows', 'overlay', 'wrapper', 'long', 'using', 'location', 'nchar', 'cross', 'compressed', 'euclidean_distance', '_sync_snapshot', 'geography_within_distance', 'within', 'soft_cpu_limit_percentage', 'constraint', 'straight_join', 'hour_microsecond', 'always', 'nulls', 'availability', 'quote', 'errors', 'skip', 'octet_length', 'real', 'conv', 'exp', 'proxy', 'aggregates', 'avg_row_length', 'table_checksum', 'rule', 'mode', 'no_query_rewrite', 'committed', 'global', 'now', 'window', 'generate', 'split', 'verbose', 'level', 'uncommitted', 'specific', 'to', 'percentile_cont', 'repeatable', 'concurrent', 'lines', 'metadata', 'oids', 'first_value', 'void', 'memsql_serialize', 'restrict', 'elseif', 'sensitive', 'hour_minute', 'sha2', 'alter', 'aes_decrypt', 'security', 'valid', 'extractors', 'concurrently', 'llvm', 'localtimestamp', 'coalesce', 'backward', 'current_user', 'interpreter_mode', 'any_value', 'data', 'foreign', '_snapshots', 'compression', 'restore', '_transactions_experimental', 'fetch', 'optimize', 'bucket_count', 'geometry', 'reverse', 'with', 's3', 'log10', 'vector_sub', 'instead', 'parser', 'of', 'upgrade', 'zerofill', 'failure', 'decode', 'and', 'execute', 'false', 'timestampdiff', 'sync', '_memsql_table_id_lookup', 'locate', 'stddev', 'upper', 'optimization', 'memsql_imitating_kafka', 'current_role', 'delimiter', 'rg_pool', 'mediumint', 'assertion', 'inherits', 'national', 'cube', 'object', 'power', '_ls', 'convert', 'into', 'to_date', 'distinctrow', 'identity', 'yes', 'strip', 'modifies', 'float8', 'ntile', 'cume_dist', 'granted', 'resource_pool', 'sync_snapshot', 'statistics', 'curtime', '_load', 'json_array_contains_double', '_utf8', 'geography_contains', 'algorithm', 'pools', 'before', 'date_format', 'match', 'max_concurrency', 'case', 'ifnull', 'degrees', 'from', 'any', 'cost', '_unittest', 'int1', 'hdfs', 'weekday', 'right', 'terminate', 'while', 'unknown', 'heartbeat_no_logging', 'truncate', 'both', 'record', 'following', 'parquet', 'hour', 'sql_no_logging', 'indexes', 'fixed', 'initcap', 'approx_count_distinct_accumulate', 'arrange', 'ignore', 'aggregators', 'sysid', 'called', 'ordered_serialize', 'has_temp_tables', 'date_sub', 'autostats_sampling', 'precision', 'limit', 'memsql', 'substring', 'field', 'floor', 'json_extract_double', 'options', 'default', '_batch_size_limit', 'key_block_size', 'fault', 'primary', 'soname', 'similar', 'catalog', 'bit_and', 'partial', 'unicode', 'immediate', 'arghistory', 'desc', 'select', 'asymmetric', 'second_microsecond', 'asin', 'bit_or', '_gcx', 'log', 'unlisten', 'insert', 'escaped', 'workload', 'date_trunc', 'restart', 'azure', 'partition', 'int3', 'longtext', 'encrypted', 'encoding', 'first', 'roles', '_sync2', 'lc_ctype', 'dayofyear', 'rollback', 'join', 'round', 'nullcols', '_check_can_connect', 'hard_cpu_limit_percentage', 'max_errors', 'strict', 'unenforced', 'ascii', 'unhex', 'boolean', 'lz4', 'approx_count_distinct_estimate', 'minvalue', 'handler', 'sql_calc_found_rows', 'save', 'current_security_roles', 'users', 'replication', 'external_port', 'weekofyear', 'collate', 'partitions', 'rank', 'close', 'warnings', 'cos', 'last_value', 'language', 'json_set_double', 'bit_count', 'show', 'auto_reprovision', 'abs', '_background_threads_for_cleanup', 'timestamp', 'longblob', 'mediumtext', 'access', 'family', 'infile', 'durability', 'offset', 'continue', 'defined', 'second', 'transform', 'cache', 'two_phase', 'deferrable', 'day', 'engine', 'reads', 'ssl', 'remote', 'hour_second', 'nvarchar', 'reassign', 'mpl', 'declare', 'sin', 'reset', 'collation', 'rand', 'sigmoid', 'reference', 'deferred', 'json_array_push_json', 'some', 'checkpoint', 'auto', 'sum', 'cast', 'geography_point', 'avg', 'sql_mode', 'year', 'percentile_disc', 'pivot', 'kill', 'pause', 'over', 'or', 'last_day', 'async', 'geometry_intersects', 'checksum', 'integer', 'subdate', '_commit_log_tail', 'max_rows', 'ucase', 'var_samp', 'gc', 'preceding', 'recheck', 'revoke', 'to_base64', 'mapping', 'initially', 'bin', 'clustered', 'open', 'election', 'regexp', 'move', 'hosts', 'master', 'types', 'insensitive', 'holding', 'characteristics', 'external', '_reprovisioning', 'cursor', 'forward', 'purge', '_rpc', 'undefined', 'sharded', 'schema', 'unsigned', 'background', 'only', 'cot', 'minute_second', 'inline', 'cluster', 'optimizer', 'character', 'geometry_within_distance', 'password_lock_time', 'percent_rank', 'instance', 'materialized', 'radians', 'when', 'addtime', 'json_array_push_string', '_gc', 'pipeline', 'autostats', 'definer', 'geometry_point', 'management', 'no_write_to_binlog', 'pow', 'batches', 'then', 'model', 'label', 'session_user', 'immutable', 'median', 'rename', 'start', 'delayed', 'true', 'connection', 'server', 'cascade', 'undo', 'json', 'create', 'schema_binding', 'variance', 'function', '_management_thread', 'offsets', 'insert_method', 'lpad', 'autostats_histogram_mode', 'replicate', 'fix_alter', 'geometry_x', 'min', 'numeric', 'persisted', 'delimiters', 'local', 'day_microsecond', 'variadic', 'procedural', 'set', 'event', 'approx_count_distinct_combine', 'collect', 'binary', 'inet_aton', 'to_timestamp', 'extension', 'plans', 'instr', 'references', 'row_count', 'dot_product', 'order', 'role', 'tinytext', 'tags', 'leaf', 'deallocate', 'shutdown', 'columnar', 'copy', 'json_extract_bigint', 'modify', 'unhold', 'sec_to_time', 'except', 'rollup', 'row_format', 'approx_percentile', 'between', 'simple', 'on', 'account', '_binary', 'memsql_deserialize', 'atan2', 'dictionary', 'geography_area', 'replace', 'length', 'current', 'varying', 'ln', 'enable', 'extractor', 'detach', 'plancache', 'promote', 'concat_ws', 'incremental', 'database', 'day_minute', 'target_size', 'against', 'ltrim', '_read', 'kafka', 'read', 'drop', 'replica', 'charset', 'inet_ntoa', 'defaults', 'nullif', 'commit', 'quarter', 'ceiling', 'spatial_check_index', 'temporary', 'ilike', 'spatial', 'disk', 'ref', 'queries', 'to_seconds', '_wake', 'program', 'leave', 'sequence', 'privileges', '_check_consistency', 'partition_id', 'datediff', 'off', 'without', 'highlight', 'differential', 'refresh', 'pack_keys', 'max_partitions_per_batch', 'attach', 'byte_length', 'estimate', 'right_straight_join', 'namespace', 'unlogged', 'class', 'json_length', 'keys', 'success', 'explain', 'right_semi_join', 'for', 'format', 'high_priority', 'node', 'out', 'aggregate', 'unix_timestamp', 'as', 'timediff', 'shard', 'trunc', 'load', 'geography_latitude', 'geometry_distance', 'max_queue_depth', 'sqlstate', 'current_security_groups', 'signed', 'week', 'max_retries_per_batch_partition', 'datetime', 'stdin', 'to_number', 'else', 'leading', 'approx_geography_intersects', 'owned', 'max', 'gcs', 'at', 'optimizer_state', '_repl', 'to_char', 'until', 'bigint', 'tinyblob', 'condition', 'sign', 'queue', 'credentials', 'columns', 'delete', 'foreground', 'columnstore_segment_rows', 'natural', 'inet6_aton', 'json_set_string', 'convert_tz', 'values', 'json_array_push_double', '_unload', 'like', 'char_length', 'geometrypoint', 'none', 'procedure', 'temptable', 'sql_small_result', 'fulltext', 'returning', '_pause_replay', 'coercibility', 'asensitive', 'lc_collate', 'nowait', 'repeat', 'echo', 'int2', 'each', 'update', 'rpad', 'exit', 'member', 'freeze', 'stats', 'int4', 'deterministic', 'hex', 'dense_rank', 'json_agg', 'scroll', 'check', 'to_days', 'periodic', 'process', 'force', 'out_of_order', 'handle', 'dynamic', 'names', 'bool', 'prepared', 'also', 'approx_count_distinct', 'action', 'whitespace', 'columnstore', 'json_array_contains_string', 'return', 'not', '_send_threads', 'retry', 'tablespace', 'backup_history', 'atan', 'config', 'text', 'change', 'extended', 'lead', 'year_month', 'date_add', 'inet6_ntoa', 'storage', 'gzip', 'events', 'rebalance', '_bt', 'implicit', 'online', '_init_profile', 'minute', 'synchronize', 'extract', 'sleep', 'relative', 'failed_login_attempts', 'decimal', 'monthname', 'isolation', 'duplicate', 'content', 'profiles', 'analyse', 'optionally', 'lag', 'add', 'concat', 'prepare', 'sha1', '_fsync', '_repair_table', 'curdate', 'by', 'in', '_continue_replay', 'autostats_enabled', 'increment', 'time', 'blob', 'byte', 'anti_join', 'starting', 'having', 'is', 'reindex', 'connections', 'describe', 'inherit', 'assignment', 'large', 'sha', 'share', 'after', 'unlock', 'aggregator_plan_hash', 'extra_join', 'asm', 'compile', 'group_concat', 'fields', 'xor', 'unencrypted', 'exists', 'stop', 'authorization', 'sql_cache', 'view', 'running', 'super', 'notify', 'arrangement', 'batch_interval', 'license', 'utc_date', 'sqlwarning', 'null', '_core', 'aggregator', 'voting', 'geography_longitude', 'do', 'mediumblob', 'configuration', 'partitioning', 'if', 'maxvalue', 'loaddata_where', 'enclosed', 'prior', 'identified', 'use', 'serializable', 'plugins', 'get_format', 'outer', 'savepoint', 'middleint', 'clear', 'div', 'named', '_internal_dynamic_typecast', 'no', 'skipped_batches', 'localtime', 'lcase', 'from_unixtime', 'latest', 'init', 'array', 'redundant', 'databases', 'overlaps', 'float4', 'cascaded', 'template', 'client_found_rows', '_global_version_timestamp', 'vacuum', 'rely', 'file', 'flush', 'type', 'rowstore', 'returns', 'norely', 'loop', 'release', 'conversion', 'json_array_contains_json', 'tan', 'grouping', 'distributed_joins', 'header', 'call', '_failover', 'fill', 'host', 'option', 'csv', 'client', 'stddev_pop', 'unbounded', 'ceil', 'to_json', 'min_rows', 'trigger', 'trim', 'schemas', 'geography_intersects', 'query_timeout', 'geographypoint', 'bootstrap', 'month', 'bit_xor', 'asc', 'int', 'password', 'enum', 'leaves', 'autostats_cardinality_mode', 'time_format', 'end', 'sql_buffer_result', 'scalar', 'right_anti_join', 'semi_join', 'bit', 'constraints', 'chain', 'dayofweek', 'passing', 'dayofmonth', 'attribute', 'site', 'symmetric', 'hold', 'repair', 'json_extract_json', 'replicating', 'temp', 'dump', 'wait', 'statement', 'row', 'sequences', 'date', 'memory_percentage', 'force_interpreter_mode', 'utc_time', 'character_length', 'force_compiled_mode', 'backup', 'user', 'groups', 'state', 'killall', 'geography', 'fs', 'current_date', 'tracelogs', 'json_set_json', 'json_splice_json', 'lateral', 'serial', 'varcharacter', 'invoker', 'require', 'json_extract_string', 'write', 'distinct', 'greatest', 'auto_increment', 'months_between', 'table', 'current_time', 'trusted', 'call_for_pipeline', 'aes_encrypt', '_sync', 'memory', 'from_days', 'tinyint', 'json_get_type', 'input', 'merge', 'btree', 'json_splice_double', 'preserve', 'signal', 'least', 'security_lists_intersect', '_sync_partitions', '_wm_heartbeat', 'key', 'isnull', '_twopcid', 'current_timestamp', 'directory', 'trailing', 'variables', 'low_priority', 'string', 'current_schema', 'outfile', 'dec', 'rows', 'domain', 'series', 'status', 'backup_id', 'from_base64', 'routine', 'files', 'functions', 'capture', 'pi', '_sleep', 'aggregator_id', 'elt', 'test', 'operator', 'terminated', 'rlike', 'timestampadd', 'nth_value', 'avro', 'time_bucket', '_checksum', 'separator', 'adddate', 'safe', 'connection_id', 'comments', 'grant', 'admin', 'day_second', 'lock', 'json_splice_string', 'work', 'ast', 'earliest', 'tables', 'geometry_contains', '_snapshot', 'unpivot', 'version', 'batch', 'mbc', 'reload', 'task', 'compact', 'microsecond', 'unique', 'result', 'sql', 'excluding', 'acos', 'treat', 'last_insert_id', 'disable', 'char', 'index', 'left', 'recursive', 'leakproof', 'md5', 'cycle', 'external_host', '_resurrect', 'plan', 'lower', 'triggers', 'xact_id', 'geography_length', 'cnf', 'port', 'sharded_id', 'value', 'traditional', 'substr', 'discard', 'volatile', 'procedures', 'session', 'sql_no_cache', 'sqrt', 'remove', 'sparse', 'float', '_drop_profile', 'offline', 'escape', 'analyze', 'varchar', 'varbinary', 'iterate', 'current_catalog', 'timeout', 'processlist', 'search'}
def jsonextractscalar_sql(self, expression: sqlglot.expressions.JSONExtractScalar) -> str:
1709        def jsonextractscalar_sql(self, expression: exp.JSONExtractScalar) -> str:
1710            json_type = expression.args.get("json_type")
1711            func_name = "JSON_EXTRACT_JSON" if json_type is None else f"JSON_EXTRACT_{json_type}"
1712            return json_extract_segments(func_name)(self, expression)
def jsonbextractscalar_sql(self, expression: sqlglot.expressions.JSONBExtractScalar) -> str:
1714        def jsonbextractscalar_sql(self, expression: exp.JSONBExtractScalar) -> str:
1715            json_type = expression.args.get("json_type")
1716            func_name = "BSON_EXTRACT_BSON" if json_type is None else f"BSON_EXTRACT_{json_type}"
1717            return json_extract_segments(func_name)(self, expression)
def jsonextractarray_sql(self, expression: sqlglot.expressions.JSONExtractArray) -> str:
1719        def jsonextractarray_sql(self, expression: exp.JSONExtractArray) -> str:
1720            self.unsupported("Arrays are not supported in SingleStore")
1721            return self.function_fallback_sql(expression)
@unsupported_args('on_condition')
def jsonvalue_sql(self, expression: sqlglot.expressions.JSONValue) -> str:
1723        @unsupported_args("on_condition")
1724        def jsonvalue_sql(self, expression: exp.JSONValue) -> str:
1725            res: exp.Expression = exp.JSONExtractScalar(
1726                this=expression.this,
1727                expression=expression.args.get("path"),
1728                json_type="STRING",
1729            )
1730
1731            returning = expression.args.get("returning")
1732            if returning is not None:
1733                res = exp.Cast(this=res, to=returning)
1734
1735            return self.sql(res)
def all_sql(self, expression: sqlglot.expressions.All) -> str:
1737        def all_sql(self, expression: exp.All) -> str:
1738            self.unsupported("ALL subquery predicate is not supported in SingleStore")
1739            return super().all_sql(expression)
def jsonarraycontains_sql(self, expression: sqlglot.expressions.JSONArrayContains) -> str:
1741        def jsonarraycontains_sql(self, expression: exp.JSONArrayContains) -> str:
1742            json_type = expression.text("json_type").upper()
1743
1744            if json_type:
1745                return self.func(
1746                    f"JSON_ARRAY_CONTAINS_{json_type}", expression.expression, expression.this
1747                )
1748
1749            return self.func(
1750                "JSON_ARRAY_CONTAINS_JSON",
1751                expression.expression,
1752                self.func("TO_JSON", expression.this),
1753            )
@unsupported_args('kind', 'nested', 'values')
def datatype_sql(self, expression: sqlglot.expressions.DataType) -> str:
1755        @unsupported_args("kind", "nested", "values")
1756        def datatype_sql(self, expression: exp.DataType) -> str:
1757            if expression.is_type(exp.DataType.Type.VARBINARY) and not expression.expressions:
1758                # `VARBINARY` must always have a size - if it doesn't, we always generate `BLOB`
1759                return "BLOB"
1760            if expression.is_type(
1761                exp.DataType.Type.DECIMAL32,
1762                exp.DataType.Type.DECIMAL64,
1763                exp.DataType.Type.DECIMAL128,
1764                exp.DataType.Type.DECIMAL256,
1765            ):
1766                scale = self.expressions(expression, flat=True)
1767
1768                if expression.is_type(exp.DataType.Type.DECIMAL32):
1769                    precision = "9"
1770                elif expression.is_type(exp.DataType.Type.DECIMAL64):
1771                    precision = "18"
1772                elif expression.is_type(exp.DataType.Type.DECIMAL128):
1773                    precision = "38"
1774                else:
1775                    # 65 is a maximum precision supported in SingleStore
1776                    precision = "65"
1777                if scale is not None:
1778                    return f"DECIMAL({precision}, {scale[0]})"
1779                else:
1780                    return f"DECIMAL({precision})"
1781            if expression.is_type(exp.DataType.Type.VECTOR):
1782                expressions = expression.expressions
1783                if len(expressions) == 2:
1784                    type_name = self.sql(expressions[0])
1785                    if type_name in self.dialect.INVERSE_VECTOR_TYPE_ALIASES:
1786                        type_name = self.dialect.INVERSE_VECTOR_TYPE_ALIASES[type_name]
1787
1788                    return f"VECTOR({self.sql(expressions[1])}, {type_name})"
1789
1790            return super().datatype_sql(expression)
def collate_sql(self, expression: sqlglot.expressions.Collate) -> str:
1792        def collate_sql(self, expression: exp.Collate) -> str:
1793            # SingleStore does not support setting a collation for column in the SELECT query,
1794            # so we cast column to a LONGTEXT type with specific collation
1795            return self.binary(expression, ":> LONGTEXT COLLATE")
def currentdate_sql(self, expression: sqlglot.expressions.CurrentDate) -> str:
1797        def currentdate_sql(self, expression: exp.CurrentDate) -> str:
1798            timezone = expression.this
1799            if timezone:
1800                if isinstance(timezone, exp.Literal) and timezone.name.lower() == "utc":
1801                    return self.func("UTC_DATE")
1802                self.unsupported("CurrentDate with timezone is not supported in SingleStore")
1803
1804            return self.func("CURRENT_DATE")
def currenttime_sql(self, expression: sqlglot.expressions.CurrentTime) -> str:
1806        def currenttime_sql(self, expression: exp.CurrentTime) -> str:
1807            arg = expression.this
1808            if arg:
1809                if isinstance(arg, exp.Literal) and arg.name.lower() == "utc":
1810                    return self.func("UTC_TIME")
1811                if isinstance(arg, exp.Literal) and arg.is_number:
1812                    return self.func("CURRENT_TIME", arg)
1813                self.unsupported("CurrentTime with timezone is not supported in SingleStore")
1814
1815            return self.func("CURRENT_TIME")
def currenttimestamp_sql(self, expression: sqlglot.expressions.CurrentTimestamp) -> str:
1817        def currenttimestamp_sql(self, expression: exp.CurrentTimestamp) -> str:
1818            arg = expression.this
1819            if arg:
1820                if isinstance(arg, exp.Literal) and arg.name.lower() == "utc":
1821                    return self.func("UTC_TIMESTAMP")
1822                if isinstance(arg, exp.Literal) and arg.is_number:
1823                    return self.func("CURRENT_TIMESTAMP", arg)
1824                self.unsupported("CurrentTimestamp with timezone is not supported in SingleStore")
1825
1826            return self.func("CURRENT_TIMESTAMP")
def standardhash_sql(self, expression: sqlglot.expressions.StandardHash) -> str:
1828        def standardhash_sql(self, expression: exp.StandardHash) -> str:
1829            hash_function = expression.expression
1830            if hash_function is None:
1831                return self.func("SHA", expression.this)
1832            if isinstance(hash_function, exp.Literal):
1833                if hash_function.name.lower() == "sha":
1834                    return self.func("SHA", expression.this)
1835                if hash_function.name.lower() == "md5":
1836                    return self.func("MD5", expression.this)
1837
1838                self.unsupported(
1839                    f"{hash_function.this} hash method is not supported in SingleStore"
1840                )
1841                return self.func("SHA", expression.this)
1842
1843            self.unsupported("STANDARD_HASH function is not supported in SingleStore")
1844            return self.func("SHA", expression.this)
@unsupported_args('is_database', 'exists', 'cluster', 'identity', 'option', 'partition')
def truncatetable_sql(self, expression: sqlglot.expressions.TruncateTable) -> str:
1846        @unsupported_args("is_database", "exists", "cluster", "identity", "option", "partition")
1847        def truncatetable_sql(self, expression: exp.TruncateTable) -> str:
1848            statements = []
1849            for expression in expression.expressions:
1850                statements.append(f"TRUNCATE {self.sql(expression)}")
1851
1852            return "; ".join(statements)
@unsupported_args('exists')
def renamecolumn_sql(self, expression: sqlglot.expressions.RenameColumn) -> str:
1854        @unsupported_args("exists")
1855        def renamecolumn_sql(self, expression: exp.RenameColumn) -> str:
1856            old_column = self.sql(expression, "this")
1857            new_column = self.sql(expression, "to")
1858            return f"CHANGE {old_column} {new_column}"
@unsupported_args('drop', 'comment', 'allow_null', 'visible', 'using')
def altercolumn_sql(self, expression: sqlglot.expressions.AlterColumn) -> str:
1860        @unsupported_args("drop", "comment", "allow_null", "visible", "using")
1861        def altercolumn_sql(self, expression: exp.AlterColumn) -> str:
1862            alter = super().altercolumn_sql(expression)
1863
1864            collate = self.sql(expression, "collate")
1865            collate = f" COLLATE {collate}" if collate else ""
1866            return f"{alter}{collate}"
def computedcolumnconstraint_sql(self, expression: sqlglot.expressions.ComputedColumnConstraint) -> str:
1868        def computedcolumnconstraint_sql(self, expression: exp.ComputedColumnConstraint) -> str:
1869            this = self.sql(expression, "this")
1870            not_null = " NOT NULL" if expression.args.get("not_null") else ""
1871            type = self.sql(expression, "data_type") or "AUTO"
1872            return f"AS {this} PERSISTED {type}{not_null}"
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
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
mltranslate_sql
mlforecast_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
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
install_sql
get_put_sql
translatecharacters_sql
decodecase_sql
semanticview_sql
getextract_sql
datefromunixdate_sql
space_sql
buildproperty_sql
refreshtriggerproperty_sql
modelattribute_sql
directorystage_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
array_sql
arraycontainsall_sql
dpipe_sql
extract_sql
cast_sql
show_sql
chr_sql
timestamptrunc_sql
converttimezone_sql
attimezone_sql
isascii_sql
currentschema_sql