sqlglot.dialects.singlestore
1from sqlglot import TokenType 2import typing as t 3 4from sqlglot import exp 5from sqlglot.dialects.dialect import ( 6 build_formatted_time, 7 build_json_extract_path, 8 json_extract_segments, 9 json_path_key_only_name, 10 rename_func, 11 bool_xor_sql, 12 count_if_to_sum, 13 timestamptrunc_sql, 14 date_add_interval_sql, 15 timestampdiff_sql, 16) 17from sqlglot.dialects.mysql import MySQL, _remove_ts_or_ds_to_date, date_add_sql 18from sqlglot.expressions import DataType 19from sqlglot.generator import unsupported_args 20from sqlglot.helper import seq_get 21 22 23def cast_to_time6(expression: t.Optional[exp.Expression]) -> exp.Cast: 24 return exp.Cast( 25 this=expression, 26 to=exp.DataType.build( 27 exp.DataType.Type.TIME, 28 expressions=[exp.DataTypeParam(this=exp.Literal.number(6))], 29 ), 30 ) 31 32 33class SingleStore(MySQL): 34 SUPPORTS_ORDER_BY_ALL = True 35 36 TIME_MAPPING: t.Dict[str, str] = { 37 "D": "%u", # Day of week (1-7) 38 "DD": "%d", # day of month (01-31) 39 "DY": "%a", # abbreviated name of day 40 "HH": "%I", # Hour of day (01-12) 41 "HH12": "%I", # alias for HH 42 "HH24": "%H", # Hour of day (00-23) 43 "MI": "%M", # Minute (00-59) 44 "MM": "%m", # Month (01-12; January = 01) 45 "MON": "%b", # Abbreviated name of month 46 "MONTH": "%B", # Name of month 47 "SS": "%S", # Second (00-59) 48 "RR": "%y", # 15 49 "YY": "%y", # 15 50 "YYYY": "%Y", # 2015 51 "FF6": "%f", # only 6 digits are supported in python formats 52 } 53 54 class Tokenizer(MySQL.Tokenizer): 55 BYTE_STRINGS = [("e'", "'"), ("E'", "'")] 56 57 KEYWORDS = { 58 **MySQL.Tokenizer.KEYWORDS, 59 "BSON": TokenType.JSONB, 60 "GEOGRAPHYPOINT": TokenType.GEOGRAPHYPOINT, 61 "TIMESTAMP": TokenType.TIMESTAMP, 62 ":>": TokenType.COLON_GT, 63 "!:>": TokenType.NCOLON_GT, 64 "::$": TokenType.DCOLONDOLLAR, 65 "::%": TokenType.DCOLONPERCENT, 66 } 67 68 class Parser(MySQL.Parser): 69 FUNCTIONS = { 70 **MySQL.Parser.FUNCTIONS, 71 "TO_DATE": build_formatted_time(exp.TsOrDsToDate, "singlestore"), 72 "TO_TIMESTAMP": build_formatted_time(exp.StrToTime, "singlestore"), 73 "TO_CHAR": build_formatted_time(exp.ToChar, "singlestore"), 74 "STR_TO_DATE": build_formatted_time(exp.StrToDate, "mysql"), 75 "DATE_FORMAT": build_formatted_time(exp.TimeToStr, "mysql"), 76 # The first argument of following functions is converted to TIME(6) 77 # This is needed because exp.TimeToStr is converted to DATE_FORMAT 78 # which interprets the first argument as DATETIME and fails to parse 79 # string literals like '12:05:47' without a date part. 80 "TIME_FORMAT": lambda args: exp.TimeToStr( 81 this=cast_to_time6(seq_get(args, 0)), 82 format=MySQL.format_time(seq_get(args, 1)), 83 ), 84 "HOUR": lambda args: exp.cast( 85 exp.TimeToStr( 86 this=cast_to_time6(seq_get(args, 0)), 87 format=MySQL.format_time(exp.Literal.string("%k")), 88 ), 89 DataType.Type.INT, 90 ), 91 "MICROSECOND": lambda args: exp.cast( 92 exp.TimeToStr( 93 this=cast_to_time6(seq_get(args, 0)), 94 format=MySQL.format_time(exp.Literal.string("%f")), 95 ), 96 DataType.Type.INT, 97 ), 98 "SECOND": lambda args: exp.cast( 99 exp.TimeToStr( 100 this=cast_to_time6(seq_get(args, 0)), 101 format=MySQL.format_time(exp.Literal.string("%s")), 102 ), 103 DataType.Type.INT, 104 ), 105 "MINUTE": lambda args: exp.cast( 106 exp.TimeToStr( 107 this=cast_to_time6(seq_get(args, 0)), 108 format=MySQL.format_time(exp.Literal.string("%i")), 109 ), 110 DataType.Type.INT, 111 ), 112 "MONTHNAME": lambda args: exp.TimeToStr( 113 this=seq_get(args, 0), 114 format=MySQL.format_time(exp.Literal.string("%M")), 115 ), 116 "WEEKDAY": lambda args: exp.paren(exp.DayOfWeek(this=seq_get(args, 0)) + 5, copy=False) 117 % 7, 118 "UNIX_TIMESTAMP": exp.StrToUnix.from_arg_list, 119 "FROM_UNIXTIME": build_formatted_time(exp.UnixToTime, "mysql"), 120 "TIME_BUCKET": lambda args: exp.DateBin( 121 this=seq_get(args, 0), 122 expression=seq_get(args, 1), 123 origin=seq_get(args, 2), 124 ), 125 "BSON_EXTRACT_BSON": build_json_extract_path(exp.JSONBExtract), 126 "BSON_EXTRACT_STRING": build_json_extract_path( 127 exp.JSONBExtractScalar, json_type="STRING" 128 ), 129 "BSON_EXTRACT_DOUBLE": build_json_extract_path( 130 exp.JSONBExtractScalar, json_type="DOUBLE" 131 ), 132 "BSON_EXTRACT_BIGINT": build_json_extract_path( 133 exp.JSONBExtractScalar, json_type="BIGINT" 134 ), 135 "JSON_EXTRACT_JSON": build_json_extract_path(exp.JSONExtract), 136 "JSON_EXTRACT_STRING": build_json_extract_path( 137 exp.JSONExtractScalar, json_type="STRING" 138 ), 139 "JSON_EXTRACT_DOUBLE": build_json_extract_path( 140 exp.JSONExtractScalar, json_type="DOUBLE" 141 ), 142 "JSON_EXTRACT_BIGINT": build_json_extract_path( 143 exp.JSONExtractScalar, json_type="BIGINT" 144 ), 145 "JSON_ARRAY_CONTAINS_STRING": lambda args: exp.JSONArrayContains( 146 this=seq_get(args, 1), 147 expression=seq_get(args, 0), 148 json_type="STRING", 149 ), 150 "JSON_ARRAY_CONTAINS_DOUBLE": lambda args: exp.JSONArrayContains( 151 this=seq_get(args, 1), 152 expression=seq_get(args, 0), 153 json_type="DOUBLE", 154 ), 155 "JSON_ARRAY_CONTAINS_JSON": lambda args: exp.JSONArrayContains( 156 this=seq_get(args, 1), 157 expression=seq_get(args, 0), 158 json_type="JSON", 159 ), 160 "JSON_PRETTY": exp.JSONFormat.from_arg_list, 161 "DATE": exp.Date.from_arg_list, 162 "DAYNAME": lambda args: exp.TimeToStr( 163 this=seq_get(args, 0), 164 format=MySQL.format_time(exp.Literal.string("%W")), 165 ), 166 "TIMESTAMPDIFF": lambda args: exp.TimestampDiff( 167 this=seq_get(args, 2), 168 expression=seq_get(args, 1), 169 unit=seq_get(args, 0), 170 ), 171 "APPROX_COUNT_DISTINCT": exp.Hll.from_arg_list, 172 "APPROX_PERCENTILE": lambda args, dialect: exp.ApproxQuantile( 173 this=seq_get(args, 0), 174 quantile=seq_get(args, 1), 175 error_tolerance=seq_get(args, 2), 176 ), 177 "VARIANCE": exp.VariancePop.from_arg_list, 178 "INSTR": exp.Contains.from_arg_list, 179 "REGEXP_MATCH": lambda args: exp.RegexpExtractAll( 180 this=seq_get(args, 0), 181 expression=seq_get(args, 1), 182 parameters=seq_get(args, 2), 183 ), 184 "REGEXP_SUBSTR": lambda args: exp.RegexpExtract( 185 this=seq_get(args, 0), 186 expression=seq_get(args, 1), 187 position=seq_get(args, 2), 188 occurrence=seq_get(args, 3), 189 parameters=seq_get(args, 4), 190 ), 191 "REDUCE": lambda args: exp.Reduce( 192 initial=seq_get(args, 0), 193 this=seq_get(args, 1), 194 merge=seq_get(args, 2), 195 ), 196 } 197 198 CAST_COLUMN_OPERATORS = {TokenType.COLON_GT, TokenType.NCOLON_GT} 199 200 COLUMN_OPERATORS = { 201 **MySQL.Parser.COLUMN_OPERATORS, 202 TokenType.COLON_GT: lambda self, this, to: self.expression( 203 exp.Cast, 204 this=this, 205 to=to, 206 ), 207 TokenType.NCOLON_GT: lambda self, this, to: self.expression( 208 exp.TryCast, 209 this=this, 210 to=to, 211 ), 212 TokenType.DCOLON: lambda self, this, path: build_json_extract_path(exp.JSONExtract)( 213 [this, exp.Literal.string(path.name)] 214 ), 215 TokenType.DCOLONDOLLAR: lambda self, this, path: build_json_extract_path( 216 exp.JSONExtractScalar, json_type="STRING" 217 )([this, exp.Literal.string(path.name)]), 218 TokenType.DCOLONPERCENT: lambda self, this, path: build_json_extract_path( 219 exp.JSONExtractScalar, json_type="DOUBLE" 220 )([this, exp.Literal.string(path.name)]), 221 } 222 COLUMN_OPERATORS.pop(TokenType.ARROW) 223 COLUMN_OPERATORS.pop(TokenType.DARROW) 224 COLUMN_OPERATORS.pop(TokenType.HASH_ARROW) 225 COLUMN_OPERATORS.pop(TokenType.DHASH_ARROW) 226 COLUMN_OPERATORS.pop(TokenType.PLACEHOLDER) 227 228 class Generator(MySQL.Generator): 229 SUPPORTED_JSON_PATH_PARTS = { 230 exp.JSONPathKey, 231 exp.JSONPathRoot, 232 exp.JSONPathSubscript, 233 } 234 235 TRANSFORMS = { 236 **MySQL.Generator.TRANSFORMS, 237 exp.TsOrDsToDate: lambda self, e: self.func("TO_DATE", e.this, self.format_time(e)) 238 if e.args.get("format") 239 else self.func("DATE", e.this), 240 exp.StrToTime: lambda self, e: self.func("TO_TIMESTAMP", e.this, self.format_time(e)), 241 exp.ToChar: lambda self, e: self.func("TO_CHAR", e.this, self.format_time(e)), 242 exp.StrToDate: lambda self, e: self.func( 243 "STR_TO_DATE", 244 e.this, 245 self.format_time( 246 e, 247 inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING, 248 inverse_time_trie=MySQL.INVERSE_TIME_TRIE, 249 ), 250 ), 251 exp.TimeToStr: lambda self, e: self.func( 252 "DATE_FORMAT", 253 e.this, 254 self.format_time( 255 e, 256 inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING, 257 inverse_time_trie=MySQL.INVERSE_TIME_TRIE, 258 ), 259 ), 260 exp.Date: unsupported_args("zone", "expressions")(rename_func("DATE")), 261 exp.Cast: unsupported_args("format", "action", "default")( 262 lambda self, e: f"{self.sql(e, 'this')} :> {self.sql(e, 'to')}" 263 ), 264 exp.TryCast: unsupported_args("format", "action", "default")( 265 lambda self, e: f"{self.sql(e, 'this')} !:> {self.sql(e, 'to')}" 266 ), 267 exp.StrToUnix: unsupported_args("format")(rename_func("UNIX_TIMESTAMP")), 268 exp.TimeToUnix: rename_func("UNIX_TIMESTAMP"), 269 exp.TimeStrToUnix: rename_func("UNIX_TIMESTAMP"), 270 exp.UnixSeconds: rename_func("UNIX_TIMESTAMP"), 271 exp.UnixToStr: lambda self, e: self.func( 272 "FROM_UNIXTIME", 273 e.this, 274 self.format_time( 275 e, 276 inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING, 277 inverse_time_trie=MySQL.INVERSE_TIME_TRIE, 278 ), 279 ), 280 exp.UnixToTime: unsupported_args("scale", "zone", "hours", "minutes")( 281 lambda self, e: self.func( 282 "FROM_UNIXTIME", 283 e.this, 284 self.format_time( 285 e, 286 inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING, 287 inverse_time_trie=MySQL.INVERSE_TIME_TRIE, 288 ), 289 ), 290 ), 291 exp.UnixToTimeStr: lambda self, e: f"FROM_UNIXTIME({self.sql(e, 'this')}) :> TEXT", 292 exp.DateBin: unsupported_args("unit", "zone")( 293 lambda self, e: self.func("TIME_BUCKET", e.this, e.expression, e.args.get("origin")) 294 ), 295 exp.TimeStrToDate: lambda self, e: self.sql(exp.cast(e.this, exp.DataType.Type.DATE)), 296 exp.FromTimeZone: lambda self, e: self.func( 297 "CONVERT_TZ", e.this, e.args.get("zone"), "'UTC'" 298 ), 299 exp.DiToDate: lambda self, 300 e: f"STR_TO_DATE({self.sql(e, 'this')}, {SingleStore.DATEINT_FORMAT})", 301 exp.DateToDi: lambda self, 302 e: f"(DATE_FORMAT({self.sql(e, 'this')}, {SingleStore.DATEINT_FORMAT}) :> INT)", 303 exp.TsOrDiToDi: lambda self, 304 e: f"(DATE_FORMAT({self.sql(e, 'this')}, {SingleStore.DATEINT_FORMAT}) :> INT)", 305 exp.Time: unsupported_args("zone")(lambda self, e: f"{self.sql(e, 'this')} :> TIME"), 306 exp.DatetimeAdd: _remove_ts_or_ds_to_date(date_add_sql("ADD")), 307 exp.DatetimeTrunc: unsupported_args("zone")(timestamptrunc_sql()), 308 exp.DatetimeSub: date_add_interval_sql("DATE", "SUB"), 309 exp.DatetimeDiff: timestampdiff_sql, 310 exp.DateTrunc: unsupported_args("zone")(timestamptrunc_sql()), 311 exp.DateDiff: unsupported_args("zone")( 312 lambda self, e: timestampdiff_sql(self, e) 313 if e.unit is not None 314 else self.func("DATEDIFF", e.this, e.expression) 315 ), 316 exp.TimestampTrunc: unsupported_args("zone")(timestamptrunc_sql()), 317 exp.JSONExtract: unsupported_args( 318 "only_json_types", 319 "expressions", 320 "variant_extract", 321 "json_query", 322 "option", 323 "quote", 324 "on_condition", 325 "requires_json", 326 )(json_extract_segments("JSON_EXTRACT_JSON")), 327 exp.JSONBExtract: json_extract_segments("BSON_EXTRACT_BSON"), 328 exp.JSONPathKey: json_path_key_only_name, 329 exp.JSONPathSubscript: lambda self, e: self.json_path_part(e.this), 330 exp.JSONPathRoot: lambda *_: "", 331 exp.JSONFormat: unsupported_args("options", "is_json")(rename_func("JSON_PRETTY")), 332 exp.DayOfWeekIso: lambda self, e: f"(({self.func('DAYOFWEEK', e.this)} % 7) + 1)", 333 exp.DayOfMonth: rename_func("DAY"), 334 exp.Hll: rename_func("APPROX_COUNT_DISTINCT"), 335 exp.ApproxDistinct: rename_func("APPROX_COUNT_DISTINCT"), 336 exp.CountIf: count_if_to_sum, 337 exp.LogicalOr: lambda self, e: f"MAX(ABS({self.sql(e, 'this')}))", 338 exp.LogicalAnd: lambda self, e: f"MIN(ABS({self.sql(e, 'this')}))", 339 exp.ApproxQuantile: unsupported_args("accuracy", "weight")( 340 lambda self, e: self.func( 341 "APPROX_PERCENTILE", 342 e.this, 343 e.args.get("quantile"), 344 e.args.get("error_tolerance"), 345 ) 346 ), 347 exp.Variance: rename_func("VAR_SAMP"), 348 exp.VariancePop: rename_func("VAR_POP"), 349 exp.Xor: bool_xor_sql, 350 exp.RegexpLike: lambda self, e: self.binary(e, "RLIKE"), 351 exp.Repeat: lambda self, e: self.func( 352 "LPAD", 353 exp.Literal.string(""), 354 exp.Mul(this=self.func("LENGTH", e.this), expression=e.args.get("times")), 355 e.this, 356 ), 357 exp.IsAscii: lambda self, e: f"({self.sql(e, 'this')} RLIKE '^[\x00-\x7f]*$')", 358 exp.MD5Digest: lambda self, e: self.func("UNHEX", self.func("MD5", e.this)), 359 exp.Chr: rename_func("CHAR"), 360 exp.Contains: rename_func("INSTR"), 361 exp.RegexpExtractAll: unsupported_args("position", "occurrence", "group")( 362 lambda self, e: self.func( 363 "REGEXP_MATCH", 364 e.this, 365 e.expression, 366 e.args.get("parameters"), 367 ) 368 ), 369 exp.RegexpExtract: unsupported_args("group")( 370 lambda self, e: self.func( 371 "REGEXP_SUBSTR", 372 e.this, 373 e.expression, 374 e.args.get("position"), 375 e.args.get("occurrence"), 376 e.args.get("parameters"), 377 ) 378 ), 379 exp.StartsWith: lambda self, e: self.func( 380 "REGEXP_INSTR", e.this, self.func("CONCAT", exp.Literal.string("^"), e.expression) 381 ), 382 exp.FromBase: lambda self, e: self.func( 383 "CONV", e.this, e.expression, exp.Literal.number(10) 384 ), 385 exp.Reduce: unsupported_args("finish")( 386 lambda self, e: self.func( 387 "REDUCE", e.args.get("initial"), e.this, e.args.get("merge") 388 ) 389 ), 390 } 391 TRANSFORMS.pop(exp.JSONExtractScalar) 392 393 UNSUPPORTED_TYPES = { 394 exp.DataType.Type.ARRAY, 395 exp.DataType.Type.AGGREGATEFUNCTION, 396 exp.DataType.Type.SIMPLEAGGREGATEFUNCTION, 397 exp.DataType.Type.BIGSERIAL, 398 exp.DataType.Type.BPCHAR, 399 exp.DataType.Type.DATEMULTIRANGE, 400 exp.DataType.Type.DATERANGE, 401 exp.DataType.Type.DYNAMIC, 402 exp.DataType.Type.HLLSKETCH, 403 exp.DataType.Type.HSTORE, 404 exp.DataType.Type.IMAGE, 405 exp.DataType.Type.INET, 406 exp.DataType.Type.INT128, 407 exp.DataType.Type.INT256, 408 exp.DataType.Type.INT4MULTIRANGE, 409 exp.DataType.Type.INT4RANGE, 410 exp.DataType.Type.INT8MULTIRANGE, 411 exp.DataType.Type.INT8RANGE, 412 exp.DataType.Type.INTERVAL, 413 exp.DataType.Type.IPADDRESS, 414 exp.DataType.Type.IPPREFIX, 415 exp.DataType.Type.IPV4, 416 exp.DataType.Type.IPV6, 417 exp.DataType.Type.LIST, 418 exp.DataType.Type.MAP, 419 exp.DataType.Type.LOWCARDINALITY, 420 exp.DataType.Type.MONEY, 421 exp.DataType.Type.MULTILINESTRING, 422 exp.DataType.Type.NAME, 423 exp.DataType.Type.NESTED, 424 exp.DataType.Type.NOTHING, 425 exp.DataType.Type.NULL, 426 exp.DataType.Type.NUMMULTIRANGE, 427 exp.DataType.Type.NUMRANGE, 428 exp.DataType.Type.OBJECT, 429 exp.DataType.Type.RANGE, 430 exp.DataType.Type.ROWVERSION, 431 exp.DataType.Type.SERIAL, 432 exp.DataType.Type.SMALLSERIAL, 433 exp.DataType.Type.SMALLMONEY, 434 exp.DataType.Type.STRUCT, 435 exp.DataType.Type.SUPER, 436 exp.DataType.Type.TIMETZ, 437 exp.DataType.Type.TIMESTAMPNTZ, 438 exp.DataType.Type.TIMESTAMPLTZ, 439 exp.DataType.Type.TIMESTAMPTZ, 440 exp.DataType.Type.TIMESTAMP_NS, 441 exp.DataType.Type.TSMULTIRANGE, 442 exp.DataType.Type.TSRANGE, 443 exp.DataType.Type.TSTZMULTIRANGE, 444 exp.DataType.Type.TSTZRANGE, 445 exp.DataType.Type.UINT128, 446 exp.DataType.Type.UINT256, 447 exp.DataType.Type.UNION, 448 exp.DataType.Type.UNKNOWN, 449 exp.DataType.Type.USERDEFINED, 450 exp.DataType.Type.UUID, 451 exp.DataType.Type.VARIANT, 452 exp.DataType.Type.XML, 453 exp.DataType.Type.TDIGEST, 454 } 455 456 TYPE_MAPPING = { 457 **MySQL.Generator.TYPE_MAPPING, 458 exp.DataType.Type.BIGDECIMAL: "DECIMAL", 459 exp.DataType.Type.BIT: "BOOLEAN", 460 exp.DataType.Type.DATE32: "DATE", 461 exp.DataType.Type.DATETIME64: "DATETIME", 462 exp.DataType.Type.DECIMAL32: "DECIMAL", 463 exp.DataType.Type.DECIMAL64: "DECIMAL", 464 exp.DataType.Type.DECIMAL128: "DECIMAL", 465 exp.DataType.Type.DECIMAL256: "DECIMAL", 466 exp.DataType.Type.ENUM8: "ENUM", 467 exp.DataType.Type.ENUM16: "ENUM", 468 exp.DataType.Type.FIXEDSTRING: "TEXT", 469 exp.DataType.Type.GEOMETRY: "GEOGRAPHY", 470 exp.DataType.Type.POINT: "GEOGRAPHYPOINT", 471 exp.DataType.Type.RING: "GEOGRAPHY", 472 exp.DataType.Type.LINESTRING: "GEOGRAPHY", 473 exp.DataType.Type.POLYGON: "GEOGRAPHY", 474 exp.DataType.Type.MULTIPOLYGON: "GEOGRAPHY", 475 exp.DataType.Type.JSONB: "BSON", 476 exp.DataType.Type.TIMESTAMP: "TIMESTAMP", 477 exp.DataType.Type.TIMESTAMP_S: "TIMESTAMP", 478 exp.DataType.Type.TIMESTAMP_MS: "TIMESTAMP(6)", 479 } 480 481 # https://docs.singlestore.com/cloud/reference/sql-reference/restricted-keywords/list-of-restricted-keywords/ 482 RESERVED_KEYWORDS = { 483 "abs", 484 "absolute", 485 "access", 486 "account", 487 "acos", 488 "action", 489 "add", 490 "adddate", 491 "addtime", 492 "admin", 493 "aes_decrypt", 494 "aes_encrypt", 495 "after", 496 "against", 497 "aggregate", 498 "aggregates", 499 "aggregator", 500 "aggregator_id", 501 "aggregator_plan_hash", 502 "aggregators", 503 "algorithm", 504 "all", 505 "also", 506 "alter", 507 "always", 508 "analyse", 509 "analyze", 510 "and", 511 "anti_join", 512 "any", 513 "any_value", 514 "approx_count_distinct", 515 "approx_count_distinct_accumulate", 516 "approx_count_distinct_combine", 517 "approx_count_distinct_estimate", 518 "approx_geography_intersects", 519 "approx_percentile", 520 "arghistory", 521 "arrange", 522 "arrangement", 523 "array", 524 "as", 525 "asc", 526 "ascii", 527 "asensitive", 528 "asin", 529 "asm", 530 "assertion", 531 "assignment", 532 "ast", 533 "asymmetric", 534 "async", 535 "at", 536 "atan", 537 "atan2", 538 "attach", 539 "attribute", 540 "authorization", 541 "auto", 542 "auto_increment", 543 "auto_reprovision", 544 "autostats", 545 "autostats_cardinality_mode", 546 "autostats_enabled", 547 "autostats_histogram_mode", 548 "autostats_sampling", 549 "availability", 550 "avg", 551 "avg_row_length", 552 "avro", 553 "azure", 554 "background", 555 "_background_threads_for_cleanup", 556 "backup", 557 "backup_history", 558 "backup_id", 559 "backward", 560 "batch", 561 "batches", 562 "batch_interval", 563 "_batch_size_limit", 564 "before", 565 "begin", 566 "between", 567 "bigint", 568 "bin", 569 "binary", 570 "_binary", 571 "bit", 572 "bit_and", 573 "bit_count", 574 "bit_or", 575 "bit_xor", 576 "blob", 577 "bool", 578 "boolean", 579 "bootstrap", 580 "both", 581 "_bt", 582 "btree", 583 "bucket_count", 584 "by", 585 "byte", 586 "byte_length", 587 "cache", 588 "call", 589 "call_for_pipeline", 590 "called", 591 "capture", 592 "cascade", 593 "cascaded", 594 "case", 595 "cast", 596 "catalog", 597 "ceil", 598 "ceiling", 599 "chain", 600 "change", 601 "char", 602 "character", 603 "characteristics", 604 "character_length", 605 "char_length", 606 "charset", 607 "check", 608 "checkpoint", 609 "_check_can_connect", 610 "_check_consistency", 611 "checksum", 612 "_checksum", 613 "class", 614 "clear", 615 "client", 616 "client_found_rows", 617 "close", 618 "cluster", 619 "clustered", 620 "cnf", 621 "coalesce", 622 "coercibility", 623 "collate", 624 "collation", 625 "collect", 626 "column", 627 "columnar", 628 "columns", 629 "columnstore", 630 "columnstore_segment_rows", 631 "comment", 632 "comments", 633 "commit", 634 "committed", 635 "_commit_log_tail", 636 "committed", 637 "compact", 638 "compile", 639 "compressed", 640 "compression", 641 "concat", 642 "concat_ws", 643 "concurrent", 644 "concurrently", 645 "condition", 646 "configuration", 647 "connection", 648 "connection_id", 649 "connections", 650 "config", 651 "constraint", 652 "constraints", 653 "content", 654 "continue", 655 "_continue_replay", 656 "conv", 657 "conversion", 658 "convert", 659 "convert_tz", 660 "copy", 661 "_core", 662 "cos", 663 "cost", 664 "cot", 665 "count", 666 "create", 667 "credentials", 668 "cross", 669 "cube", 670 "csv", 671 "cume_dist", 672 "curdate", 673 "current", 674 "current_catalog", 675 "current_date", 676 "current_role", 677 "current_schema", 678 "current_security_groups", 679 "current_security_roles", 680 "current_time", 681 "current_timestamp", 682 "current_user", 683 "cursor", 684 "curtime", 685 "cycle", 686 "data", 687 "database", 688 "databases", 689 "date", 690 "date_add", 691 "datediff", 692 "date_format", 693 "date_sub", 694 "date_trunc", 695 "datetime", 696 "day", 697 "day_hour", 698 "day_microsecond", 699 "day_minute", 700 "dayname", 701 "dayofmonth", 702 "dayofweek", 703 "dayofyear", 704 "day_second", 705 "deallocate", 706 "dec", 707 "decimal", 708 "declare", 709 "decode", 710 "default", 711 "defaults", 712 "deferrable", 713 "deferred", 714 "defined", 715 "definer", 716 "degrees", 717 "delayed", 718 "delay_key_write", 719 "delete", 720 "delimiter", 721 "delimiters", 722 "dense_rank", 723 "desc", 724 "describe", 725 "detach", 726 "deterministic", 727 "dictionary", 728 "differential", 729 "directory", 730 "disable", 731 "discard", 732 "_disconnect", 733 "disk", 734 "distinct", 735 "distinctrow", 736 "distributed_joins", 737 "div", 738 "do", 739 "document", 740 "domain", 741 "dot_product", 742 "double", 743 "drop", 744 "_drop_profile", 745 "dual", 746 "dump", 747 "duplicate", 748 "dynamic", 749 "earliest", 750 "each", 751 "echo", 752 "election", 753 "else", 754 "elseif", 755 "elt", 756 "enable", 757 "enclosed", 758 "encoding", 759 "encrypted", 760 "end", 761 "engine", 762 "engines", 763 "enum", 764 "errors", 765 "escape", 766 "escaped", 767 "estimate", 768 "euclidean_distance", 769 "event", 770 "events", 771 "except", 772 "exclude", 773 "excluding", 774 "exclusive", 775 "execute", 776 "exists", 777 "exit", 778 "exp", 779 "explain", 780 "extended", 781 "extension", 782 "external", 783 "external_host", 784 "external_port", 785 "extract", 786 "extractor", 787 "extractors", 788 "extra_join", 789 "_failover", 790 "failed_login_attempts", 791 "failure", 792 "false", 793 "family", 794 "fault", 795 "fetch", 796 "field", 797 "fields", 798 "file", 799 "files", 800 "fill", 801 "first", 802 "first_value", 803 "fix_alter", 804 "fixed", 805 "float", 806 "float4", 807 "float8", 808 "floor", 809 "flush", 810 "following", 811 "for", 812 "force", 813 "force_compiled_mode", 814 "force_interpreter_mode", 815 "foreground", 816 "foreign", 817 "format", 818 "forward", 819 "found_rows", 820 "freeze", 821 "from", 822 "from_base64", 823 "from_days", 824 "from_unixtime", 825 "fs", 826 "_fsync", 827 "full", 828 "fulltext", 829 "function", 830 "functions", 831 "gc", 832 "gcs", 833 "get_format", 834 "_gc", 835 "_gcx", 836 "generate", 837 "geography", 838 "geography_area", 839 "geography_contains", 840 "geography_distance", 841 "geography_intersects", 842 "geography_latitude", 843 "geography_length", 844 "geography_longitude", 845 "geographypoint", 846 "geography_point", 847 "geography_within_distance", 848 "geometry", 849 "geometry_area", 850 "geometry_contains", 851 "geometry_distance", 852 "geometry_filter", 853 "geometry_intersects", 854 "geometry_length", 855 "geometrypoint", 856 "geometry_point", 857 "geometry_within_distance", 858 "geometry_x", 859 "geometry_y", 860 "global", 861 "_global_version_timestamp", 862 "grant", 863 "granted", 864 "grants", 865 "greatest", 866 "group", 867 "grouping", 868 "groups", 869 "group_concat", 870 "gzip", 871 "handle", 872 "handler", 873 "hard_cpu_limit_percentage", 874 "hash", 875 "has_temp_tables", 876 "having", 877 "hdfs", 878 "header", 879 "heartbeat_no_logging", 880 "hex", 881 "highlight", 882 "high_priority", 883 "hold", 884 "holding", 885 "host", 886 "hosts", 887 "hour", 888 "hour_microsecond", 889 "hour_minute", 890 "hour_second", 891 "identified", 892 "identity", 893 "if", 894 "ifnull", 895 "ignore", 896 "ilike", 897 "immediate", 898 "immutable", 899 "implicit", 900 "import", 901 "in", 902 "including", 903 "increment", 904 "incremental", 905 "index", 906 "indexes", 907 "inet_aton", 908 "inet_ntoa", 909 "inet6_aton", 910 "inet6_ntoa", 911 "infile", 912 "inherit", 913 "inherits", 914 "_init_profile", 915 "init", 916 "initcap", 917 "initialize", 918 "initially", 919 "inject", 920 "inline", 921 "inner", 922 "inout", 923 "input", 924 "insensitive", 925 "insert", 926 "insert_method", 927 "instance", 928 "instead", 929 "instr", 930 "int", 931 "int1", 932 "int2", 933 "int3", 934 "int4", 935 "int8", 936 "integer", 937 "_internal_dynamic_typecast", 938 "interpreter_mode", 939 "intersect", 940 "interval", 941 "into", 942 "invoker", 943 "is", 944 "isnull", 945 "isolation", 946 "iterate", 947 "join", 948 "json", 949 "json_agg", 950 "json_array_contains_double", 951 "json_array_contains_json", 952 "json_array_contains_string", 953 "json_array_push_double", 954 "json_array_push_json", 955 "json_array_push_string", 956 "json_delete_key", 957 "json_extract_double", 958 "json_extract_json", 959 "json_extract_string", 960 "json_extract_bigint", 961 "json_get_type", 962 "json_length", 963 "json_set_double", 964 "json_set_json", 965 "json_set_string", 966 "json_splice_double", 967 "json_splice_json", 968 "json_splice_string", 969 "kafka", 970 "key", 971 "key_block_size", 972 "keys", 973 "kill", 974 "killall", 975 "label", 976 "lag", 977 "language", 978 "large", 979 "last", 980 "last_day", 981 "last_insert_id", 982 "last_value", 983 "lateral", 984 "latest", 985 "lc_collate", 986 "lc_ctype", 987 "lcase", 988 "lead", 989 "leading", 990 "leaf", 991 "leakproof", 992 "least", 993 "leave", 994 "leaves", 995 "left", 996 "length", 997 "level", 998 "license", 999 "like", 1000 "limit", 1001 "lines", 1002 "listen", 1003 "llvm", 1004 "ln", 1005 "load", 1006 "loaddata_where", 1007 "_load", 1008 "local", 1009 "localtime", 1010 "localtimestamp", 1011 "locate", 1012 "location", 1013 "lock", 1014 "log", 1015 "log10", 1016 "log2", 1017 "long", 1018 "longblob", 1019 "longtext", 1020 "loop", 1021 "lower", 1022 "low_priority", 1023 "lpad", 1024 "_ls", 1025 "ltrim", 1026 "lz4", 1027 "management", 1028 "_management_thread", 1029 "mapping", 1030 "master", 1031 "match", 1032 "materialized", 1033 "max", 1034 "maxvalue", 1035 "max_concurrency", 1036 "max_errors", 1037 "max_partitions_per_batch", 1038 "max_queue_depth", 1039 "max_retries_per_batch_partition", 1040 "max_rows", 1041 "mbc", 1042 "md5", 1043 "mpl", 1044 "median", 1045 "mediumblob", 1046 "mediumint", 1047 "mediumtext", 1048 "member", 1049 "memory", 1050 "memory_percentage", 1051 "_memsql_table_id_lookup", 1052 "memsql", 1053 "memsql_deserialize", 1054 "memsql_imitating_kafka", 1055 "memsql_serialize", 1056 "merge", 1057 "metadata", 1058 "microsecond", 1059 "middleint", 1060 "min", 1061 "min_rows", 1062 "minus", 1063 "minute", 1064 "minute_microsecond", 1065 "minute_second", 1066 "minvalue", 1067 "mod", 1068 "mode", 1069 "model", 1070 "modifies", 1071 "modify", 1072 "month", 1073 "monthname", 1074 "months_between", 1075 "move", 1076 "mpl", 1077 "names", 1078 "named", 1079 "namespace", 1080 "national", 1081 "natural", 1082 "nchar", 1083 "next", 1084 "no", 1085 "node", 1086 "none", 1087 "no_query_rewrite", 1088 "noparam", 1089 "not", 1090 "nothing", 1091 "notify", 1092 "now", 1093 "nowait", 1094 "no_write_to_binlog", 1095 "no_query_rewrite", 1096 "norely", 1097 "nth_value", 1098 "ntile", 1099 "null", 1100 "nullcols", 1101 "nullif", 1102 "nulls", 1103 "numeric", 1104 "nvarchar", 1105 "object", 1106 "octet_length", 1107 "of", 1108 "off", 1109 "offline", 1110 "offset", 1111 "offsets", 1112 "oids", 1113 "on", 1114 "online", 1115 "only", 1116 "open", 1117 "operator", 1118 "optimization", 1119 "optimize", 1120 "optimizer", 1121 "optimizer_state", 1122 "option", 1123 "options", 1124 "optionally", 1125 "or", 1126 "order", 1127 "ordered_serialize", 1128 "orphan", 1129 "out", 1130 "out_of_order", 1131 "outer", 1132 "outfile", 1133 "over", 1134 "overlaps", 1135 "overlay", 1136 "owned", 1137 "owner", 1138 "pack_keys", 1139 "paired", 1140 "parser", 1141 "parquet", 1142 "partial", 1143 "partition", 1144 "partition_id", 1145 "partitioning", 1146 "partitions", 1147 "passing", 1148 "password", 1149 "password_lock_time", 1150 "parser", 1151 "pause", 1152 "_pause_replay", 1153 "percent_rank", 1154 "percentile_cont", 1155 "percentile_disc", 1156 "periodic", 1157 "persisted", 1158 "pi", 1159 "pipeline", 1160 "pipelines", 1161 "pivot", 1162 "placing", 1163 "plan", 1164 "plans", 1165 "plancache", 1166 "plugins", 1167 "pool", 1168 "pools", 1169 "port", 1170 "position", 1171 "pow", 1172 "power", 1173 "preceding", 1174 "precision", 1175 "prepare", 1176 "prepared", 1177 "preserve", 1178 "primary", 1179 "prior", 1180 "privileges", 1181 "procedural", 1182 "procedure", 1183 "procedures", 1184 "process", 1185 "processlist", 1186 "profile", 1187 "profiles", 1188 "program", 1189 "promote", 1190 "proxy", 1191 "purge", 1192 "quarter", 1193 "queries", 1194 "query", 1195 "query_timeout", 1196 "queue", 1197 "quote", 1198 "radians", 1199 "rand", 1200 "range", 1201 "rank", 1202 "read", 1203 "_read", 1204 "reads", 1205 "real", 1206 "reassign", 1207 "rebalance", 1208 "recheck", 1209 "record", 1210 "recursive", 1211 "redundancy", 1212 "redundant", 1213 "ref", 1214 "reference", 1215 "references", 1216 "refresh", 1217 "regexp", 1218 "reindex", 1219 "relative", 1220 "release", 1221 "reload", 1222 "rely", 1223 "remote", 1224 "remove", 1225 "rename", 1226 "repair", 1227 "_repair_table", 1228 "repeat", 1229 "repeatable", 1230 "_repl", 1231 "_reprovisioning", 1232 "replace", 1233 "replica", 1234 "replicate", 1235 "replicating", 1236 "replication", 1237 "durability", 1238 "require", 1239 "resource", 1240 "resource_pool", 1241 "reset", 1242 "restart", 1243 "restore", 1244 "restrict", 1245 "result", 1246 "_resurrect", 1247 "retry", 1248 "return", 1249 "returning", 1250 "returns", 1251 "reverse", 1252 "revoke", 1253 "rg_pool", 1254 "right", 1255 "right_anti_join", 1256 "right_semi_join", 1257 "right_straight_join", 1258 "rlike", 1259 "role", 1260 "roles", 1261 "rollback", 1262 "rollup", 1263 "round", 1264 "routine", 1265 "row", 1266 "row_count", 1267 "row_format", 1268 "row_number", 1269 "rows", 1270 "rowstore", 1271 "rule", 1272 "rpad", 1273 "_rpc", 1274 "rtrim", 1275 "running", 1276 "s3", 1277 "safe", 1278 "save", 1279 "savepoint", 1280 "scalar", 1281 "schema", 1282 "schemas", 1283 "schema_binding", 1284 "scroll", 1285 "search", 1286 "second", 1287 "second_microsecond", 1288 "sec_to_time", 1289 "security", 1290 "select", 1291 "semi_join", 1292 "_send_threads", 1293 "sensitive", 1294 "separator", 1295 "sequence", 1296 "sequences", 1297 "serial", 1298 "serializable", 1299 "series", 1300 "service_user", 1301 "server", 1302 "session", 1303 "session_user", 1304 "set", 1305 "setof", 1306 "security_lists_intersect", 1307 "sha", 1308 "sha1", 1309 "sha2", 1310 "shard", 1311 "sharded", 1312 "sharded_id", 1313 "share", 1314 "show", 1315 "shutdown", 1316 "sigmoid", 1317 "sign", 1318 "signal", 1319 "similar", 1320 "simple", 1321 "site", 1322 "signed", 1323 "sin", 1324 "skip", 1325 "skipped_batches", 1326 "sleep", 1327 "_sleep", 1328 "smallint", 1329 "snapshot", 1330 "_snapshot", 1331 "_snapshots", 1332 "soft_cpu_limit_percentage", 1333 "some", 1334 "soname", 1335 "sparse", 1336 "spatial", 1337 "spatial_check_index", 1338 "specific", 1339 "split", 1340 "sql", 1341 "sql_big_result", 1342 "sql_buffer_result", 1343 "sql_cache", 1344 "sql_calc_found_rows", 1345 "sqlexception", 1346 "sql_mode", 1347 "sql_no_cache", 1348 "sql_no_logging", 1349 "sql_small_result", 1350 "sqlstate", 1351 "sqlwarning", 1352 "sqrt", 1353 "ssl", 1354 "stable", 1355 "standalone", 1356 "start", 1357 "starting", 1358 "state", 1359 "statement", 1360 "statistics", 1361 "stats", 1362 "status", 1363 "std", 1364 "stddev", 1365 "stddev_pop", 1366 "stddev_samp", 1367 "stdin", 1368 "stdout", 1369 "stop", 1370 "storage", 1371 "str_to_date", 1372 "straight_join", 1373 "strict", 1374 "string", 1375 "strip", 1376 "subdate", 1377 "substr", 1378 "substring", 1379 "substring_index", 1380 "success", 1381 "sum", 1382 "super", 1383 "symmetric", 1384 "sync_snapshot", 1385 "sync", 1386 "_sync", 1387 "_sync2", 1388 "_sync_partitions", 1389 "_sync_snapshot", 1390 "synchronize", 1391 "sysid", 1392 "system", 1393 "table", 1394 "table_checksum", 1395 "tables", 1396 "tablespace", 1397 "tags", 1398 "tan", 1399 "target_size", 1400 "task", 1401 "temp", 1402 "template", 1403 "temporary", 1404 "temptable", 1405 "_term_bump", 1406 "terminate", 1407 "terminated", 1408 "test", 1409 "text", 1410 "then", 1411 "time", 1412 "timediff", 1413 "time_bucket", 1414 "time_format", 1415 "timeout", 1416 "timestamp", 1417 "timestampadd", 1418 "timestampdiff", 1419 "timezone", 1420 "time_to_sec", 1421 "tinyblob", 1422 "tinyint", 1423 "tinytext", 1424 "to", 1425 "to_base64", 1426 "to_char", 1427 "to_date", 1428 "to_days", 1429 "to_json", 1430 "to_number", 1431 "to_seconds", 1432 "to_timestamp", 1433 "tracelogs", 1434 "traditional", 1435 "trailing", 1436 "transform", 1437 "transaction", 1438 "_transactions_experimental", 1439 "treat", 1440 "trigger", 1441 "triggers", 1442 "trim", 1443 "true", 1444 "trunc", 1445 "truncate", 1446 "trusted", 1447 "two_phase", 1448 "_twopcid", 1449 "type", 1450 "types", 1451 "ucase", 1452 "unbounded", 1453 "uncommitted", 1454 "undefined", 1455 "undo", 1456 "unencrypted", 1457 "unenforced", 1458 "unhex", 1459 "unhold", 1460 "unicode", 1461 "union", 1462 "unique", 1463 "_unittest", 1464 "unix_timestamp", 1465 "unknown", 1466 "unlisten", 1467 "_unload", 1468 "unlock", 1469 "unlogged", 1470 "unpivot", 1471 "unsigned", 1472 "until", 1473 "update", 1474 "upgrade", 1475 "upper", 1476 "usage", 1477 "use", 1478 "user", 1479 "users", 1480 "using", 1481 "utc_date", 1482 "utc_time", 1483 "utc_timestamp", 1484 "_utf8", 1485 "vacuum", 1486 "valid", 1487 "validate", 1488 "validator", 1489 "value", 1490 "values", 1491 "varbinary", 1492 "varchar", 1493 "varcharacter", 1494 "variables", 1495 "variadic", 1496 "variance", 1497 "var_pop", 1498 "var_samp", 1499 "varying", 1500 "vector_sub", 1501 "verbose", 1502 "version", 1503 "view", 1504 "void", 1505 "volatile", 1506 "voting", 1507 "wait", 1508 "_wake", 1509 "warnings", 1510 "week", 1511 "weekday", 1512 "weekofyear", 1513 "when", 1514 "where", 1515 "while", 1516 "whitespace", 1517 "window", 1518 "with", 1519 "without", 1520 "within", 1521 "_wm_heartbeat", 1522 "work", 1523 "workload", 1524 "wrapper", 1525 "write", 1526 "xact_id", 1527 "xor", 1528 "year", 1529 "year_month", 1530 "yes", 1531 "zerofill", 1532 "zone", 1533 } 1534 1535 def jsonextractscalar_sql(self, expression: exp.JSONExtractScalar) -> str: 1536 json_type = expression.args.get("json_type") 1537 func_name = "JSON_EXTRACT_JSON" if json_type is None else f"JSON_EXTRACT_{json_type}" 1538 return json_extract_segments(func_name)(self, expression) 1539 1540 def jsonbextractscalar_sql(self, expression: exp.JSONBExtractScalar) -> str: 1541 json_type = expression.args.get("json_type") 1542 func_name = "BSON_EXTRACT_BSON" if json_type is None else f"BSON_EXTRACT_{json_type}" 1543 return json_extract_segments(func_name)(self, expression) 1544 1545 def jsonextractarray_sql(self, expression: exp.JSONExtractArray) -> str: 1546 self.unsupported("Arrays are not supported in SingleStore") 1547 return self.function_fallback_sql(expression) 1548 1549 @unsupported_args("on_condition") 1550 def jsonvalue_sql(self, expression: exp.JSONValue) -> str: 1551 res: exp.Expression = exp.JSONExtractScalar( 1552 this=expression.this, 1553 expression=expression.args.get("path"), 1554 json_type="STRING", 1555 ) 1556 1557 returning = expression.args.get("returning") 1558 if returning is not None: 1559 res = exp.Cast(this=res, to=returning) 1560 1561 return self.sql(res) 1562 1563 def all_sql(self, expression: exp.All) -> str: 1564 self.unsupported("ALL subquery predicate is not supported in SingleStore") 1565 return super().all_sql(expression) 1566 1567 def jsonarraycontains_sql(self, expression: exp.JSONArrayContains) -> str: 1568 json_type = expression.text("json_type").upper() 1569 1570 if json_type: 1571 return self.func( 1572 f"JSON_ARRAY_CONTAINS_{json_type}", expression.expression, expression.this 1573 ) 1574 1575 return self.func( 1576 "JSON_ARRAY_CONTAINS_JSON", 1577 expression.expression, 1578 self.func("TO_JSON", expression.this), 1579 ) 1580 1581 @unsupported_args("kind", "nested", "values") 1582 def datatype_sql(self, expression: exp.DataType) -> str: 1583 if expression.is_type(exp.DataType.Type.VARBINARY) and not expression.expressions: 1584 # `VARBINARY` must always have a size - if it doesn't, we always generate `BLOB` 1585 return "BLOB" 1586 if expression.is_type( 1587 exp.DataType.Type.DECIMAL32, 1588 exp.DataType.Type.DECIMAL64, 1589 exp.DataType.Type.DECIMAL128, 1590 exp.DataType.Type.DECIMAL256, 1591 ): 1592 scale = self.expressions(expression, flat=True) 1593 1594 if expression.is_type(exp.DataType.Type.DECIMAL32): 1595 precision = "9" 1596 elif expression.is_type(exp.DataType.Type.DECIMAL64): 1597 precision = "18" 1598 elif expression.is_type(exp.DataType.Type.DECIMAL128): 1599 precision = "38" 1600 else: 1601 # 65 is a maximum precision supported in SingleStore 1602 precision = "65" 1603 if scale is not None: 1604 return f"DECIMAL({precision}, {scale[0]})" 1605 else: 1606 return f"DECIMAL({precision})" 1607 1608 return super().datatype_sql(expression)
def
cast_to_time6( expression: Optional[sqlglot.expressions.Expression]) -> sqlglot.expressions.Cast:
34class SingleStore(MySQL): 35 SUPPORTS_ORDER_BY_ALL = True 36 37 TIME_MAPPING: t.Dict[str, str] = { 38 "D": "%u", # Day of week (1-7) 39 "DD": "%d", # day of month (01-31) 40 "DY": "%a", # abbreviated name of day 41 "HH": "%I", # Hour of day (01-12) 42 "HH12": "%I", # alias for HH 43 "HH24": "%H", # Hour of day (00-23) 44 "MI": "%M", # Minute (00-59) 45 "MM": "%m", # Month (01-12; January = 01) 46 "MON": "%b", # Abbreviated name of month 47 "MONTH": "%B", # Name of month 48 "SS": "%S", # Second (00-59) 49 "RR": "%y", # 15 50 "YY": "%y", # 15 51 "YYYY": "%Y", # 2015 52 "FF6": "%f", # only 6 digits are supported in python formats 53 } 54 55 class Tokenizer(MySQL.Tokenizer): 56 BYTE_STRINGS = [("e'", "'"), ("E'", "'")] 57 58 KEYWORDS = { 59 **MySQL.Tokenizer.KEYWORDS, 60 "BSON": TokenType.JSONB, 61 "GEOGRAPHYPOINT": TokenType.GEOGRAPHYPOINT, 62 "TIMESTAMP": TokenType.TIMESTAMP, 63 ":>": TokenType.COLON_GT, 64 "!:>": TokenType.NCOLON_GT, 65 "::$": TokenType.DCOLONDOLLAR, 66 "::%": TokenType.DCOLONPERCENT, 67 } 68 69 class Parser(MySQL.Parser): 70 FUNCTIONS = { 71 **MySQL.Parser.FUNCTIONS, 72 "TO_DATE": build_formatted_time(exp.TsOrDsToDate, "singlestore"), 73 "TO_TIMESTAMP": build_formatted_time(exp.StrToTime, "singlestore"), 74 "TO_CHAR": build_formatted_time(exp.ToChar, "singlestore"), 75 "STR_TO_DATE": build_formatted_time(exp.StrToDate, "mysql"), 76 "DATE_FORMAT": build_formatted_time(exp.TimeToStr, "mysql"), 77 # The first argument of following functions is converted to TIME(6) 78 # This is needed because exp.TimeToStr is converted to DATE_FORMAT 79 # which interprets the first argument as DATETIME and fails to parse 80 # string literals like '12:05:47' without a date part. 81 "TIME_FORMAT": lambda args: exp.TimeToStr( 82 this=cast_to_time6(seq_get(args, 0)), 83 format=MySQL.format_time(seq_get(args, 1)), 84 ), 85 "HOUR": lambda args: exp.cast( 86 exp.TimeToStr( 87 this=cast_to_time6(seq_get(args, 0)), 88 format=MySQL.format_time(exp.Literal.string("%k")), 89 ), 90 DataType.Type.INT, 91 ), 92 "MICROSECOND": lambda args: exp.cast( 93 exp.TimeToStr( 94 this=cast_to_time6(seq_get(args, 0)), 95 format=MySQL.format_time(exp.Literal.string("%f")), 96 ), 97 DataType.Type.INT, 98 ), 99 "SECOND": lambda args: exp.cast( 100 exp.TimeToStr( 101 this=cast_to_time6(seq_get(args, 0)), 102 format=MySQL.format_time(exp.Literal.string("%s")), 103 ), 104 DataType.Type.INT, 105 ), 106 "MINUTE": lambda args: exp.cast( 107 exp.TimeToStr( 108 this=cast_to_time6(seq_get(args, 0)), 109 format=MySQL.format_time(exp.Literal.string("%i")), 110 ), 111 DataType.Type.INT, 112 ), 113 "MONTHNAME": lambda args: exp.TimeToStr( 114 this=seq_get(args, 0), 115 format=MySQL.format_time(exp.Literal.string("%M")), 116 ), 117 "WEEKDAY": lambda args: exp.paren(exp.DayOfWeek(this=seq_get(args, 0)) + 5, copy=False) 118 % 7, 119 "UNIX_TIMESTAMP": exp.StrToUnix.from_arg_list, 120 "FROM_UNIXTIME": build_formatted_time(exp.UnixToTime, "mysql"), 121 "TIME_BUCKET": lambda args: exp.DateBin( 122 this=seq_get(args, 0), 123 expression=seq_get(args, 1), 124 origin=seq_get(args, 2), 125 ), 126 "BSON_EXTRACT_BSON": build_json_extract_path(exp.JSONBExtract), 127 "BSON_EXTRACT_STRING": build_json_extract_path( 128 exp.JSONBExtractScalar, json_type="STRING" 129 ), 130 "BSON_EXTRACT_DOUBLE": build_json_extract_path( 131 exp.JSONBExtractScalar, json_type="DOUBLE" 132 ), 133 "BSON_EXTRACT_BIGINT": build_json_extract_path( 134 exp.JSONBExtractScalar, json_type="BIGINT" 135 ), 136 "JSON_EXTRACT_JSON": build_json_extract_path(exp.JSONExtract), 137 "JSON_EXTRACT_STRING": build_json_extract_path( 138 exp.JSONExtractScalar, json_type="STRING" 139 ), 140 "JSON_EXTRACT_DOUBLE": build_json_extract_path( 141 exp.JSONExtractScalar, json_type="DOUBLE" 142 ), 143 "JSON_EXTRACT_BIGINT": build_json_extract_path( 144 exp.JSONExtractScalar, json_type="BIGINT" 145 ), 146 "JSON_ARRAY_CONTAINS_STRING": lambda args: exp.JSONArrayContains( 147 this=seq_get(args, 1), 148 expression=seq_get(args, 0), 149 json_type="STRING", 150 ), 151 "JSON_ARRAY_CONTAINS_DOUBLE": lambda args: exp.JSONArrayContains( 152 this=seq_get(args, 1), 153 expression=seq_get(args, 0), 154 json_type="DOUBLE", 155 ), 156 "JSON_ARRAY_CONTAINS_JSON": lambda args: exp.JSONArrayContains( 157 this=seq_get(args, 1), 158 expression=seq_get(args, 0), 159 json_type="JSON", 160 ), 161 "JSON_PRETTY": exp.JSONFormat.from_arg_list, 162 "DATE": exp.Date.from_arg_list, 163 "DAYNAME": lambda args: exp.TimeToStr( 164 this=seq_get(args, 0), 165 format=MySQL.format_time(exp.Literal.string("%W")), 166 ), 167 "TIMESTAMPDIFF": lambda args: exp.TimestampDiff( 168 this=seq_get(args, 2), 169 expression=seq_get(args, 1), 170 unit=seq_get(args, 0), 171 ), 172 "APPROX_COUNT_DISTINCT": exp.Hll.from_arg_list, 173 "APPROX_PERCENTILE": lambda args, dialect: exp.ApproxQuantile( 174 this=seq_get(args, 0), 175 quantile=seq_get(args, 1), 176 error_tolerance=seq_get(args, 2), 177 ), 178 "VARIANCE": exp.VariancePop.from_arg_list, 179 "INSTR": exp.Contains.from_arg_list, 180 "REGEXP_MATCH": lambda args: exp.RegexpExtractAll( 181 this=seq_get(args, 0), 182 expression=seq_get(args, 1), 183 parameters=seq_get(args, 2), 184 ), 185 "REGEXP_SUBSTR": lambda args: exp.RegexpExtract( 186 this=seq_get(args, 0), 187 expression=seq_get(args, 1), 188 position=seq_get(args, 2), 189 occurrence=seq_get(args, 3), 190 parameters=seq_get(args, 4), 191 ), 192 "REDUCE": lambda args: exp.Reduce( 193 initial=seq_get(args, 0), 194 this=seq_get(args, 1), 195 merge=seq_get(args, 2), 196 ), 197 } 198 199 CAST_COLUMN_OPERATORS = {TokenType.COLON_GT, TokenType.NCOLON_GT} 200 201 COLUMN_OPERATORS = { 202 **MySQL.Parser.COLUMN_OPERATORS, 203 TokenType.COLON_GT: lambda self, this, to: self.expression( 204 exp.Cast, 205 this=this, 206 to=to, 207 ), 208 TokenType.NCOLON_GT: lambda self, this, to: self.expression( 209 exp.TryCast, 210 this=this, 211 to=to, 212 ), 213 TokenType.DCOLON: lambda self, this, path: build_json_extract_path(exp.JSONExtract)( 214 [this, exp.Literal.string(path.name)] 215 ), 216 TokenType.DCOLONDOLLAR: lambda self, this, path: build_json_extract_path( 217 exp.JSONExtractScalar, json_type="STRING" 218 )([this, exp.Literal.string(path.name)]), 219 TokenType.DCOLONPERCENT: lambda self, this, path: build_json_extract_path( 220 exp.JSONExtractScalar, json_type="DOUBLE" 221 )([this, exp.Literal.string(path.name)]), 222 } 223 COLUMN_OPERATORS.pop(TokenType.ARROW) 224 COLUMN_OPERATORS.pop(TokenType.DARROW) 225 COLUMN_OPERATORS.pop(TokenType.HASH_ARROW) 226 COLUMN_OPERATORS.pop(TokenType.DHASH_ARROW) 227 COLUMN_OPERATORS.pop(TokenType.PLACEHOLDER) 228 229 class Generator(MySQL.Generator): 230 SUPPORTED_JSON_PATH_PARTS = { 231 exp.JSONPathKey, 232 exp.JSONPathRoot, 233 exp.JSONPathSubscript, 234 } 235 236 TRANSFORMS = { 237 **MySQL.Generator.TRANSFORMS, 238 exp.TsOrDsToDate: lambda self, e: self.func("TO_DATE", e.this, self.format_time(e)) 239 if e.args.get("format") 240 else self.func("DATE", e.this), 241 exp.StrToTime: lambda self, e: self.func("TO_TIMESTAMP", e.this, self.format_time(e)), 242 exp.ToChar: lambda self, e: self.func("TO_CHAR", e.this, self.format_time(e)), 243 exp.StrToDate: lambda self, e: self.func( 244 "STR_TO_DATE", 245 e.this, 246 self.format_time( 247 e, 248 inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING, 249 inverse_time_trie=MySQL.INVERSE_TIME_TRIE, 250 ), 251 ), 252 exp.TimeToStr: lambda self, e: self.func( 253 "DATE_FORMAT", 254 e.this, 255 self.format_time( 256 e, 257 inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING, 258 inverse_time_trie=MySQL.INVERSE_TIME_TRIE, 259 ), 260 ), 261 exp.Date: unsupported_args("zone", "expressions")(rename_func("DATE")), 262 exp.Cast: unsupported_args("format", "action", "default")( 263 lambda self, e: f"{self.sql(e, 'this')} :> {self.sql(e, 'to')}" 264 ), 265 exp.TryCast: unsupported_args("format", "action", "default")( 266 lambda self, e: f"{self.sql(e, 'this')} !:> {self.sql(e, 'to')}" 267 ), 268 exp.StrToUnix: unsupported_args("format")(rename_func("UNIX_TIMESTAMP")), 269 exp.TimeToUnix: rename_func("UNIX_TIMESTAMP"), 270 exp.TimeStrToUnix: rename_func("UNIX_TIMESTAMP"), 271 exp.UnixSeconds: rename_func("UNIX_TIMESTAMP"), 272 exp.UnixToStr: lambda self, e: self.func( 273 "FROM_UNIXTIME", 274 e.this, 275 self.format_time( 276 e, 277 inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING, 278 inverse_time_trie=MySQL.INVERSE_TIME_TRIE, 279 ), 280 ), 281 exp.UnixToTime: unsupported_args("scale", "zone", "hours", "minutes")( 282 lambda self, e: self.func( 283 "FROM_UNIXTIME", 284 e.this, 285 self.format_time( 286 e, 287 inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING, 288 inverse_time_trie=MySQL.INVERSE_TIME_TRIE, 289 ), 290 ), 291 ), 292 exp.UnixToTimeStr: lambda self, e: f"FROM_UNIXTIME({self.sql(e, 'this')}) :> TEXT", 293 exp.DateBin: unsupported_args("unit", "zone")( 294 lambda self, e: self.func("TIME_BUCKET", e.this, e.expression, e.args.get("origin")) 295 ), 296 exp.TimeStrToDate: lambda self, e: self.sql(exp.cast(e.this, exp.DataType.Type.DATE)), 297 exp.FromTimeZone: lambda self, e: self.func( 298 "CONVERT_TZ", e.this, e.args.get("zone"), "'UTC'" 299 ), 300 exp.DiToDate: lambda self, 301 e: f"STR_TO_DATE({self.sql(e, 'this')}, {SingleStore.DATEINT_FORMAT})", 302 exp.DateToDi: lambda self, 303 e: f"(DATE_FORMAT({self.sql(e, 'this')}, {SingleStore.DATEINT_FORMAT}) :> INT)", 304 exp.TsOrDiToDi: lambda self, 305 e: f"(DATE_FORMAT({self.sql(e, 'this')}, {SingleStore.DATEINT_FORMAT}) :> INT)", 306 exp.Time: unsupported_args("zone")(lambda self, e: f"{self.sql(e, 'this')} :> TIME"), 307 exp.DatetimeAdd: _remove_ts_or_ds_to_date(date_add_sql("ADD")), 308 exp.DatetimeTrunc: unsupported_args("zone")(timestamptrunc_sql()), 309 exp.DatetimeSub: date_add_interval_sql("DATE", "SUB"), 310 exp.DatetimeDiff: timestampdiff_sql, 311 exp.DateTrunc: unsupported_args("zone")(timestamptrunc_sql()), 312 exp.DateDiff: unsupported_args("zone")( 313 lambda self, e: timestampdiff_sql(self, e) 314 if e.unit is not None 315 else self.func("DATEDIFF", e.this, e.expression) 316 ), 317 exp.TimestampTrunc: unsupported_args("zone")(timestamptrunc_sql()), 318 exp.JSONExtract: unsupported_args( 319 "only_json_types", 320 "expressions", 321 "variant_extract", 322 "json_query", 323 "option", 324 "quote", 325 "on_condition", 326 "requires_json", 327 )(json_extract_segments("JSON_EXTRACT_JSON")), 328 exp.JSONBExtract: json_extract_segments("BSON_EXTRACT_BSON"), 329 exp.JSONPathKey: json_path_key_only_name, 330 exp.JSONPathSubscript: lambda self, e: self.json_path_part(e.this), 331 exp.JSONPathRoot: lambda *_: "", 332 exp.JSONFormat: unsupported_args("options", "is_json")(rename_func("JSON_PRETTY")), 333 exp.DayOfWeekIso: lambda self, e: f"(({self.func('DAYOFWEEK', e.this)} % 7) + 1)", 334 exp.DayOfMonth: rename_func("DAY"), 335 exp.Hll: rename_func("APPROX_COUNT_DISTINCT"), 336 exp.ApproxDistinct: rename_func("APPROX_COUNT_DISTINCT"), 337 exp.CountIf: count_if_to_sum, 338 exp.LogicalOr: lambda self, e: f"MAX(ABS({self.sql(e, 'this')}))", 339 exp.LogicalAnd: lambda self, e: f"MIN(ABS({self.sql(e, 'this')}))", 340 exp.ApproxQuantile: unsupported_args("accuracy", "weight")( 341 lambda self, e: self.func( 342 "APPROX_PERCENTILE", 343 e.this, 344 e.args.get("quantile"), 345 e.args.get("error_tolerance"), 346 ) 347 ), 348 exp.Variance: rename_func("VAR_SAMP"), 349 exp.VariancePop: rename_func("VAR_POP"), 350 exp.Xor: bool_xor_sql, 351 exp.RegexpLike: lambda self, e: self.binary(e, "RLIKE"), 352 exp.Repeat: lambda self, e: self.func( 353 "LPAD", 354 exp.Literal.string(""), 355 exp.Mul(this=self.func("LENGTH", e.this), expression=e.args.get("times")), 356 e.this, 357 ), 358 exp.IsAscii: lambda self, e: f"({self.sql(e, 'this')} RLIKE '^[\x00-\x7f]*$')", 359 exp.MD5Digest: lambda self, e: self.func("UNHEX", self.func("MD5", e.this)), 360 exp.Chr: rename_func("CHAR"), 361 exp.Contains: rename_func("INSTR"), 362 exp.RegexpExtractAll: unsupported_args("position", "occurrence", "group")( 363 lambda self, e: self.func( 364 "REGEXP_MATCH", 365 e.this, 366 e.expression, 367 e.args.get("parameters"), 368 ) 369 ), 370 exp.RegexpExtract: unsupported_args("group")( 371 lambda self, e: self.func( 372 "REGEXP_SUBSTR", 373 e.this, 374 e.expression, 375 e.args.get("position"), 376 e.args.get("occurrence"), 377 e.args.get("parameters"), 378 ) 379 ), 380 exp.StartsWith: lambda self, e: self.func( 381 "REGEXP_INSTR", e.this, self.func("CONCAT", exp.Literal.string("^"), e.expression) 382 ), 383 exp.FromBase: lambda self, e: self.func( 384 "CONV", e.this, e.expression, exp.Literal.number(10) 385 ), 386 exp.Reduce: unsupported_args("finish")( 387 lambda self, e: self.func( 388 "REDUCE", e.args.get("initial"), e.this, e.args.get("merge") 389 ) 390 ), 391 } 392 TRANSFORMS.pop(exp.JSONExtractScalar) 393 394 UNSUPPORTED_TYPES = { 395 exp.DataType.Type.ARRAY, 396 exp.DataType.Type.AGGREGATEFUNCTION, 397 exp.DataType.Type.SIMPLEAGGREGATEFUNCTION, 398 exp.DataType.Type.BIGSERIAL, 399 exp.DataType.Type.BPCHAR, 400 exp.DataType.Type.DATEMULTIRANGE, 401 exp.DataType.Type.DATERANGE, 402 exp.DataType.Type.DYNAMIC, 403 exp.DataType.Type.HLLSKETCH, 404 exp.DataType.Type.HSTORE, 405 exp.DataType.Type.IMAGE, 406 exp.DataType.Type.INET, 407 exp.DataType.Type.INT128, 408 exp.DataType.Type.INT256, 409 exp.DataType.Type.INT4MULTIRANGE, 410 exp.DataType.Type.INT4RANGE, 411 exp.DataType.Type.INT8MULTIRANGE, 412 exp.DataType.Type.INT8RANGE, 413 exp.DataType.Type.INTERVAL, 414 exp.DataType.Type.IPADDRESS, 415 exp.DataType.Type.IPPREFIX, 416 exp.DataType.Type.IPV4, 417 exp.DataType.Type.IPV6, 418 exp.DataType.Type.LIST, 419 exp.DataType.Type.MAP, 420 exp.DataType.Type.LOWCARDINALITY, 421 exp.DataType.Type.MONEY, 422 exp.DataType.Type.MULTILINESTRING, 423 exp.DataType.Type.NAME, 424 exp.DataType.Type.NESTED, 425 exp.DataType.Type.NOTHING, 426 exp.DataType.Type.NULL, 427 exp.DataType.Type.NUMMULTIRANGE, 428 exp.DataType.Type.NUMRANGE, 429 exp.DataType.Type.OBJECT, 430 exp.DataType.Type.RANGE, 431 exp.DataType.Type.ROWVERSION, 432 exp.DataType.Type.SERIAL, 433 exp.DataType.Type.SMALLSERIAL, 434 exp.DataType.Type.SMALLMONEY, 435 exp.DataType.Type.STRUCT, 436 exp.DataType.Type.SUPER, 437 exp.DataType.Type.TIMETZ, 438 exp.DataType.Type.TIMESTAMPNTZ, 439 exp.DataType.Type.TIMESTAMPLTZ, 440 exp.DataType.Type.TIMESTAMPTZ, 441 exp.DataType.Type.TIMESTAMP_NS, 442 exp.DataType.Type.TSMULTIRANGE, 443 exp.DataType.Type.TSRANGE, 444 exp.DataType.Type.TSTZMULTIRANGE, 445 exp.DataType.Type.TSTZRANGE, 446 exp.DataType.Type.UINT128, 447 exp.DataType.Type.UINT256, 448 exp.DataType.Type.UNION, 449 exp.DataType.Type.UNKNOWN, 450 exp.DataType.Type.USERDEFINED, 451 exp.DataType.Type.UUID, 452 exp.DataType.Type.VARIANT, 453 exp.DataType.Type.XML, 454 exp.DataType.Type.TDIGEST, 455 } 456 457 TYPE_MAPPING = { 458 **MySQL.Generator.TYPE_MAPPING, 459 exp.DataType.Type.BIGDECIMAL: "DECIMAL", 460 exp.DataType.Type.BIT: "BOOLEAN", 461 exp.DataType.Type.DATE32: "DATE", 462 exp.DataType.Type.DATETIME64: "DATETIME", 463 exp.DataType.Type.DECIMAL32: "DECIMAL", 464 exp.DataType.Type.DECIMAL64: "DECIMAL", 465 exp.DataType.Type.DECIMAL128: "DECIMAL", 466 exp.DataType.Type.DECIMAL256: "DECIMAL", 467 exp.DataType.Type.ENUM8: "ENUM", 468 exp.DataType.Type.ENUM16: "ENUM", 469 exp.DataType.Type.FIXEDSTRING: "TEXT", 470 exp.DataType.Type.GEOMETRY: "GEOGRAPHY", 471 exp.DataType.Type.POINT: "GEOGRAPHYPOINT", 472 exp.DataType.Type.RING: "GEOGRAPHY", 473 exp.DataType.Type.LINESTRING: "GEOGRAPHY", 474 exp.DataType.Type.POLYGON: "GEOGRAPHY", 475 exp.DataType.Type.MULTIPOLYGON: "GEOGRAPHY", 476 exp.DataType.Type.JSONB: "BSON", 477 exp.DataType.Type.TIMESTAMP: "TIMESTAMP", 478 exp.DataType.Type.TIMESTAMP_S: "TIMESTAMP", 479 exp.DataType.Type.TIMESTAMP_MS: "TIMESTAMP(6)", 480 } 481 482 # https://docs.singlestore.com/cloud/reference/sql-reference/restricted-keywords/list-of-restricted-keywords/ 483 RESERVED_KEYWORDS = { 484 "abs", 485 "absolute", 486 "access", 487 "account", 488 "acos", 489 "action", 490 "add", 491 "adddate", 492 "addtime", 493 "admin", 494 "aes_decrypt", 495 "aes_encrypt", 496 "after", 497 "against", 498 "aggregate", 499 "aggregates", 500 "aggregator", 501 "aggregator_id", 502 "aggregator_plan_hash", 503 "aggregators", 504 "algorithm", 505 "all", 506 "also", 507 "alter", 508 "always", 509 "analyse", 510 "analyze", 511 "and", 512 "anti_join", 513 "any", 514 "any_value", 515 "approx_count_distinct", 516 "approx_count_distinct_accumulate", 517 "approx_count_distinct_combine", 518 "approx_count_distinct_estimate", 519 "approx_geography_intersects", 520 "approx_percentile", 521 "arghistory", 522 "arrange", 523 "arrangement", 524 "array", 525 "as", 526 "asc", 527 "ascii", 528 "asensitive", 529 "asin", 530 "asm", 531 "assertion", 532 "assignment", 533 "ast", 534 "asymmetric", 535 "async", 536 "at", 537 "atan", 538 "atan2", 539 "attach", 540 "attribute", 541 "authorization", 542 "auto", 543 "auto_increment", 544 "auto_reprovision", 545 "autostats", 546 "autostats_cardinality_mode", 547 "autostats_enabled", 548 "autostats_histogram_mode", 549 "autostats_sampling", 550 "availability", 551 "avg", 552 "avg_row_length", 553 "avro", 554 "azure", 555 "background", 556 "_background_threads_for_cleanup", 557 "backup", 558 "backup_history", 559 "backup_id", 560 "backward", 561 "batch", 562 "batches", 563 "batch_interval", 564 "_batch_size_limit", 565 "before", 566 "begin", 567 "between", 568 "bigint", 569 "bin", 570 "binary", 571 "_binary", 572 "bit", 573 "bit_and", 574 "bit_count", 575 "bit_or", 576 "bit_xor", 577 "blob", 578 "bool", 579 "boolean", 580 "bootstrap", 581 "both", 582 "_bt", 583 "btree", 584 "bucket_count", 585 "by", 586 "byte", 587 "byte_length", 588 "cache", 589 "call", 590 "call_for_pipeline", 591 "called", 592 "capture", 593 "cascade", 594 "cascaded", 595 "case", 596 "cast", 597 "catalog", 598 "ceil", 599 "ceiling", 600 "chain", 601 "change", 602 "char", 603 "character", 604 "characteristics", 605 "character_length", 606 "char_length", 607 "charset", 608 "check", 609 "checkpoint", 610 "_check_can_connect", 611 "_check_consistency", 612 "checksum", 613 "_checksum", 614 "class", 615 "clear", 616 "client", 617 "client_found_rows", 618 "close", 619 "cluster", 620 "clustered", 621 "cnf", 622 "coalesce", 623 "coercibility", 624 "collate", 625 "collation", 626 "collect", 627 "column", 628 "columnar", 629 "columns", 630 "columnstore", 631 "columnstore_segment_rows", 632 "comment", 633 "comments", 634 "commit", 635 "committed", 636 "_commit_log_tail", 637 "committed", 638 "compact", 639 "compile", 640 "compressed", 641 "compression", 642 "concat", 643 "concat_ws", 644 "concurrent", 645 "concurrently", 646 "condition", 647 "configuration", 648 "connection", 649 "connection_id", 650 "connections", 651 "config", 652 "constraint", 653 "constraints", 654 "content", 655 "continue", 656 "_continue_replay", 657 "conv", 658 "conversion", 659 "convert", 660 "convert_tz", 661 "copy", 662 "_core", 663 "cos", 664 "cost", 665 "cot", 666 "count", 667 "create", 668 "credentials", 669 "cross", 670 "cube", 671 "csv", 672 "cume_dist", 673 "curdate", 674 "current", 675 "current_catalog", 676 "current_date", 677 "current_role", 678 "current_schema", 679 "current_security_groups", 680 "current_security_roles", 681 "current_time", 682 "current_timestamp", 683 "current_user", 684 "cursor", 685 "curtime", 686 "cycle", 687 "data", 688 "database", 689 "databases", 690 "date", 691 "date_add", 692 "datediff", 693 "date_format", 694 "date_sub", 695 "date_trunc", 696 "datetime", 697 "day", 698 "day_hour", 699 "day_microsecond", 700 "day_minute", 701 "dayname", 702 "dayofmonth", 703 "dayofweek", 704 "dayofyear", 705 "day_second", 706 "deallocate", 707 "dec", 708 "decimal", 709 "declare", 710 "decode", 711 "default", 712 "defaults", 713 "deferrable", 714 "deferred", 715 "defined", 716 "definer", 717 "degrees", 718 "delayed", 719 "delay_key_write", 720 "delete", 721 "delimiter", 722 "delimiters", 723 "dense_rank", 724 "desc", 725 "describe", 726 "detach", 727 "deterministic", 728 "dictionary", 729 "differential", 730 "directory", 731 "disable", 732 "discard", 733 "_disconnect", 734 "disk", 735 "distinct", 736 "distinctrow", 737 "distributed_joins", 738 "div", 739 "do", 740 "document", 741 "domain", 742 "dot_product", 743 "double", 744 "drop", 745 "_drop_profile", 746 "dual", 747 "dump", 748 "duplicate", 749 "dynamic", 750 "earliest", 751 "each", 752 "echo", 753 "election", 754 "else", 755 "elseif", 756 "elt", 757 "enable", 758 "enclosed", 759 "encoding", 760 "encrypted", 761 "end", 762 "engine", 763 "engines", 764 "enum", 765 "errors", 766 "escape", 767 "escaped", 768 "estimate", 769 "euclidean_distance", 770 "event", 771 "events", 772 "except", 773 "exclude", 774 "excluding", 775 "exclusive", 776 "execute", 777 "exists", 778 "exit", 779 "exp", 780 "explain", 781 "extended", 782 "extension", 783 "external", 784 "external_host", 785 "external_port", 786 "extract", 787 "extractor", 788 "extractors", 789 "extra_join", 790 "_failover", 791 "failed_login_attempts", 792 "failure", 793 "false", 794 "family", 795 "fault", 796 "fetch", 797 "field", 798 "fields", 799 "file", 800 "files", 801 "fill", 802 "first", 803 "first_value", 804 "fix_alter", 805 "fixed", 806 "float", 807 "float4", 808 "float8", 809 "floor", 810 "flush", 811 "following", 812 "for", 813 "force", 814 "force_compiled_mode", 815 "force_interpreter_mode", 816 "foreground", 817 "foreign", 818 "format", 819 "forward", 820 "found_rows", 821 "freeze", 822 "from", 823 "from_base64", 824 "from_days", 825 "from_unixtime", 826 "fs", 827 "_fsync", 828 "full", 829 "fulltext", 830 "function", 831 "functions", 832 "gc", 833 "gcs", 834 "get_format", 835 "_gc", 836 "_gcx", 837 "generate", 838 "geography", 839 "geography_area", 840 "geography_contains", 841 "geography_distance", 842 "geography_intersects", 843 "geography_latitude", 844 "geography_length", 845 "geography_longitude", 846 "geographypoint", 847 "geography_point", 848 "geography_within_distance", 849 "geometry", 850 "geometry_area", 851 "geometry_contains", 852 "geometry_distance", 853 "geometry_filter", 854 "geometry_intersects", 855 "geometry_length", 856 "geometrypoint", 857 "geometry_point", 858 "geometry_within_distance", 859 "geometry_x", 860 "geometry_y", 861 "global", 862 "_global_version_timestamp", 863 "grant", 864 "granted", 865 "grants", 866 "greatest", 867 "group", 868 "grouping", 869 "groups", 870 "group_concat", 871 "gzip", 872 "handle", 873 "handler", 874 "hard_cpu_limit_percentage", 875 "hash", 876 "has_temp_tables", 877 "having", 878 "hdfs", 879 "header", 880 "heartbeat_no_logging", 881 "hex", 882 "highlight", 883 "high_priority", 884 "hold", 885 "holding", 886 "host", 887 "hosts", 888 "hour", 889 "hour_microsecond", 890 "hour_minute", 891 "hour_second", 892 "identified", 893 "identity", 894 "if", 895 "ifnull", 896 "ignore", 897 "ilike", 898 "immediate", 899 "immutable", 900 "implicit", 901 "import", 902 "in", 903 "including", 904 "increment", 905 "incremental", 906 "index", 907 "indexes", 908 "inet_aton", 909 "inet_ntoa", 910 "inet6_aton", 911 "inet6_ntoa", 912 "infile", 913 "inherit", 914 "inherits", 915 "_init_profile", 916 "init", 917 "initcap", 918 "initialize", 919 "initially", 920 "inject", 921 "inline", 922 "inner", 923 "inout", 924 "input", 925 "insensitive", 926 "insert", 927 "insert_method", 928 "instance", 929 "instead", 930 "instr", 931 "int", 932 "int1", 933 "int2", 934 "int3", 935 "int4", 936 "int8", 937 "integer", 938 "_internal_dynamic_typecast", 939 "interpreter_mode", 940 "intersect", 941 "interval", 942 "into", 943 "invoker", 944 "is", 945 "isnull", 946 "isolation", 947 "iterate", 948 "join", 949 "json", 950 "json_agg", 951 "json_array_contains_double", 952 "json_array_contains_json", 953 "json_array_contains_string", 954 "json_array_push_double", 955 "json_array_push_json", 956 "json_array_push_string", 957 "json_delete_key", 958 "json_extract_double", 959 "json_extract_json", 960 "json_extract_string", 961 "json_extract_bigint", 962 "json_get_type", 963 "json_length", 964 "json_set_double", 965 "json_set_json", 966 "json_set_string", 967 "json_splice_double", 968 "json_splice_json", 969 "json_splice_string", 970 "kafka", 971 "key", 972 "key_block_size", 973 "keys", 974 "kill", 975 "killall", 976 "label", 977 "lag", 978 "language", 979 "large", 980 "last", 981 "last_day", 982 "last_insert_id", 983 "last_value", 984 "lateral", 985 "latest", 986 "lc_collate", 987 "lc_ctype", 988 "lcase", 989 "lead", 990 "leading", 991 "leaf", 992 "leakproof", 993 "least", 994 "leave", 995 "leaves", 996 "left", 997 "length", 998 "level", 999 "license", 1000 "like", 1001 "limit", 1002 "lines", 1003 "listen", 1004 "llvm", 1005 "ln", 1006 "load", 1007 "loaddata_where", 1008 "_load", 1009 "local", 1010 "localtime", 1011 "localtimestamp", 1012 "locate", 1013 "location", 1014 "lock", 1015 "log", 1016 "log10", 1017 "log2", 1018 "long", 1019 "longblob", 1020 "longtext", 1021 "loop", 1022 "lower", 1023 "low_priority", 1024 "lpad", 1025 "_ls", 1026 "ltrim", 1027 "lz4", 1028 "management", 1029 "_management_thread", 1030 "mapping", 1031 "master", 1032 "match", 1033 "materialized", 1034 "max", 1035 "maxvalue", 1036 "max_concurrency", 1037 "max_errors", 1038 "max_partitions_per_batch", 1039 "max_queue_depth", 1040 "max_retries_per_batch_partition", 1041 "max_rows", 1042 "mbc", 1043 "md5", 1044 "mpl", 1045 "median", 1046 "mediumblob", 1047 "mediumint", 1048 "mediumtext", 1049 "member", 1050 "memory", 1051 "memory_percentage", 1052 "_memsql_table_id_lookup", 1053 "memsql", 1054 "memsql_deserialize", 1055 "memsql_imitating_kafka", 1056 "memsql_serialize", 1057 "merge", 1058 "metadata", 1059 "microsecond", 1060 "middleint", 1061 "min", 1062 "min_rows", 1063 "minus", 1064 "minute", 1065 "minute_microsecond", 1066 "minute_second", 1067 "minvalue", 1068 "mod", 1069 "mode", 1070 "model", 1071 "modifies", 1072 "modify", 1073 "month", 1074 "monthname", 1075 "months_between", 1076 "move", 1077 "mpl", 1078 "names", 1079 "named", 1080 "namespace", 1081 "national", 1082 "natural", 1083 "nchar", 1084 "next", 1085 "no", 1086 "node", 1087 "none", 1088 "no_query_rewrite", 1089 "noparam", 1090 "not", 1091 "nothing", 1092 "notify", 1093 "now", 1094 "nowait", 1095 "no_write_to_binlog", 1096 "no_query_rewrite", 1097 "norely", 1098 "nth_value", 1099 "ntile", 1100 "null", 1101 "nullcols", 1102 "nullif", 1103 "nulls", 1104 "numeric", 1105 "nvarchar", 1106 "object", 1107 "octet_length", 1108 "of", 1109 "off", 1110 "offline", 1111 "offset", 1112 "offsets", 1113 "oids", 1114 "on", 1115 "online", 1116 "only", 1117 "open", 1118 "operator", 1119 "optimization", 1120 "optimize", 1121 "optimizer", 1122 "optimizer_state", 1123 "option", 1124 "options", 1125 "optionally", 1126 "or", 1127 "order", 1128 "ordered_serialize", 1129 "orphan", 1130 "out", 1131 "out_of_order", 1132 "outer", 1133 "outfile", 1134 "over", 1135 "overlaps", 1136 "overlay", 1137 "owned", 1138 "owner", 1139 "pack_keys", 1140 "paired", 1141 "parser", 1142 "parquet", 1143 "partial", 1144 "partition", 1145 "partition_id", 1146 "partitioning", 1147 "partitions", 1148 "passing", 1149 "password", 1150 "password_lock_time", 1151 "parser", 1152 "pause", 1153 "_pause_replay", 1154 "percent_rank", 1155 "percentile_cont", 1156 "percentile_disc", 1157 "periodic", 1158 "persisted", 1159 "pi", 1160 "pipeline", 1161 "pipelines", 1162 "pivot", 1163 "placing", 1164 "plan", 1165 "plans", 1166 "plancache", 1167 "plugins", 1168 "pool", 1169 "pools", 1170 "port", 1171 "position", 1172 "pow", 1173 "power", 1174 "preceding", 1175 "precision", 1176 "prepare", 1177 "prepared", 1178 "preserve", 1179 "primary", 1180 "prior", 1181 "privileges", 1182 "procedural", 1183 "procedure", 1184 "procedures", 1185 "process", 1186 "processlist", 1187 "profile", 1188 "profiles", 1189 "program", 1190 "promote", 1191 "proxy", 1192 "purge", 1193 "quarter", 1194 "queries", 1195 "query", 1196 "query_timeout", 1197 "queue", 1198 "quote", 1199 "radians", 1200 "rand", 1201 "range", 1202 "rank", 1203 "read", 1204 "_read", 1205 "reads", 1206 "real", 1207 "reassign", 1208 "rebalance", 1209 "recheck", 1210 "record", 1211 "recursive", 1212 "redundancy", 1213 "redundant", 1214 "ref", 1215 "reference", 1216 "references", 1217 "refresh", 1218 "regexp", 1219 "reindex", 1220 "relative", 1221 "release", 1222 "reload", 1223 "rely", 1224 "remote", 1225 "remove", 1226 "rename", 1227 "repair", 1228 "_repair_table", 1229 "repeat", 1230 "repeatable", 1231 "_repl", 1232 "_reprovisioning", 1233 "replace", 1234 "replica", 1235 "replicate", 1236 "replicating", 1237 "replication", 1238 "durability", 1239 "require", 1240 "resource", 1241 "resource_pool", 1242 "reset", 1243 "restart", 1244 "restore", 1245 "restrict", 1246 "result", 1247 "_resurrect", 1248 "retry", 1249 "return", 1250 "returning", 1251 "returns", 1252 "reverse", 1253 "revoke", 1254 "rg_pool", 1255 "right", 1256 "right_anti_join", 1257 "right_semi_join", 1258 "right_straight_join", 1259 "rlike", 1260 "role", 1261 "roles", 1262 "rollback", 1263 "rollup", 1264 "round", 1265 "routine", 1266 "row", 1267 "row_count", 1268 "row_format", 1269 "row_number", 1270 "rows", 1271 "rowstore", 1272 "rule", 1273 "rpad", 1274 "_rpc", 1275 "rtrim", 1276 "running", 1277 "s3", 1278 "safe", 1279 "save", 1280 "savepoint", 1281 "scalar", 1282 "schema", 1283 "schemas", 1284 "schema_binding", 1285 "scroll", 1286 "search", 1287 "second", 1288 "second_microsecond", 1289 "sec_to_time", 1290 "security", 1291 "select", 1292 "semi_join", 1293 "_send_threads", 1294 "sensitive", 1295 "separator", 1296 "sequence", 1297 "sequences", 1298 "serial", 1299 "serializable", 1300 "series", 1301 "service_user", 1302 "server", 1303 "session", 1304 "session_user", 1305 "set", 1306 "setof", 1307 "security_lists_intersect", 1308 "sha", 1309 "sha1", 1310 "sha2", 1311 "shard", 1312 "sharded", 1313 "sharded_id", 1314 "share", 1315 "show", 1316 "shutdown", 1317 "sigmoid", 1318 "sign", 1319 "signal", 1320 "similar", 1321 "simple", 1322 "site", 1323 "signed", 1324 "sin", 1325 "skip", 1326 "skipped_batches", 1327 "sleep", 1328 "_sleep", 1329 "smallint", 1330 "snapshot", 1331 "_snapshot", 1332 "_snapshots", 1333 "soft_cpu_limit_percentage", 1334 "some", 1335 "soname", 1336 "sparse", 1337 "spatial", 1338 "spatial_check_index", 1339 "specific", 1340 "split", 1341 "sql", 1342 "sql_big_result", 1343 "sql_buffer_result", 1344 "sql_cache", 1345 "sql_calc_found_rows", 1346 "sqlexception", 1347 "sql_mode", 1348 "sql_no_cache", 1349 "sql_no_logging", 1350 "sql_small_result", 1351 "sqlstate", 1352 "sqlwarning", 1353 "sqrt", 1354 "ssl", 1355 "stable", 1356 "standalone", 1357 "start", 1358 "starting", 1359 "state", 1360 "statement", 1361 "statistics", 1362 "stats", 1363 "status", 1364 "std", 1365 "stddev", 1366 "stddev_pop", 1367 "stddev_samp", 1368 "stdin", 1369 "stdout", 1370 "stop", 1371 "storage", 1372 "str_to_date", 1373 "straight_join", 1374 "strict", 1375 "string", 1376 "strip", 1377 "subdate", 1378 "substr", 1379 "substring", 1380 "substring_index", 1381 "success", 1382 "sum", 1383 "super", 1384 "symmetric", 1385 "sync_snapshot", 1386 "sync", 1387 "_sync", 1388 "_sync2", 1389 "_sync_partitions", 1390 "_sync_snapshot", 1391 "synchronize", 1392 "sysid", 1393 "system", 1394 "table", 1395 "table_checksum", 1396 "tables", 1397 "tablespace", 1398 "tags", 1399 "tan", 1400 "target_size", 1401 "task", 1402 "temp", 1403 "template", 1404 "temporary", 1405 "temptable", 1406 "_term_bump", 1407 "terminate", 1408 "terminated", 1409 "test", 1410 "text", 1411 "then", 1412 "time", 1413 "timediff", 1414 "time_bucket", 1415 "time_format", 1416 "timeout", 1417 "timestamp", 1418 "timestampadd", 1419 "timestampdiff", 1420 "timezone", 1421 "time_to_sec", 1422 "tinyblob", 1423 "tinyint", 1424 "tinytext", 1425 "to", 1426 "to_base64", 1427 "to_char", 1428 "to_date", 1429 "to_days", 1430 "to_json", 1431 "to_number", 1432 "to_seconds", 1433 "to_timestamp", 1434 "tracelogs", 1435 "traditional", 1436 "trailing", 1437 "transform", 1438 "transaction", 1439 "_transactions_experimental", 1440 "treat", 1441 "trigger", 1442 "triggers", 1443 "trim", 1444 "true", 1445 "trunc", 1446 "truncate", 1447 "trusted", 1448 "two_phase", 1449 "_twopcid", 1450 "type", 1451 "types", 1452 "ucase", 1453 "unbounded", 1454 "uncommitted", 1455 "undefined", 1456 "undo", 1457 "unencrypted", 1458 "unenforced", 1459 "unhex", 1460 "unhold", 1461 "unicode", 1462 "union", 1463 "unique", 1464 "_unittest", 1465 "unix_timestamp", 1466 "unknown", 1467 "unlisten", 1468 "_unload", 1469 "unlock", 1470 "unlogged", 1471 "unpivot", 1472 "unsigned", 1473 "until", 1474 "update", 1475 "upgrade", 1476 "upper", 1477 "usage", 1478 "use", 1479 "user", 1480 "users", 1481 "using", 1482 "utc_date", 1483 "utc_time", 1484 "utc_timestamp", 1485 "_utf8", 1486 "vacuum", 1487 "valid", 1488 "validate", 1489 "validator", 1490 "value", 1491 "values", 1492 "varbinary", 1493 "varchar", 1494 "varcharacter", 1495 "variables", 1496 "variadic", 1497 "variance", 1498 "var_pop", 1499 "var_samp", 1500 "varying", 1501 "vector_sub", 1502 "verbose", 1503 "version", 1504 "view", 1505 "void", 1506 "volatile", 1507 "voting", 1508 "wait", 1509 "_wake", 1510 "warnings", 1511 "week", 1512 "weekday", 1513 "weekofyear", 1514 "when", 1515 "where", 1516 "while", 1517 "whitespace", 1518 "window", 1519 "with", 1520 "without", 1521 "within", 1522 "_wm_heartbeat", 1523 "work", 1524 "workload", 1525 "wrapper", 1526 "write", 1527 "xact_id", 1528 "xor", 1529 "year", 1530 "year_month", 1531 "yes", 1532 "zerofill", 1533 "zone", 1534 } 1535 1536 def jsonextractscalar_sql(self, expression: exp.JSONExtractScalar) -> str: 1537 json_type = expression.args.get("json_type") 1538 func_name = "JSON_EXTRACT_JSON" if json_type is None else f"JSON_EXTRACT_{json_type}" 1539 return json_extract_segments(func_name)(self, expression) 1540 1541 def jsonbextractscalar_sql(self, expression: exp.JSONBExtractScalar) -> str: 1542 json_type = expression.args.get("json_type") 1543 func_name = "BSON_EXTRACT_BSON" if json_type is None else f"BSON_EXTRACT_{json_type}" 1544 return json_extract_segments(func_name)(self, expression) 1545 1546 def jsonextractarray_sql(self, expression: exp.JSONExtractArray) -> str: 1547 self.unsupported("Arrays are not supported in SingleStore") 1548 return self.function_fallback_sql(expression) 1549 1550 @unsupported_args("on_condition") 1551 def jsonvalue_sql(self, expression: exp.JSONValue) -> str: 1552 res: exp.Expression = exp.JSONExtractScalar( 1553 this=expression.this, 1554 expression=expression.args.get("path"), 1555 json_type="STRING", 1556 ) 1557 1558 returning = expression.args.get("returning") 1559 if returning is not None: 1560 res = exp.Cast(this=res, to=returning) 1561 1562 return self.sql(res) 1563 1564 def all_sql(self, expression: exp.All) -> str: 1565 self.unsupported("ALL subquery predicate is not supported in SingleStore") 1566 return super().all_sql(expression) 1567 1568 def jsonarraycontains_sql(self, expression: exp.JSONArrayContains) -> str: 1569 json_type = expression.text("json_type").upper() 1570 1571 if json_type: 1572 return self.func( 1573 f"JSON_ARRAY_CONTAINS_{json_type}", expression.expression, expression.this 1574 ) 1575 1576 return self.func( 1577 "JSON_ARRAY_CONTAINS_JSON", 1578 expression.expression, 1579 self.func("TO_JSON", expression.this), 1580 ) 1581 1582 @unsupported_args("kind", "nested", "values") 1583 def datatype_sql(self, expression: exp.DataType) -> str: 1584 if expression.is_type(exp.DataType.Type.VARBINARY) and not expression.expressions: 1585 # `VARBINARY` must always have a size - if it doesn't, we always generate `BLOB` 1586 return "BLOB" 1587 if expression.is_type( 1588 exp.DataType.Type.DECIMAL32, 1589 exp.DataType.Type.DECIMAL64, 1590 exp.DataType.Type.DECIMAL128, 1591 exp.DataType.Type.DECIMAL256, 1592 ): 1593 scale = self.expressions(expression, flat=True) 1594 1595 if expression.is_type(exp.DataType.Type.DECIMAL32): 1596 precision = "9" 1597 elif expression.is_type(exp.DataType.Type.DECIMAL64): 1598 precision = "18" 1599 elif expression.is_type(exp.DataType.Type.DECIMAL128): 1600 precision = "38" 1601 else: 1602 # 65 is a maximum precision supported in SingleStore 1603 precision = "65" 1604 if scale is not None: 1605 return f"DECIMAL({precision}, {scale[0]})" 1606 else: 1607 return f"DECIMAL({precision})" 1608 1609 return super().datatype_sql(expression)
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.
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'>
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}}}
55 class Tokenizer(MySQL.Tokenizer): 56 BYTE_STRINGS = [("e'", "'"), ("E'", "'")] 57 58 KEYWORDS = { 59 **MySQL.Tokenizer.KEYWORDS, 60 "BSON": TokenType.JSONB, 61 "GEOGRAPHYPOINT": TokenType.GEOGRAPHYPOINT, 62 "TIMESTAMP": TokenType.TIMESTAMP, 63 ":>": TokenType.COLON_GT, 64 "!:>": TokenType.NCOLON_GT, 65 "::$": TokenType.DCOLONDOLLAR, 66 "::%": TokenType.DCOLONPERCENT, 67 }
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'>, 'ALWAYS': <TokenType.ALWAYS: 'ALWAYS'>, 'AND': <TokenType.AND: 'AND'>, 'ANTI': <TokenType.ANTI: 'ANTI'>, 'ANY': <TokenType.ANY: 'ANY'>, 'ASC': <TokenType.ASC: 'ASC'>, 'AS': <TokenType.ALIAS: 'ALIAS'>, 'ASOF': <TokenType.ASOF: 'ASOF'>, 'AUTOINCREMENT': <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, 'AUTO_INCREMENT': <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, 'BEGIN': <TokenType.BEGIN: 'BEGIN'>, 'BETWEEN': <TokenType.BETWEEN: 'BETWEEN'>, 'CACHE': <TokenType.CACHE: 'CACHE'>, 'UNCACHE': <TokenType.UNCACHE: 'UNCACHE'>, 'CASE': <TokenType.CASE: 'CASE'>, 'CHARACTER SET': <TokenType.CHARACTER_SET: 'CHARACTER_SET'>, 'CLUSTER BY': <TokenType.CLUSTER_BY: 'CLUSTER_BY'>, 'COLLATE': <TokenType.COLLATE: 'COLLATE'>, 'COLUMN': <TokenType.COLUMN: 'COLUMN'>, 'COMMIT': <TokenType.COMMIT: 'COMMIT'>, 'CONNECT BY': <TokenType.CONNECT_BY: 'CONNECT_BY'>, 'CONSTRAINT': <TokenType.CONSTRAINT: 'CONSTRAINT'>, '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'>, 'SET': <TokenType.SET: 'SET'>, 'SETTINGS': <TokenType.SETTINGS: 'SETTINGS'>, 'SHOW': <TokenType.SHOW: 'SHOW'>, 'SIMILAR TO': <TokenType.SIMILAR_TO: 'SIMILAR_TO'>, 'SOME': <TokenType.SOME: 'SOME'>, 'SORT BY': <TokenType.SORT_BY: 'SORT_BY'>, 'START WITH': <TokenType.START_WITH: 'START_WITH'>, 'STRAIGHT_JOIN': <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, 'TABLE': <TokenType.TABLE: 'TABLE'>, 'TABLESAMPLE': <TokenType.TABLE_SAMPLE: 'TABLE_SAMPLE'>, 'TEMP': <TokenType.TEMPORARY: 'TEMPORARY'>, 'TEMPORARY': <TokenType.TEMPORARY: 'TEMPORARY'>, 'THEN': <TokenType.THEN: 'THEN'>, 'TRUE': <TokenType.TRUE: 'TRUE'>, 'TRUNCATE': <TokenType.TRUNCATE: 'TRUNCATE'>, 'UNION': <TokenType.UNION: 'UNION'>, 'UNKNOWN': <TokenType.UNKNOWN: 'UNKNOWN'>, 'UNNEST': <TokenType.UNNEST: 'UNNEST'>, 'UNPIVOT': <TokenType.UNPIVOT: 'UNPIVOT'>, 'UPDATE': <TokenType.UPDATE: 'UPDATE'>, 'USE': <TokenType.USE: 'USE'>, 'USING': <TokenType.USING: 'USING'>, 'UUID': <TokenType.UUID: 'UUID'>, 'VALUES': <TokenType.VALUES: 'VALUES'>, 'VIEW': <TokenType.VIEW: 'VIEW'>, 'VOLATILE': <TokenType.VOLATILE: 'VOLATILE'>, 'WHEN': <TokenType.WHEN: 'WHEN'>, 'WHERE': <TokenType.WHERE: 'WHERE'>, 'WINDOW': <TokenType.WINDOW: 'WINDOW'>, 'WITH': <TokenType.WITH: 'WITH'>, 'APPLY': <TokenType.APPLY: 'APPLY'>, 'ARRAY': <TokenType.ARRAY: 'ARRAY'>, 'BIT': <TokenType.BIT: 'BIT'>, 'BOOL': <TokenType.BOOLEAN: 'BOOLEAN'>, 'BOOLEAN': <TokenType.BOOLEAN: 'BOOLEAN'>, 'BYTE': <TokenType.TINYINT: 'TINYINT'>, 'MEDIUMINT': <TokenType.MEDIUMINT: 'MEDIUMINT'>, 'INT1': <TokenType.TINYINT: 'TINYINT'>, 'TINYINT': <TokenType.TINYINT: 'TINYINT'>, 'INT16': <TokenType.SMALLINT: 'SMALLINT'>, 'SHORT': <TokenType.SMALLINT: 'SMALLINT'>, 'SMALLINT': <TokenType.SMALLINT: 'SMALLINT'>, 'HUGEINT': <TokenType.INT128: 'INT128'>, 'UHUGEINT': <TokenType.UINT128: 'UINT128'>, 'INT2': <TokenType.SMALLINT: 'SMALLINT'>, 'INTEGER': <TokenType.INT: 'INT'>, 'INT': <TokenType.INT: 'INT'>, 'INT4': <TokenType.INT: 'INT'>, 'INT32': <TokenType.INT: 'INT'>, 'INT64': <TokenType.BIGINT: 'BIGINT'>, 'INT128': <TokenType.INT128: 'INT128'>, 'INT256': <TokenType.INT256: 'INT256'>, 'LONG': <TokenType.BIGINT: 'BIGINT'>, 'BIGINT': <TokenType.BIGINT: 'BIGINT'>, 'INT8': <TokenType.TINYINT: 'TINYINT'>, 'UINT': <TokenType.UINT: 'UINT'>, 'UINT128': <TokenType.UINT128: 'UINT128'>, 'UINT256': <TokenType.UINT256: 'UINT256'>, 'DEC': <TokenType.DECIMAL: 'DECIMAL'>, 'DECIMAL': <TokenType.DECIMAL: 'DECIMAL'>, 'DECIMAL32': <TokenType.DECIMAL32: 'DECIMAL32'>, 'DECIMAL64': <TokenType.DECIMAL64: 'DECIMAL64'>, 'DECIMAL128': <TokenType.DECIMAL128: 'DECIMAL128'>, 'DECIMAL256': <TokenType.DECIMAL256: 'DECIMAL256'>, 'BIGDECIMAL': <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, 'BIGNUMERIC': <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, 'LIST': <TokenType.LIST: 'LIST'>, 'MAP': <TokenType.MAP: 'MAP'>, 'NULLABLE': <TokenType.NULLABLE: 'NULLABLE'>, 'NUMBER': <TokenType.DECIMAL: 'DECIMAL'>, 'NUMERIC': <TokenType.DECIMAL: 'DECIMAL'>, 'FIXED': <TokenType.DECIMAL: 'DECIMAL'>, 'REAL': <TokenType.FLOAT: 'FLOAT'>, 'FLOAT': <TokenType.FLOAT: 'FLOAT'>, 'FLOAT4': <TokenType.FLOAT: 'FLOAT'>, 'FLOAT8': <TokenType.DOUBLE: 'DOUBLE'>, 'DOUBLE': <TokenType.DOUBLE: 'DOUBLE'>, 'DOUBLE PRECISION': <TokenType.DOUBLE: 'DOUBLE'>, 'JSON': <TokenType.JSON: 'JSON'>, 'JSONB': <TokenType.JSONB: 'JSONB'>, 'CHAR': <TokenType.CHAR: 'CHAR'>, 'CHARACTER': <TokenType.CHAR: 'CHAR'>, 'CHAR VARYING': <TokenType.VARCHAR: 'VARCHAR'>, 'CHARACTER VARYING': <TokenType.VARCHAR: 'VARCHAR'>, 'NCHAR': <TokenType.NCHAR: 'NCHAR'>, 'VARCHAR': <TokenType.VARCHAR: 'VARCHAR'>, 'VARCHAR2': <TokenType.VARCHAR: 'VARCHAR'>, 'NVARCHAR': <TokenType.NVARCHAR: 'NVARCHAR'>, 'NVARCHAR2': <TokenType.NVARCHAR: 'NVARCHAR'>, 'BPCHAR': <TokenType.BPCHAR: 'BPCHAR'>, 'STR': <TokenType.TEXT: 'TEXT'>, 'STRING': <TokenType.TEXT: 'TEXT'>, 'TEXT': <TokenType.TEXT: 'TEXT'>, 'LONGTEXT': <TokenType.LONGTEXT: 'LONGTEXT'>, 'MEDIUMTEXT': <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, 'TINYTEXT': <TokenType.TINYTEXT: 'TINYTEXT'>, 'CLOB': <TokenType.TEXT: 'TEXT'>, 'LONGVARCHAR': <TokenType.TEXT: 'TEXT'>, 'BINARY': <TokenType.BINARY: 'BINARY'>, 'BLOB': <TokenType.BLOB: 'BLOB'>, 'LONGBLOB': <TokenType.LONGBLOB: 'LONGBLOB'>, 'MEDIUMBLOB': <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, 'TINYBLOB': <TokenType.TINYBLOB: 'TINYBLOB'>, 'BYTEA': <TokenType.VARBINARY: 'VARBINARY'>, 'VARBINARY': <TokenType.VARBINARY: 'VARBINARY'>, 'TIME': <TokenType.TIME: 'TIME'>, 'TIMETZ': <TokenType.TIMETZ: 'TIMETZ'>, 'TIMESTAMP': <TokenType.TIMESTAMP: 'TIMESTAMP'>, 'TIMESTAMPTZ': <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, 'TIMESTAMPLTZ': <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, 'TIMESTAMP_LTZ': <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, 'TIMESTAMPNTZ': <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, 'TIMESTAMP_NTZ': <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, 'DATE': <TokenType.DATE: 'DATE'>, 'DATETIME': <TokenType.DATETIME: 'DATETIME'>, 'INT4RANGE': <TokenType.INT4RANGE: 'INT4RANGE'>, 'INT4MULTIRANGE': <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, 'INT8RANGE': <TokenType.INT8RANGE: 'INT8RANGE'>, 'INT8MULTIRANGE': <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, 'NUMRANGE': <TokenType.NUMRANGE: 'NUMRANGE'>, 'NUMMULTIRANGE': <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, 'TSRANGE': <TokenType.TSRANGE: 'TSRANGE'>, 'TSMULTIRANGE': <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, 'TSTZRANGE': <TokenType.TSTZRANGE: 'TSTZRANGE'>, 'TSTZMULTIRANGE': <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, 'DATERANGE': <TokenType.DATERANGE: 'DATERANGE'>, 'DATEMULTIRANGE': <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, 'UNIQUE': <TokenType.UNIQUE: 'UNIQUE'>, 'VECTOR': <TokenType.VECTOR: 'VECTOR'>, 'STRUCT': <TokenType.STRUCT: 'STRUCT'>, 'SEQUENCE': <TokenType.SEQUENCE: 'SEQUENCE'>, 'VARIANT': <TokenType.VARIANT: 'VARIANT'>, 'ALTER': <TokenType.ALTER: 'ALTER'>, 'ANALYZE': <TokenType.ANALYZE: 'ANALYZE'>, 'CALL': <TokenType.COMMAND: 'COMMAND'>, 'COMMENT': <TokenType.COMMENT: 'COMMENT'>, 'EXPLAIN': <TokenType.DESCRIBE: 'DESCRIBE'>, 'GRANT': <TokenType.GRANT: 'GRANT'>, 'REVOKE': <TokenType.REVOKE: 'REVOKE'>, 'OPTIMIZE': <TokenType.COMMAND: 'COMMAND'>, 'PREPARE': <TokenType.COMMAND: 'COMMAND'>, 'VACUUM': <TokenType.COMMAND: 'COMMAND'>, 'USER-DEFINED': <TokenType.USERDEFINED: 'USERDEFINED'>, 'FOR VERSION': <TokenType.VERSION_SNAPSHOT: 'VERSION_SNAPSHOT'>, 'FOR TIMESTAMP': <TokenType.TIMESTAMP_SNAPSHOT: 'TIMESTAMP_SNAPSHOT'>, 'CHARSET': <TokenType.CHARACTER_SET: 'CHARACTER_SET'>, 'DISTINCTROW': <TokenType.DISTINCT: 'DISTINCT'>, 'FORCE': <TokenType.FORCE: 'FORCE'>, 'IGNORE': <TokenType.IGNORE: 'IGNORE'>, 'KEY': <TokenType.KEY: 'KEY'>, 'LOCK TABLES': <TokenType.COMMAND: 'COMMAND'>, 'MEMBER OF': <TokenType.MEMBER_OF: 'MEMBER_OF'>, 'SEPARATOR': <TokenType.SEPARATOR: 'SEPARATOR'>, 'SERIAL': <TokenType.SERIAL: 'SERIAL'>, 'START': <TokenType.BEGIN: 'BEGIN'>, 'SIGNED': <TokenType.BIGINT: 'BIGINT'>, 'SIGNED INTEGER': <TokenType.BIGINT: 'BIGINT'>, 'UNLOCK TABLES': <TokenType.COMMAND: 'COMMAND'>, 'UNSIGNED': <TokenType.UBIGINT: 'UBIGINT'>, 'UNSIGNED INTEGER': <TokenType.UBIGINT: 'UBIGINT'>, 'YEAR': <TokenType.YEAR: 'YEAR'>, '_ARMSCII8': <TokenType.INTRODUCER: 'INTRODUCER'>, '_ASCII': <TokenType.INTRODUCER: 'INTRODUCER'>, '_BIG5': <TokenType.INTRODUCER: 'INTRODUCER'>, '_BINARY': <TokenType.INTRODUCER: 'INTRODUCER'>, '_CP1250': <TokenType.INTRODUCER: 'INTRODUCER'>, '_CP1251': <TokenType.INTRODUCER: 'INTRODUCER'>, '_CP1256': <TokenType.INTRODUCER: 'INTRODUCER'>, '_CP1257': <TokenType.INTRODUCER: 'INTRODUCER'>, '_CP850': <TokenType.INTRODUCER: 'INTRODUCER'>, '_CP852': <TokenType.INTRODUCER: 'INTRODUCER'>, '_CP866': <TokenType.INTRODUCER: 'INTRODUCER'>, '_CP932': <TokenType.INTRODUCER: 'INTRODUCER'>, '_DEC8': <TokenType.INTRODUCER: 'INTRODUCER'>, '_EUCJPMS': <TokenType.INTRODUCER: 'INTRODUCER'>, '_EUCKR': <TokenType.INTRODUCER: 'INTRODUCER'>, '_GB18030': <TokenType.INTRODUCER: 'INTRODUCER'>, '_GB2312': <TokenType.INTRODUCER: 'INTRODUCER'>, '_GBK': <TokenType.INTRODUCER: 'INTRODUCER'>, '_GEOSTD8': <TokenType.INTRODUCER: 'INTRODUCER'>, '_GREEK': <TokenType.INTRODUCER: 'INTRODUCER'>, '_HEBREW': <TokenType.INTRODUCER: 'INTRODUCER'>, '_HP8': <TokenType.INTRODUCER: 'INTRODUCER'>, '_KEYBCS2': <TokenType.INTRODUCER: 'INTRODUCER'>, '_KOI8R': <TokenType.INTRODUCER: 'INTRODUCER'>, '_KOI8U': <TokenType.INTRODUCER: 'INTRODUCER'>, '_LATIN1': <TokenType.INTRODUCER: 'INTRODUCER'>, '_LATIN2': <TokenType.INTRODUCER: 'INTRODUCER'>, '_LATIN5': <TokenType.INTRODUCER: 'INTRODUCER'>, '_LATIN7': <TokenType.INTRODUCER: 'INTRODUCER'>, '_MACCE': <TokenType.INTRODUCER: 'INTRODUCER'>, '_MACROMAN': <TokenType.INTRODUCER: 'INTRODUCER'>, '_SJIS': <TokenType.INTRODUCER: 'INTRODUCER'>, '_SWE7': <TokenType.INTRODUCER: 'INTRODUCER'>, '_TIS620': <TokenType.INTRODUCER: 'INTRODUCER'>, '_UCS2': <TokenType.INTRODUCER: 'INTRODUCER'>, '_UJIS': <TokenType.INTRODUCER: 'INTRODUCER'>, '_UTF8': <TokenType.INTRODUCER: 'INTRODUCER'>, '_UTF16': <TokenType.INTRODUCER: 'INTRODUCER'>, '_UTF16LE': <TokenType.INTRODUCER: 'INTRODUCER'>, '_UTF32': <TokenType.INTRODUCER: 'INTRODUCER'>, '_UTF8MB3': <TokenType.INTRODUCER: 'INTRODUCER'>, '_UTF8MB4': <TokenType.INTRODUCER: 'INTRODUCER'>, '@@': <TokenType.SESSION_PARAMETER: 'SESSION_PARAMETER'>, 'BSON': <TokenType.JSONB: 'JSONB'>, 'GEOGRAPHYPOINT': <TokenType.GEOGRAPHYPOINT: 'GEOGRAPHYPOINT'>, ':>': <TokenType.COLON_GT: 'COLON_GT'>, '!:>': <TokenType.NCOLON_GT: 'NCOLON_GT'>, '::$': <TokenType.DCOLONDOLLAR: 'DCOLONDOLLAR'>, '::%': <TokenType.DCOLONPERCENT: 'DCOLONPERCENT'>}
Inherited Members
- sqlglot.tokens.Tokenizer
- Tokenizer
- SINGLE_TOKENS
- RAW_STRINGS
- HEREDOC_STRINGS
- UNICODE_STRINGS
- VAR_SINGLE_TOKENS
- IDENTIFIER_ESCAPES
- HEREDOC_TAG_IS_IDENTIFIER
- HEREDOC_STRING_ALTERNATIVE
- STRING_ESCAPES_ALLOWED_IN_RAW_STRINGS
- HINT_START
- TOKENS_PRECEDING_HINT
- WHITE_SPACE
- COMMAND_PREFIX_TOKENS
- NUMERIC_LITERALS
- dialect
- use_rs_tokenizer
- reset
- tokenize
- tokenize_rs
- size
- sql
- tokens
69 class Parser(MySQL.Parser): 70 FUNCTIONS = { 71 **MySQL.Parser.FUNCTIONS, 72 "TO_DATE": build_formatted_time(exp.TsOrDsToDate, "singlestore"), 73 "TO_TIMESTAMP": build_formatted_time(exp.StrToTime, "singlestore"), 74 "TO_CHAR": build_formatted_time(exp.ToChar, "singlestore"), 75 "STR_TO_DATE": build_formatted_time(exp.StrToDate, "mysql"), 76 "DATE_FORMAT": build_formatted_time(exp.TimeToStr, "mysql"), 77 # The first argument of following functions is converted to TIME(6) 78 # This is needed because exp.TimeToStr is converted to DATE_FORMAT 79 # which interprets the first argument as DATETIME and fails to parse 80 # string literals like '12:05:47' without a date part. 81 "TIME_FORMAT": lambda args: exp.TimeToStr( 82 this=cast_to_time6(seq_get(args, 0)), 83 format=MySQL.format_time(seq_get(args, 1)), 84 ), 85 "HOUR": lambda args: exp.cast( 86 exp.TimeToStr( 87 this=cast_to_time6(seq_get(args, 0)), 88 format=MySQL.format_time(exp.Literal.string("%k")), 89 ), 90 DataType.Type.INT, 91 ), 92 "MICROSECOND": lambda args: exp.cast( 93 exp.TimeToStr( 94 this=cast_to_time6(seq_get(args, 0)), 95 format=MySQL.format_time(exp.Literal.string("%f")), 96 ), 97 DataType.Type.INT, 98 ), 99 "SECOND": lambda args: exp.cast( 100 exp.TimeToStr( 101 this=cast_to_time6(seq_get(args, 0)), 102 format=MySQL.format_time(exp.Literal.string("%s")), 103 ), 104 DataType.Type.INT, 105 ), 106 "MINUTE": lambda args: exp.cast( 107 exp.TimeToStr( 108 this=cast_to_time6(seq_get(args, 0)), 109 format=MySQL.format_time(exp.Literal.string("%i")), 110 ), 111 DataType.Type.INT, 112 ), 113 "MONTHNAME": lambda args: exp.TimeToStr( 114 this=seq_get(args, 0), 115 format=MySQL.format_time(exp.Literal.string("%M")), 116 ), 117 "WEEKDAY": lambda args: exp.paren(exp.DayOfWeek(this=seq_get(args, 0)) + 5, copy=False) 118 % 7, 119 "UNIX_TIMESTAMP": exp.StrToUnix.from_arg_list, 120 "FROM_UNIXTIME": build_formatted_time(exp.UnixToTime, "mysql"), 121 "TIME_BUCKET": lambda args: exp.DateBin( 122 this=seq_get(args, 0), 123 expression=seq_get(args, 1), 124 origin=seq_get(args, 2), 125 ), 126 "BSON_EXTRACT_BSON": build_json_extract_path(exp.JSONBExtract), 127 "BSON_EXTRACT_STRING": build_json_extract_path( 128 exp.JSONBExtractScalar, json_type="STRING" 129 ), 130 "BSON_EXTRACT_DOUBLE": build_json_extract_path( 131 exp.JSONBExtractScalar, json_type="DOUBLE" 132 ), 133 "BSON_EXTRACT_BIGINT": build_json_extract_path( 134 exp.JSONBExtractScalar, json_type="BIGINT" 135 ), 136 "JSON_EXTRACT_JSON": build_json_extract_path(exp.JSONExtract), 137 "JSON_EXTRACT_STRING": build_json_extract_path( 138 exp.JSONExtractScalar, json_type="STRING" 139 ), 140 "JSON_EXTRACT_DOUBLE": build_json_extract_path( 141 exp.JSONExtractScalar, json_type="DOUBLE" 142 ), 143 "JSON_EXTRACT_BIGINT": build_json_extract_path( 144 exp.JSONExtractScalar, json_type="BIGINT" 145 ), 146 "JSON_ARRAY_CONTAINS_STRING": lambda args: exp.JSONArrayContains( 147 this=seq_get(args, 1), 148 expression=seq_get(args, 0), 149 json_type="STRING", 150 ), 151 "JSON_ARRAY_CONTAINS_DOUBLE": lambda args: exp.JSONArrayContains( 152 this=seq_get(args, 1), 153 expression=seq_get(args, 0), 154 json_type="DOUBLE", 155 ), 156 "JSON_ARRAY_CONTAINS_JSON": lambda args: exp.JSONArrayContains( 157 this=seq_get(args, 1), 158 expression=seq_get(args, 0), 159 json_type="JSON", 160 ), 161 "JSON_PRETTY": exp.JSONFormat.from_arg_list, 162 "DATE": exp.Date.from_arg_list, 163 "DAYNAME": lambda args: exp.TimeToStr( 164 this=seq_get(args, 0), 165 format=MySQL.format_time(exp.Literal.string("%W")), 166 ), 167 "TIMESTAMPDIFF": lambda args: exp.TimestampDiff( 168 this=seq_get(args, 2), 169 expression=seq_get(args, 1), 170 unit=seq_get(args, 0), 171 ), 172 "APPROX_COUNT_DISTINCT": exp.Hll.from_arg_list, 173 "APPROX_PERCENTILE": lambda args, dialect: exp.ApproxQuantile( 174 this=seq_get(args, 0), 175 quantile=seq_get(args, 1), 176 error_tolerance=seq_get(args, 2), 177 ), 178 "VARIANCE": exp.VariancePop.from_arg_list, 179 "INSTR": exp.Contains.from_arg_list, 180 "REGEXP_MATCH": lambda args: exp.RegexpExtractAll( 181 this=seq_get(args, 0), 182 expression=seq_get(args, 1), 183 parameters=seq_get(args, 2), 184 ), 185 "REGEXP_SUBSTR": lambda args: exp.RegexpExtract( 186 this=seq_get(args, 0), 187 expression=seq_get(args, 1), 188 position=seq_get(args, 2), 189 occurrence=seq_get(args, 3), 190 parameters=seq_get(args, 4), 191 ), 192 "REDUCE": lambda args: exp.Reduce( 193 initial=seq_get(args, 0), 194 this=seq_get(args, 1), 195 merge=seq_get(args, 2), 196 ), 197 } 198 199 CAST_COLUMN_OPERATORS = {TokenType.COLON_GT, TokenType.NCOLON_GT} 200 201 COLUMN_OPERATORS = { 202 **MySQL.Parser.COLUMN_OPERATORS, 203 TokenType.COLON_GT: lambda self, this, to: self.expression( 204 exp.Cast, 205 this=this, 206 to=to, 207 ), 208 TokenType.NCOLON_GT: lambda self, this, to: self.expression( 209 exp.TryCast, 210 this=this, 211 to=to, 212 ), 213 TokenType.DCOLON: lambda self, this, path: build_json_extract_path(exp.JSONExtract)( 214 [this, exp.Literal.string(path.name)] 215 ), 216 TokenType.DCOLONDOLLAR: lambda self, this, path: build_json_extract_path( 217 exp.JSONExtractScalar, json_type="STRING" 218 )([this, exp.Literal.string(path.name)]), 219 TokenType.DCOLONPERCENT: lambda self, this, path: build_json_extract_path( 220 exp.JSONExtractScalar, json_type="DOUBLE" 221 )([this, exp.Literal.string(path.name)]), 222 } 223 COLUMN_OPERATORS.pop(TokenType.ARROW) 224 COLUMN_OPERATORS.pop(TokenType.DARROW) 225 COLUMN_OPERATORS.pop(TokenType.HASH_ARROW) 226 COLUMN_OPERATORS.pop(TokenType.DHASH_ARROW) 227 COLUMN_OPERATORS.pop(TokenType.PLACEHOLDER)
Parser consumes a list of tokens produced by the Tokenizer and produces a parsed syntax tree.
Arguments:
- error_level: The desired error level. Default: ErrorLevel.IMMEDIATE
- error_message_context: The amount of context to capture from a query string when displaying the error message (in number of characters). Default: 100
- max_errors: Maximum number of error messages to include in a raised ParseError. This is only relevant if error_level is ErrorLevel.RAISE. Default: 3
FUNCTIONS =
{'ABS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Abs'>>, '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'>>, 'AVG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Avg'>>, 'BIT_AND': <bound method Func.from_arg_list of <class 'sqlglot.expressions.BitwiseAndAgg'>>, 'BIT_COUNT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.BitwiseCountAgg'>>, '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'>>, 'BYTE_LENGTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ByteLength'>>, 'CASE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Case'>>, 'CAST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Cast'>>, 'CAST_TO_STR_TYPE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CastToStrType'>>, 'CBRT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Cbrt'>>, 'CEIL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Ceil'>>, 'CEILING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Ceil'>>, 'CHR': <function Parser.<lambda>>, 'CHAR': <function Parser.<lambda>>, 'COALESCE': <function build_coalesce>, 'IFNULL': <function build_coalesce>, 'NVL': <function build_coalesce>, 'CODE_POINTS_TO_BYTES': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CodePointsToBytes'>>, 'CODE_POINTS_TO_STRING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CodePointsToString'>>, 'COLLATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Collate'>>, 'COLUMNS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Columns'>>, 'COMBINED_AGG_FUNC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CombinedAggFunc'>>, 'COMBINED_PARAMETERIZED_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CombinedParameterizedAgg'>>, 'CONCAT': <function Parser.<lambda>>, 'CONCAT_WS': <function Parser.<lambda>>, 'CONNECT_BY_ROOT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ConnectByRoot'>>, 'CONTAINS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Contains'>>, 'CONVERT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Convert'>>, 'CONVERT_TIMEZONE': <function build_convert_timezone>, 'CONVERT_TO_CHARSET': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ConvertToCharset'>>, 'CORR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Corr'>>, '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'>>, 'CUME_DIST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CumeDist'>>, 'CURRENT_DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CurrentDate'>>, 'CURRENT_DATETIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CurrentDatetime'>>, 'CURRENT_SCHEMA': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CurrentSchema'>>, 'CURRENT_TIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CurrentTime'>>, 'CURRENT_TIMESTAMP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CurrentTimestamp'>>, 'CURRENT_TIMESTAMP_L_T_Z': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CurrentTimestampLTZ'>>, 'CURRENT_USER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.CurrentUser'>>, 'DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Date'>>, 'DATE_ADD': <function build_date_delta_with_interval.<locals>._builder>, 'DATE_BIN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateBin'>>, 'DATEDIFF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateDiff'>>, 'DATE_DIFF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateDiff'>>, 'DATE_FROM_PARTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateFromParts'>>, 'DATEFROMPARTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateFromParts'>>, 'DATE_FROM_UNIX_DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateFromUnixDate'>>, 'DATE_STR_TO_DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateStrToDate'>>, 'DATE_SUB': <function build_date_delta_with_interval.<locals>._builder>, 'DATE_TO_DATE_STR': <function Parser.<lambda>>, 'DATE_TO_DI': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateToDi'>>, 'DATE_TRUNC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DateTrunc'>>, 'DATETIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Datetime'>>, 'DATETIME_ADD': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DatetimeAdd'>>, 'DATETIME_DIFF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DatetimeDiff'>>, 'DATETIME_SUB': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DatetimeSub'>>, 'DATETIME_TRUNC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DatetimeTrunc'>>, 'DAY': <function MySQL.Parser.<lambda>>, 'DAY_OF_MONTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DayOfMonth'>>, 'DAYOFMONTH': <function MySQL.Parser.<lambda>>, 'DAY_OF_WEEK': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DayOfWeek'>>, 'DAYOFWEEK': <function MySQL.Parser.<lambda>>, 'DAYOFWEEK_ISO': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DayOfWeekIso'>>, 'ISODOW': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DayOfWeekIso'>>, 'DAY_OF_YEAR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DayOfYear'>>, 'DAYOFYEAR': <function MySQL.Parser.<lambda>>, 'DECODE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Decode'>>, 'DECODE_CASE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DecodeCase'>>, 'DENSE_RANK': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DenseRank'>>, 'DI_TO_DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.DiToDate'>>, 'ENCODE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Encode'>>, 'ENDS_WITH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.EndsWith'>>, 'ENDSWITH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.EndsWith'>>, 'EXISTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Exists'>>, 'EXP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Exp'>>, 'EXPLODE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Explode'>>, 'EXPLODE_OUTER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ExplodeOuter'>>, 'EXPLODING_GENERATE_SERIES': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ExplodingGenerateSeries'>>, 'EXTRACT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Extract'>>, 'FARM_FINGERPRINT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.FarmFingerprint'>>, 'FARMFINGERPRINT64': <bound method Func.from_arg_list of <class 'sqlglot.expressions.FarmFingerprint'>>, 'FEATURES_AT_TIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.FeaturesAtTime'>>, 'FIRST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.First'>>, 'FIRST_VALUE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.FirstValue'>>, 'FLATTEN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Flatten'>>, 'FLOAT64': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Float64'>>, 'FLOOR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Floor'>>, 'FORMAT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.NumberToStr'>>, 'FROM_BASE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.FromBase'>>, 'FROM_BASE32': <bound method Func.from_arg_list of <class 'sqlglot.expressions.FromBase32'>>, 'FROM_BASE64': <bound method Func.from_arg_list of <class 'sqlglot.expressions.FromBase64'>>, 'FROM_ISO8601_TIMESTAMP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.FromISO8601Timestamp'>>, 'GAP_FILL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.GapFill'>>, 'GENERATE_DATE_ARRAY': <function Parser.<lambda>>, 'GENERATE_EMBEDDING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.GenerateEmbedding'>>, 'GENERATE_SERIES': <bound method Func.from_arg_list of <class 'sqlglot.expressions.GenerateSeries'>>, 'GENERATE_TIMESTAMP_ARRAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.GenerateTimestampArray'>>, 'GET_EXTRACT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.GetExtract'>>, 'GREATEST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Greatest'>>, 'GROUP_CONCAT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.GroupConcat'>>, 'GROUPING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Grouping'>>, 'HEX': <function build_hex>, 'HLL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Hll'>>, 'IF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.If'>>, 'IIF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.If'>>, 'INITCAP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Initcap'>>, 'INLINE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Inline'>>, 'INT64': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Int64'>>, 'IS_ASCII': <bound method Func.from_arg_list of <class 'sqlglot.expressions.IsAscii'>>, 'IS_INF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.IsInf'>>, 'ISINF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.IsInf'>>, 'IS_NAN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.IsNan'>>, 'ISNAN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.IsNan'>>, 'J_S_O_N_ARRAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONArray'>>, 'J_S_O_N_ARRAY_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONArrayAgg'>>, 'JSON_ARRAY_APPEND': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONArrayAppend'>>, 'JSON_ARRAY_CONTAINS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONArrayContains'>>, 'JSON_ARRAY_INSERT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONArrayInsert'>>, 'JSONB_CONTAINS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONBContains'>>, 'JSONB_EXISTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONBExists'>>, 'JSONB_EXTRACT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONBExtract'>>, 'JSONB_EXTRACT_SCALAR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONBExtractScalar'>>, 'J_S_O_N_B_OBJECT_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONBObjectAgg'>>, 'J_S_O_N_BOOL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONBool'>>, 'J_S_O_N_CAST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONCast'>>, 'J_S_O_N_EXISTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONExists'>>, 'JSON_EXTRACT': <function build_extract_json_with_path.<locals>._builder>, 'JSON_EXTRACT_ARRAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONExtractArray'>>, 'JSON_EXTRACT_SCALAR': <function build_extract_json_with_path.<locals>._builder>, 'JSON_FORMAT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONFormat'>>, 'J_S_O_N_KEYS_AT_DEPTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONKeysAtDepth'>>, 'J_S_O_N_OBJECT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONObject'>>, 'J_S_O_N_OBJECT_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONObjectAgg'>>, 'JSON_REMOVE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONRemove'>>, 'JSON_SET': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONSet'>>, 'JSON_STRIP_NULLS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONStripNulls'>>, 'J_S_O_N_TABLE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONTable'>>, 'JSON_TYPE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONType'>>, 'J_S_O_N_VALUE_ARRAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JSONValueArray'>>, 'JUSTIFY_DAYS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JustifyDays'>>, 'JUSTIFY_HOURS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JustifyHours'>>, 'JUSTIFY_INTERVAL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.JustifyInterval'>>, 'LAG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Lag'>>, 'LAST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Last'>>, 'LAST_DAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LastDay'>>, 'LAST_DAY_OF_MONTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LastDay'>>, 'LAST_VALUE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LastValue'>>, 'LAX_BOOL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LaxBool'>>, 'LAX_FLOAT64': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LaxFloat64'>>, 'LAX_INT64': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LaxInt64'>>, 'LAX_STRING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LaxString'>>, 'LEAD': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Lead'>>, 'LEAST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Least'>>, 'LEFT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Left'>>, 'LENGTH': <function MySQL.Parser.<lambda>>, 'LEN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Length'>>, 'CHAR_LENGTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Length'>>, 'CHARACTER_LENGTH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Length'>>, 'LEVENSHTEIN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Levenshtein'>>, 'LIST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.List'>>, 'LN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Ln'>>, 'LOG': <function build_logarithm>, 'LOGICAL_AND': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LogicalAnd'>>, 'BOOL_AND': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LogicalAnd'>>, 'BOOLAND_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LogicalAnd'>>, 'LOGICAL_OR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LogicalOr'>>, 'BOOL_OR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LogicalOr'>>, 'BOOLOR_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LogicalOr'>>, 'LOWER': <function build_lower>, 'LCASE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Lower'>>, 'LOWER_HEX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.LowerHex'>>, 'MD5': <bound method Func.from_arg_list of <class 'sqlglot.expressions.MD5'>>, 'MD5_DIGEST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.MD5Digest'>>, 'MAKE_INTERVAL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.MakeInterval'>>, 'MAP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Map'>>, 'MAP_FROM_ENTRIES': <bound method Func.from_arg_list of <class 'sqlglot.expressions.MapFromEntries'>>, 'MATCH_AGAINST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.MatchAgainst'>>, 'MAX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Max'>>, 'MEDIAN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Median'>>, 'MIN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Min'>>, 'MONTH': <function MySQL.Parser.<lambda>>, 'MONTHS_BETWEEN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.MonthsBetween'>>, 'NEXT_VALUE_FOR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.NextValueFor'>>, 'NORMALIZE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Normalize'>>, 'NTH_VALUE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.NthValue'>>, 'NTILE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Ntile'>>, 'NULLIF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Nullif'>>, 'NUMBER_TO_STR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.NumberToStr'>>, 'NVL2': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Nvl2'>>, 'OBJECT_INSERT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ObjectInsert'>>, 'OPEN_J_S_O_N': <bound method Func.from_arg_list of <class 'sqlglot.expressions.OpenJSON'>>, 'OR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Or'>>, 'OVERLAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Overlay'>>, 'PAD': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Pad'>>, 'PARAMETERIZED_AGG': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ParameterizedAgg'>>, 'PARSE_BIGNUMERIC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ParseBignumeric'>>, 'PARSE_DATETIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ParseDatetime'>>, 'PARSE_JSON': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ParseJSON'>>, 'JSON_PARSE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ParseJSON'>>, 'PARSE_NUMERIC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ParseNumeric'>>, 'PARSE_TIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ParseTime'>>, 'PERCENT_RANK': <bound method Func.from_arg_list of <class 'sqlglot.expressions.PercentRank'>>, 'PERCENTILE_CONT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.PercentileCont'>>, 'PERCENTILE_DISC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.PercentileDisc'>>, 'POSEXPLODE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Posexplode'>>, 'POSEXPLODE_OUTER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.PosexplodeOuter'>>, 'POWER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Pow'>>, 'POW': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Pow'>>, 'PREDICT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Predict'>>, 'QUANTILE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Quantile'>>, 'QUARTER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Quarter'>>, 'RAND': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Rand'>>, 'RANDOM': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Rand'>>, 'RANDN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Randn'>>, 'RANGE_N': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RangeN'>>, 'RANK': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Rank'>>, 'READ_CSV': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ReadCSV'>>, 'REDUCE': <function SingleStore.Parser.<lambda>>, 'REGEXP_EXTRACT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpExtract'>>, 'REGEXP_EXTRACT_ALL': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpExtractAll'>>, 'REGEXP_I_LIKE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpILike'>>, 'REGEXP_INSTR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpInstr'>>, 'REGEXP_LIKE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpLike'>>, 'REGEXP_REPLACE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpReplace'>>, 'REGEXP_SPLIT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RegexpSplit'>>, 'REPEAT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Repeat'>>, 'REPLACE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Replace'>>, 'REVERSE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Reverse'>>, 'RIGHT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Right'>>, 'ROUND': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Round'>>, 'ROW_NUMBER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.RowNumber'>>, 'SHA': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SHA'>>, 'SHA1': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SHA'>>, 'SHA2': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SHA2'>>, 'SAFE_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'>>, 'SIGN': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Sign'>>, 'SIGNUM': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Sign'>>, 'SORT_ARRAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SortArray'>>, 'SOUNDEX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Soundex'>>, 'SPACE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Space'>>, 'SPLIT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Split'>>, 'SPLIT_PART': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SplitPart'>>, 'SQRT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Sqrt'>>, 'ST_DISTANCE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StDistance'>>, 'ST_POINT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StPoint'>>, 'ST_MAKEPOINT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StPoint'>>, 'STANDARD_HASH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StandardHash'>>, 'STAR_MAP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StarMap'>>, 'STARTS_WITH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StartsWith'>>, 'STARTSWITH': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StartsWith'>>, 'STDDEV': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Stddev'>>, 'STDEV': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Stddev'>>, 'STDDEV_POP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StddevPop'>>, 'STDDEV_SAMP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StddevSamp'>>, 'STR_POSITION': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StrPosition'>>, 'STR_TO_DATE': <function build_formatted_time.<locals>._builder>, 'STR_TO_MAP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StrToMap'>>, 'STR_TO_TIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StrToTime'>>, 'STR_TO_UNIX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StrToUnix'>>, 'STRING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.String'>>, 'STRING_TO_ARRAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StringToArray'>>, 'SPLIT_BY_STRING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StringToArray'>>, 'STRTOK_TO_ARRAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StringToArray'>>, 'STRUCT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Struct'>>, 'STRUCT_EXTRACT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.StructExtract'>>, 'STUFF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Stuff'>>, 'INSERT': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Stuff'>>, 'SUBSTRING': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Substring'>>, 'SUBSTR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Substring'>>, 'SUBSTRING_INDEX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.SubstringIndex'>>, 'SUM': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Sum'>>, 'TIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Time'>>, 'TIME_ADD': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeAdd'>>, 'TIME_DIFF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeDiff'>>, 'TIME_FROM_PARTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeFromParts'>>, 'TIMEFROMPARTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeFromParts'>>, 'TIME_STR_TO_DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeStrToDate'>>, 'TIME_STR_TO_TIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeStrToTime'>>, 'TIME_STR_TO_UNIX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeStrToUnix'>>, 'TIME_SUB': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeSub'>>, 'TIME_TO_STR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeToStr'>>, 'TIME_TO_TIME_STR': <function Parser.<lambda>>, 'TIME_TO_UNIX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeToUnix'>>, 'TIME_TRUNC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimeTrunc'>>, 'TIMESTAMP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Timestamp'>>, 'TIMESTAMP_ADD': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimestampAdd'>>, 'TIMESTAMPDIFF': <function SingleStore.Parser.<lambda>>, 'TIMESTAMP_DIFF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimestampDiff'>>, 'TIMESTAMP_FROM_PARTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimestampFromParts'>>, 'TIMESTAMPFROMPARTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimestampFromParts'>>, 'TIMESTAMP_SUB': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimestampSub'>>, 'TIMESTAMP_TRUNC': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TimestampTrunc'>>, 'TO_ARRAY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ToArray'>>, 'TO_BASE32': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ToBase32'>>, 'TO_BASE64': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ToBase64'>>, 'TO_CHAR': <function build_formatted_time.<locals>._builder>, 'TO_CODE_POINTS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ToCodePoints'>>, 'TO_DAYS': <function MySQL.Parser.<lambda>>, 'TO_DOUBLE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ToDouble'>>, 'TO_MAP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ToMap'>>, 'TO_NUMBER': <bound method Func.from_arg_list of <class 'sqlglot.expressions.ToNumber'>>, 'TRANSFORM': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Transform'>>, 'TRANSLATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Translate'>>, 'TRIM': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Trim'>>, 'TRY': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Try'>>, 'TRY_CAST': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TryCast'>>, 'TS_OR_DI_TO_DI': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TsOrDiToDi'>>, 'TS_OR_DS_ADD': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TsOrDsAdd'>>, 'TS_OR_DS_DIFF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TsOrDsDiff'>>, 'TS_OR_DS_TO_DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TsOrDsToDate'>>, 'TS_OR_DS_TO_DATE_STR': <function Parser.<lambda>>, 'TS_OR_DS_TO_DATETIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TsOrDsToDatetime'>>, 'TS_OR_DS_TO_TIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TsOrDsToTime'>>, 'TS_OR_DS_TO_TIMESTAMP': <bound method Func.from_arg_list of <class 'sqlglot.expressions.TsOrDsToTimestamp'>>, 'TYPEOF': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Typeof'>>, 'UNHEX': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Unhex'>>, 'UNICODE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Unicode'>>, 'UNIX_DATE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.UnixDate'>>, 'UNIX_MICROS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.UnixMicros'>>, 'UNIX_MILLIS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.UnixMillis'>>, 'UNIX_SECONDS': <bound method Func.from_arg_list of <class 'sqlglot.expressions.UnixSeconds'>>, 'UNIX_TO_STR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.UnixToStr'>>, 'UNIX_TO_TIME': <bound method Func.from_arg_list of <class 'sqlglot.expressions.UnixToTime'>>, 'UNIX_TO_TIME_STR': <bound method Func.from_arg_list of <class 'sqlglot.expressions.UnixToTimeStr'>>, 'UNNEST': <function Parser.<lambda>>, 'UPPER': <function build_upper>, 'UCASE': <bound method Func.from_arg_list of <class 'sqlglot.expressions.Upper'>>, '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>, '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'>>, 'DAYNAME': <function SingleStore.Parser.<lambda>>, 'APPROX_PERCENTILE': <function SingleStore.Parser.<lambda>>, 'REGEXP_MATCH': <function SingleStore.Parser.<lambda>>, 'REGEXP_SUBSTR': <function SingleStore.Parser.<lambda>>}
COLUMN_OPERATORS =
{<TokenType.DOT: 'DOT'>: None, <TokenType.DOTCOLON: 'DOTCOLON'>: <function Parser.<lambda>>, <TokenType.DCOLON: 'DCOLON'>: <function SingleStore.Parser.<lambda>>, <TokenType.COLON_GT: 'COLON_GT'>: <function SingleStore.Parser.<lambda>>, <TokenType.NCOLON_GT: 'NCOLON_GT'>: <function SingleStore.Parser.<lambda>>, <TokenType.DCOLONDOLLAR: 'DCOLONDOLLAR'>: <function SingleStore.Parser.<lambda>>, <TokenType.DCOLONPERCENT: 'DCOLONPERCENT'>: <function SingleStore.Parser.<lambda>>}
TABLE_ALIAS_TOKENS =
{<TokenType.LIMIT: 'LIMIT'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.GEOGRAPHYPOINT: 'GEOGRAPHYPOINT'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.ATTACH: 'ATTACH'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.GET: 'GET'>, <TokenType.YEAR: 'YEAR'>, <TokenType.SOURCE: 'SOURCE'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.ANTI: 'ANTI'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.VECTOR: 'VECTOR'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.CURRENT_SCHEMA: 'CURRENT_SCHEMA'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.BIT: 'BIT'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.CASE: 'CASE'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.IS: 'IS'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.JSONB: 'JSONB'>, <TokenType.VOID: 'VOID'>, <TokenType.ENUM: 'ENUM'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.CUBE: 'CUBE'>, <TokenType.STAGE: 'STAGE'>, <TokenType.MULTILINESTRING: 'MULTILINESTRING'>, <TokenType.MERGE: 'MERGE'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.KILL: 'KILL'>, <TokenType.OFFSET: 'OFFSET'>, <TokenType.EXPORT: 'EXPORT'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.NOTHING: 'NOTHING'>, <TokenType.RANGE: 'RANGE'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.SMALLDATETIME: 'SMALLDATETIME'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.ANY: 'ANY'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.DECIMAL256: 'DECIMAL256'>, <TokenType.APPLY: 'APPLY'>, <TokenType.SHOW: 'SHOW'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.UINT: 'UINT'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.VIEW: 'VIEW'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.FINAL: 'FINAL'>, <TokenType.BINARY: 'BINARY'>, <TokenType.RENAME: 'RENAME'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.SEMI: 'SEMI'>, <TokenType.TOP: 'TOP'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.FIRST: 'FIRST'>, <TokenType.JSON: 'JSON'>, <TokenType.SOME: 'SOME'>, <TokenType.TABLE: 'TABLE'>, <TokenType.SUPER: 'SUPER'>, <TokenType.NULL: 'NULL'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.INDEX: 'INDEX'>, <TokenType.SINK: 'SINK'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.DATE: 'DATE'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.POINT: 'POINT'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.LOAD: 'LOAD'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.FILE_FORMAT: 'FILE_FORMAT'>, <TokenType.LINESTRING: 'LINESTRING'>, <TokenType.NAMESPACE: 'NAMESPACE'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.DATE32: 'DATE32'>, <TokenType.NEXT: 'NEXT'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.MAP: 'MAP'>, <TokenType.INET: 'INET'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.LIST: 'LIST'>, <TokenType.INT128: 'INT128'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.ALL: 'ALL'>, <TokenType.COPY: 'COPY'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.DYNAMIC: 'DYNAMIC'>, <TokenType.FALSE: 'FALSE'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.RING: 'RING'>, <TokenType.INT256: 'INT256'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.ASC: 'ASC'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.DECIMAL64: 'DECIMAL64'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.DESC: 'DESC'>, <TokenType.ROW: 'ROW'>, <TokenType.UPDATE: 'UPDATE'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.UINT256: 'UINT256'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.ROWS: 'ROWS'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.IPV4: 'IPV4'>, <TokenType.DIV: 'DIV'>, <TokenType.KEEP: 'KEEP'>, <TokenType.DELETE: 'DELETE'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.XML: 'XML'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.TEXT: 'TEXT'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.COMMENT: 'COMMENT'>, <TokenType.SET: 'SET'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.CHAR: 'CHAR'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.ROLLUP: 'ROLLUP'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, <TokenType.ESCAPE: 'ESCAPE'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.DETACH: 'DETACH'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.UINT128: 'UINT128'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.TRUE: 'TRUE'>, <TokenType.DATETIME2: 'DATETIME2'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.NESTED: 'NESTED'>, <TokenType.VAR: 'VAR'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.FILTER: 'FILTER'>, <TokenType.MONEY: 'MONEY'>, <TokenType.TIME: 'TIME'>, <TokenType.DECIMAL128: 'DECIMAL128'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.WAREHOUSE: 'WAREHOUSE'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.BLOB: 'BLOB'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.UUID: 'UUID'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.END: 'END'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.PUT: 'PUT'>, <TokenType.MODEL: 'MODEL'>, <TokenType.IPV6: 'IPV6'>, <TokenType.SEMANTIC_VIEW: 'SEMANTIC_VIEW'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.POLYGON: 'POLYGON'>, <TokenType.INT: 'INT'>, <TokenType.CACHE: 'CACHE'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.DECIMAL32: 'DECIMAL32'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.TAG: 'TAG'>, <TokenType.MULTIPOLYGON: 'MULTIPOLYGON'>, <TokenType.UDOUBLE: 'UDOUBLE'>, <TokenType.NAME: 'NAME'>, <TokenType.STREAMLIT: 'STREAMLIT'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.DATETIME: 'DATETIME'>}
ID_VAR_TOKENS =
{<TokenType.LIMIT: 'LIMIT'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.GEOGRAPHYPOINT: 'GEOGRAPHYPOINT'>, <TokenType.RIGHT: 'RIGHT'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.ATTACH: 'ATTACH'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.GET: 'GET'>, <TokenType.YEAR: 'YEAR'>, <TokenType.SOURCE: 'SOURCE'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.ANTI: 'ANTI'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.VECTOR: 'VECTOR'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.CURRENT_SCHEMA: 'CURRENT_SCHEMA'>, <TokenType.LEFT: 'LEFT'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.BIT: 'BIT'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.CASE: 'CASE'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.IS: 'IS'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.JSONB: 'JSONB'>, <TokenType.VOID: 'VOID'>, <TokenType.ENUM: 'ENUM'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.CUBE: 'CUBE'>, <TokenType.STAGE: 'STAGE'>, <TokenType.MULTILINESTRING: 'MULTILINESTRING'>, <TokenType.MERGE: 'MERGE'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.KILL: 'KILL'>, <TokenType.OFFSET: 'OFFSET'>, <TokenType.EXPORT: 'EXPORT'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.NOTHING: 'NOTHING'>, <TokenType.RANGE: 'RANGE'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.ASOF: 'ASOF'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.SMALLDATETIME: 'SMALLDATETIME'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.NATURAL: 'NATURAL'>, <TokenType.ANY: 'ANY'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.DECIMAL256: 'DECIMAL256'>, <TokenType.APPLY: 'APPLY'>, <TokenType.SHOW: 'SHOW'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.UINT: 'UINT'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.VIEW: 'VIEW'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.FINAL: 'FINAL'>, <TokenType.BINARY: 'BINARY'>, <TokenType.RENAME: 'RENAME'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.SEMI: 'SEMI'>, <TokenType.TOP: 'TOP'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.FIRST: 'FIRST'>, <TokenType.JSON: 'JSON'>, <TokenType.SOME: 'SOME'>, <TokenType.TABLE: 'TABLE'>, <TokenType.SUPER: 'SUPER'>, <TokenType.NULL: 'NULL'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.INDEX: 'INDEX'>, <TokenType.SINK: 'SINK'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.DATE: 'DATE'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.POINT: 'POINT'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.LOAD: 'LOAD'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.FILE_FORMAT: 'FILE_FORMAT'>, <TokenType.LINESTRING: 'LINESTRING'>, <TokenType.NAMESPACE: 'NAMESPACE'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.DATE32: 'DATE32'>, <TokenType.NEXT: 'NEXT'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.MAP: 'MAP'>, <TokenType.INET: 'INET'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.LIST: 'LIST'>, <TokenType.INT128: 'INT128'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.ALL: 'ALL'>, <TokenType.COPY: 'COPY'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.DYNAMIC: 'DYNAMIC'>, <TokenType.FALSE: 'FALSE'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.RING: 'RING'>, <TokenType.INT256: 'INT256'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.ASC: 'ASC'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.DECIMAL64: 'DECIMAL64'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.DESC: 'DESC'>, <TokenType.ROW: 'ROW'>, <TokenType.UPDATE: 'UPDATE'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.UINT256: 'UINT256'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.ROWS: 'ROWS'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.IPV4: 'IPV4'>, <TokenType.DIV: 'DIV'>, <TokenType.KEEP: 'KEEP'>, <TokenType.DELETE: 'DELETE'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.WINDOW: 'WINDOW'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.XML: 'XML'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.TEXT: 'TEXT'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.COMMENT: 'COMMENT'>, <TokenType.SET: 'SET'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.CHAR: 'CHAR'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.ROLLUP: 'ROLLUP'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, <TokenType.ESCAPE: 'ESCAPE'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.DETACH: 'DETACH'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.UINT128: 'UINT128'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.TRUE: 'TRUE'>, <TokenType.DATETIME2: 'DATETIME2'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.NESTED: 'NESTED'>, <TokenType.VAR: 'VAR'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.FILTER: 'FILTER'>, <TokenType.USE: 'USE'>, <TokenType.MONEY: 'MONEY'>, <TokenType.TIME: 'TIME'>, <TokenType.DECIMAL128: 'DECIMAL128'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.WAREHOUSE: 'WAREHOUSE'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.BLOB: 'BLOB'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.UUID: 'UUID'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.END: 'END'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.PUT: 'PUT'>, <TokenType.MODEL: 'MODEL'>, <TokenType.IPV6: 'IPV6'>, <TokenType.SEMANTIC_VIEW: 'SEMANTIC_VIEW'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.FULL: 'FULL'>, <TokenType.POLYGON: 'POLYGON'>, <TokenType.INT: 'INT'>, <TokenType.CACHE: 'CACHE'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.DECIMAL32: 'DECIMAL32'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.TAG: 'TAG'>, <TokenType.MULTIPOLYGON: 'MULTIPOLYGON'>, <TokenType.UDOUBLE: 'UDOUBLE'>, <TokenType.NAME: 'NAME'>, <TokenType.STREAMLIT: 'STREAMLIT'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.DATETIME: 'DATETIME'>}
SHOW_TRIE: Dict =
{'BINARY': {'LOGS': {0: True}}, 'MASTER': {'LOGS': {0: True}, 'STATUS': {0: True}}, 'BINLOG': {'EVENTS': {0: True}}, 'CHARACTER': {'SET': {0: True}}, 'CHARSET': {0: True}, 'COLLATION': {0: True}, 'FULL': {'COLUMNS': {0: True}, 'PROCESSLIST': {0: True}, 'TABLES': {0: True}}, 'COLUMNS': {0: True}, 'CREATE': {'DATABASE': {0: True}, 'EVENT': {0: True}, 'FUNCTION': {0: True}, 'PROCEDURE': {0: True}, 'TABLE': {0: True}, 'TRIGGER': {0: True}, 'VIEW': {0: True}}, 'DATABASES': {0: True}, 'SCHEMAS': {0: True}, 'ENGINE': {0: True}, 'STORAGE': {'ENGINES': {0: True}}, 'ENGINES': {0: True}, 'ERRORS': {0: True}, 'EVENTS': {0: True}, 'FUNCTION': {'CODE': {0: True}, 'STATUS': {0: True}}, 'GRANTS': {0: True}, 'INDEX': {0: True}, 'OPEN': {'TABLES': {0: True}}, 'PLUGINS': {0: True}, 'PROCEDURE': {'CODE': {0: True}, 'STATUS': {0: True}}, 'PRIVILEGES': {0: True}, 'PROCESSLIST': {0: True}, 'PROFILE': {0: True}, 'PROFILES': {0: True}, 'RELAYLOG': {'EVENTS': {0: True}}, 'REPLICAS': {0: True}, 'SLAVE': {'HOSTS': {0: True}, 'STATUS': {0: True}}, 'REPLICA': {'STATUS': {0: True}}, 'GLOBAL': {'STATUS': {0: True}, 'VARIABLES': {0: True}}, 'SESSION': {'STATUS': {0: True}, 'VARIABLES': {0: True}}, 'STATUS': {0: True}, 'TABLE': {'STATUS': {0: True}}, 'TABLES': {0: True}, 'TRIGGERS': {0: True}, 'VARIABLES': {0: True}, 'WARNINGS': {0: True}}
SET_TRIE: Dict =
{'GLOBAL': {0: True}, 'LOCAL': {0: True}, 'SESSION': {0: True}, 'TRANSACTION': {0: True}, 'PERSIST': {0: True}, 'PERSIST_ONLY': {0: True}, 'CHARACTER': {'SET': {0: True}}, 'CHARSET': {0: True}, 'NAMES': {0: True}}
Inherited Members
- sqlglot.parser.Parser
- Parser
- NO_PAREN_FUNCTIONS
- STRUCT_TYPE_TOKENS
- NESTED_TYPE_TOKENS
- AGGREGATE_TYPE_TOKENS
- SIGNED_TO_UNSIGNED_TYPE_TOKEN
- SUBQUERY_PREDICATES
- RESERVED_TOKENS
- DB_CREATABLES
- CREATABLES
- ALTERABLES
- ALIAS_TOKENS
- COLON_PLACEHOLDER_TOKENS
- ARRAY_CONSTRUCTORS
- COMMENT_TABLE_ALIAS_TOKENS
- UPDATE_ALIAS_TOKENS
- TRIM_TYPES
- ASSIGNMENT
- EQUALITY
- COMPARISON
- BITWISE
- TERM
- FACTOR
- EXPONENT
- TIMES
- TIMESTAMPS
- SET_OPERATIONS
- JOIN_METHODS
- JOIN_SIDES
- JOIN_KINDS
- JOIN_HINTS
- LAMBDAS
- EXPRESSION_PARSERS
- UNARY_PARSERS
- STRING_PARSERS
- NUMERIC_PARSERS
- PRIMARY_PARSERS
- PLACEHOLDER_PARSERS
- PIPE_SYNTAX_TRANSFORM_PARSERS
- NO_PAREN_FUNCTION_PARSERS
- INVALID_FUNC_NAME_TOKENS
- FUNCTIONS_WITH_ALIASED_ARGS
- KEY_VALUE_DEFINITIONS
- QUERY_MODIFIER_PARSERS
- QUERY_MODIFIER_TOKENS
- TYPE_LITERAL_PARSERS
- TYPE_CONVERTERS
- DDL_SELECT_TOKENS
- PRE_VOLATILE_TOKENS
- TRANSACTION_KIND
- TRANSACTION_CHARACTERISTICS
- CONFLICT_ACTIONS
- CREATE_SEQUENCE
- ISOLATED_LOADING_OPTIONS
- USABLES
- CAST_ACTIONS
- SCHEMA_BINDING_OPTIONS
- PROCEDURE_OPTIONS
- EXECUTE_AS_OPTIONS
- KEY_CONSTRAINT_OPTIONS
- WINDOW_EXCLUDE_OPTIONS
- INSERT_ALTERNATIVES
- CLONE_KEYWORDS
- HISTORICAL_DATA_PREFIX
- HISTORICAL_DATA_KIND
- OPCLASS_FOLLOW_KEYWORDS
- OPTYPE_FOLLOW_TOKENS
- TABLE_INDEX_HINT_TOKENS
- VIEW_ATTRIBUTES
- WINDOW_ALIAS_TOKENS
- WINDOW_BEFORE_PAREN_TOKENS
- WINDOW_SIDES
- JSON_KEY_VALUE_SEPARATOR_TOKENS
- FETCH_TOKENS
- ADD_CONSTRAINT_TOKENS
- DISTINCT_TOKENS
- NULL_TOKENS
- UNNEST_OFFSET_ALIAS_TOKENS
- SELECT_START_TOKENS
- COPY_INTO_VARLEN_OPTIONS
- IS_JSON_PREDICATE_KIND
- ODBC_DATETIME_LITERALS
- ON_CONDITION_TOKENS
- PRIVILEGE_FOLLOW_TOKENS
- DESCRIBE_STYLES
- ANALYZE_STYLES
- ANALYZE_EXPRESSION_PARSERS
- PARTITION_KEYWORDS
- AMBIGUOUS_ALIAS_TOKENS
- RECURSIVE_CTE_SEARCH_KIND
- MODIFIABLES
- STRICT_CAST
- PREFIXED_PIVOT_COLUMNS
- IDENTIFY_PIVOT_STRINGS
- TABLESAMPLE_CSV
- DEFAULT_SAMPLING_METHOD
- SET_REQUIRES_ASSIGNMENT_DELIMITER
- TRIM_PATTERN_FIRST
- MODIFIERS_ATTACHED_TO_SET_OP
- SET_OP_MODIFIERS
- NO_PAREN_IF_COMMANDS
- JSON_ARROWS_REQUIRE_JSON_TYPE
- COLON_IS_VARIANT_EXTRACT
- SUPPORTS_IMPLICIT_UNNEST
- INTERVAL_SPANS
- WRAPPED_TRANSFORM_COLUMN_CONSTRAINT
- OPTIONAL_ALIAS_TOKEN_CTE
- ALTER_RENAME_REQUIRES_COLUMN
- JOINS_HAVE_EQUAL_PRECEDENCE
- ZONE_AWARE_TIMESTAMP_CONSTRUCTOR
- MAP_KEYS_ARE_ARBITRARY_EXPRESSIONS
- JSON_EXTRACT_REQUIRES_JSON_EXPRESSION
- error_level
- error_message_context
- max_errors
- dialect
- reset
- parse
- parse_into
- check_errors
- raise_error
- expression
- validate_expression
- parse_set_operation
- build_cast
- errors
- sql
- sqlglot.dialects.mysql.MySQL.Parser
- FUNC_TOKENS
- CONJUNCTION
- DISJUNCTION
- RANGE_PARSERS
- FUNCTION_PARSERS
- STATEMENT_PARSERS
- SHOW_PARSERS
- PROPERTY_PARSERS
- SET_PARSERS
- CONSTRAINT_PARSERS
- ALTER_PARSERS
- ALTER_ALTER_PARSERS
- SCHEMA_UNNAMED_CONSTRAINTS
- PROFILE_TYPES
- TYPE_TOKENS
- ENUM_TYPE_TOKENS
- OPERATION_MODIFIERS
- LOG_DEFAULTS_TO_LN
- STRING_ALIASES
- VALUES_FOLLOWED_BY_PAREN
- SUPPORTS_PARTITION_SELECTION
229 class Generator(MySQL.Generator): 230 SUPPORTED_JSON_PATH_PARTS = { 231 exp.JSONPathKey, 232 exp.JSONPathRoot, 233 exp.JSONPathSubscript, 234 } 235 236 TRANSFORMS = { 237 **MySQL.Generator.TRANSFORMS, 238 exp.TsOrDsToDate: lambda self, e: self.func("TO_DATE", e.this, self.format_time(e)) 239 if e.args.get("format") 240 else self.func("DATE", e.this), 241 exp.StrToTime: lambda self, e: self.func("TO_TIMESTAMP", e.this, self.format_time(e)), 242 exp.ToChar: lambda self, e: self.func("TO_CHAR", e.this, self.format_time(e)), 243 exp.StrToDate: lambda self, e: self.func( 244 "STR_TO_DATE", 245 e.this, 246 self.format_time( 247 e, 248 inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING, 249 inverse_time_trie=MySQL.INVERSE_TIME_TRIE, 250 ), 251 ), 252 exp.TimeToStr: lambda self, e: self.func( 253 "DATE_FORMAT", 254 e.this, 255 self.format_time( 256 e, 257 inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING, 258 inverse_time_trie=MySQL.INVERSE_TIME_TRIE, 259 ), 260 ), 261 exp.Date: unsupported_args("zone", "expressions")(rename_func("DATE")), 262 exp.Cast: unsupported_args("format", "action", "default")( 263 lambda self, e: f"{self.sql(e, 'this')} :> {self.sql(e, 'to')}" 264 ), 265 exp.TryCast: unsupported_args("format", "action", "default")( 266 lambda self, e: f"{self.sql(e, 'this')} !:> {self.sql(e, 'to')}" 267 ), 268 exp.StrToUnix: unsupported_args("format")(rename_func("UNIX_TIMESTAMP")), 269 exp.TimeToUnix: rename_func("UNIX_TIMESTAMP"), 270 exp.TimeStrToUnix: rename_func("UNIX_TIMESTAMP"), 271 exp.UnixSeconds: rename_func("UNIX_TIMESTAMP"), 272 exp.UnixToStr: lambda self, e: self.func( 273 "FROM_UNIXTIME", 274 e.this, 275 self.format_time( 276 e, 277 inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING, 278 inverse_time_trie=MySQL.INVERSE_TIME_TRIE, 279 ), 280 ), 281 exp.UnixToTime: unsupported_args("scale", "zone", "hours", "minutes")( 282 lambda self, e: self.func( 283 "FROM_UNIXTIME", 284 e.this, 285 self.format_time( 286 e, 287 inverse_time_mapping=MySQL.INVERSE_TIME_MAPPING, 288 inverse_time_trie=MySQL.INVERSE_TIME_TRIE, 289 ), 290 ), 291 ), 292 exp.UnixToTimeStr: lambda self, e: f"FROM_UNIXTIME({self.sql(e, 'this')}) :> TEXT", 293 exp.DateBin: unsupported_args("unit", "zone")( 294 lambda self, e: self.func("TIME_BUCKET", e.this, e.expression, e.args.get("origin")) 295 ), 296 exp.TimeStrToDate: lambda self, e: self.sql(exp.cast(e.this, exp.DataType.Type.DATE)), 297 exp.FromTimeZone: lambda self, e: self.func( 298 "CONVERT_TZ", e.this, e.args.get("zone"), "'UTC'" 299 ), 300 exp.DiToDate: lambda self, 301 e: f"STR_TO_DATE({self.sql(e, 'this')}, {SingleStore.DATEINT_FORMAT})", 302 exp.DateToDi: lambda self, 303 e: f"(DATE_FORMAT({self.sql(e, 'this')}, {SingleStore.DATEINT_FORMAT}) :> INT)", 304 exp.TsOrDiToDi: lambda self, 305 e: f"(DATE_FORMAT({self.sql(e, 'this')}, {SingleStore.DATEINT_FORMAT}) :> INT)", 306 exp.Time: unsupported_args("zone")(lambda self, e: f"{self.sql(e, 'this')} :> TIME"), 307 exp.DatetimeAdd: _remove_ts_or_ds_to_date(date_add_sql("ADD")), 308 exp.DatetimeTrunc: unsupported_args("zone")(timestamptrunc_sql()), 309 exp.DatetimeSub: date_add_interval_sql("DATE", "SUB"), 310 exp.DatetimeDiff: timestampdiff_sql, 311 exp.DateTrunc: unsupported_args("zone")(timestamptrunc_sql()), 312 exp.DateDiff: unsupported_args("zone")( 313 lambda self, e: timestampdiff_sql(self, e) 314 if e.unit is not None 315 else self.func("DATEDIFF", e.this, e.expression) 316 ), 317 exp.TimestampTrunc: unsupported_args("zone")(timestamptrunc_sql()), 318 exp.JSONExtract: unsupported_args( 319 "only_json_types", 320 "expressions", 321 "variant_extract", 322 "json_query", 323 "option", 324 "quote", 325 "on_condition", 326 "requires_json", 327 )(json_extract_segments("JSON_EXTRACT_JSON")), 328 exp.JSONBExtract: json_extract_segments("BSON_EXTRACT_BSON"), 329 exp.JSONPathKey: json_path_key_only_name, 330 exp.JSONPathSubscript: lambda self, e: self.json_path_part(e.this), 331 exp.JSONPathRoot: lambda *_: "", 332 exp.JSONFormat: unsupported_args("options", "is_json")(rename_func("JSON_PRETTY")), 333 exp.DayOfWeekIso: lambda self, e: f"(({self.func('DAYOFWEEK', e.this)} % 7) + 1)", 334 exp.DayOfMonth: rename_func("DAY"), 335 exp.Hll: rename_func("APPROX_COUNT_DISTINCT"), 336 exp.ApproxDistinct: rename_func("APPROX_COUNT_DISTINCT"), 337 exp.CountIf: count_if_to_sum, 338 exp.LogicalOr: lambda self, e: f"MAX(ABS({self.sql(e, 'this')}))", 339 exp.LogicalAnd: lambda self, e: f"MIN(ABS({self.sql(e, 'this')}))", 340 exp.ApproxQuantile: unsupported_args("accuracy", "weight")( 341 lambda self, e: self.func( 342 "APPROX_PERCENTILE", 343 e.this, 344 e.args.get("quantile"), 345 e.args.get("error_tolerance"), 346 ) 347 ), 348 exp.Variance: rename_func("VAR_SAMP"), 349 exp.VariancePop: rename_func("VAR_POP"), 350 exp.Xor: bool_xor_sql, 351 exp.RegexpLike: lambda self, e: self.binary(e, "RLIKE"), 352 exp.Repeat: lambda self, e: self.func( 353 "LPAD", 354 exp.Literal.string(""), 355 exp.Mul(this=self.func("LENGTH", e.this), expression=e.args.get("times")), 356 e.this, 357 ), 358 exp.IsAscii: lambda self, e: f"({self.sql(e, 'this')} RLIKE '^[\x00-\x7f]*$')", 359 exp.MD5Digest: lambda self, e: self.func("UNHEX", self.func("MD5", e.this)), 360 exp.Chr: rename_func("CHAR"), 361 exp.Contains: rename_func("INSTR"), 362 exp.RegexpExtractAll: unsupported_args("position", "occurrence", "group")( 363 lambda self, e: self.func( 364 "REGEXP_MATCH", 365 e.this, 366 e.expression, 367 e.args.get("parameters"), 368 ) 369 ), 370 exp.RegexpExtract: unsupported_args("group")( 371 lambda self, e: self.func( 372 "REGEXP_SUBSTR", 373 e.this, 374 e.expression, 375 e.args.get("position"), 376 e.args.get("occurrence"), 377 e.args.get("parameters"), 378 ) 379 ), 380 exp.StartsWith: lambda self, e: self.func( 381 "REGEXP_INSTR", e.this, self.func("CONCAT", exp.Literal.string("^"), e.expression) 382 ), 383 exp.FromBase: lambda self, e: self.func( 384 "CONV", e.this, e.expression, exp.Literal.number(10) 385 ), 386 exp.Reduce: unsupported_args("finish")( 387 lambda self, e: self.func( 388 "REDUCE", e.args.get("initial"), e.this, e.args.get("merge") 389 ) 390 ), 391 } 392 TRANSFORMS.pop(exp.JSONExtractScalar) 393 394 UNSUPPORTED_TYPES = { 395 exp.DataType.Type.ARRAY, 396 exp.DataType.Type.AGGREGATEFUNCTION, 397 exp.DataType.Type.SIMPLEAGGREGATEFUNCTION, 398 exp.DataType.Type.BIGSERIAL, 399 exp.DataType.Type.BPCHAR, 400 exp.DataType.Type.DATEMULTIRANGE, 401 exp.DataType.Type.DATERANGE, 402 exp.DataType.Type.DYNAMIC, 403 exp.DataType.Type.HLLSKETCH, 404 exp.DataType.Type.HSTORE, 405 exp.DataType.Type.IMAGE, 406 exp.DataType.Type.INET, 407 exp.DataType.Type.INT128, 408 exp.DataType.Type.INT256, 409 exp.DataType.Type.INT4MULTIRANGE, 410 exp.DataType.Type.INT4RANGE, 411 exp.DataType.Type.INT8MULTIRANGE, 412 exp.DataType.Type.INT8RANGE, 413 exp.DataType.Type.INTERVAL, 414 exp.DataType.Type.IPADDRESS, 415 exp.DataType.Type.IPPREFIX, 416 exp.DataType.Type.IPV4, 417 exp.DataType.Type.IPV6, 418 exp.DataType.Type.LIST, 419 exp.DataType.Type.MAP, 420 exp.DataType.Type.LOWCARDINALITY, 421 exp.DataType.Type.MONEY, 422 exp.DataType.Type.MULTILINESTRING, 423 exp.DataType.Type.NAME, 424 exp.DataType.Type.NESTED, 425 exp.DataType.Type.NOTHING, 426 exp.DataType.Type.NULL, 427 exp.DataType.Type.NUMMULTIRANGE, 428 exp.DataType.Type.NUMRANGE, 429 exp.DataType.Type.OBJECT, 430 exp.DataType.Type.RANGE, 431 exp.DataType.Type.ROWVERSION, 432 exp.DataType.Type.SERIAL, 433 exp.DataType.Type.SMALLSERIAL, 434 exp.DataType.Type.SMALLMONEY, 435 exp.DataType.Type.STRUCT, 436 exp.DataType.Type.SUPER, 437 exp.DataType.Type.TIMETZ, 438 exp.DataType.Type.TIMESTAMPNTZ, 439 exp.DataType.Type.TIMESTAMPLTZ, 440 exp.DataType.Type.TIMESTAMPTZ, 441 exp.DataType.Type.TIMESTAMP_NS, 442 exp.DataType.Type.TSMULTIRANGE, 443 exp.DataType.Type.TSRANGE, 444 exp.DataType.Type.TSTZMULTIRANGE, 445 exp.DataType.Type.TSTZRANGE, 446 exp.DataType.Type.UINT128, 447 exp.DataType.Type.UINT256, 448 exp.DataType.Type.UNION, 449 exp.DataType.Type.UNKNOWN, 450 exp.DataType.Type.USERDEFINED, 451 exp.DataType.Type.UUID, 452 exp.DataType.Type.VARIANT, 453 exp.DataType.Type.XML, 454 exp.DataType.Type.TDIGEST, 455 } 456 457 TYPE_MAPPING = { 458 **MySQL.Generator.TYPE_MAPPING, 459 exp.DataType.Type.BIGDECIMAL: "DECIMAL", 460 exp.DataType.Type.BIT: "BOOLEAN", 461 exp.DataType.Type.DATE32: "DATE", 462 exp.DataType.Type.DATETIME64: "DATETIME", 463 exp.DataType.Type.DECIMAL32: "DECIMAL", 464 exp.DataType.Type.DECIMAL64: "DECIMAL", 465 exp.DataType.Type.DECIMAL128: "DECIMAL", 466 exp.DataType.Type.DECIMAL256: "DECIMAL", 467 exp.DataType.Type.ENUM8: "ENUM", 468 exp.DataType.Type.ENUM16: "ENUM", 469 exp.DataType.Type.FIXEDSTRING: "TEXT", 470 exp.DataType.Type.GEOMETRY: "GEOGRAPHY", 471 exp.DataType.Type.POINT: "GEOGRAPHYPOINT", 472 exp.DataType.Type.RING: "GEOGRAPHY", 473 exp.DataType.Type.LINESTRING: "GEOGRAPHY", 474 exp.DataType.Type.POLYGON: "GEOGRAPHY", 475 exp.DataType.Type.MULTIPOLYGON: "GEOGRAPHY", 476 exp.DataType.Type.JSONB: "BSON", 477 exp.DataType.Type.TIMESTAMP: "TIMESTAMP", 478 exp.DataType.Type.TIMESTAMP_S: "TIMESTAMP", 479 exp.DataType.Type.TIMESTAMP_MS: "TIMESTAMP(6)", 480 } 481 482 # https://docs.singlestore.com/cloud/reference/sql-reference/restricted-keywords/list-of-restricted-keywords/ 483 RESERVED_KEYWORDS = { 484 "abs", 485 "absolute", 486 "access", 487 "account", 488 "acos", 489 "action", 490 "add", 491 "adddate", 492 "addtime", 493 "admin", 494 "aes_decrypt", 495 "aes_encrypt", 496 "after", 497 "against", 498 "aggregate", 499 "aggregates", 500 "aggregator", 501 "aggregator_id", 502 "aggregator_plan_hash", 503 "aggregators", 504 "algorithm", 505 "all", 506 "also", 507 "alter", 508 "always", 509 "analyse", 510 "analyze", 511 "and", 512 "anti_join", 513 "any", 514 "any_value", 515 "approx_count_distinct", 516 "approx_count_distinct_accumulate", 517 "approx_count_distinct_combine", 518 "approx_count_distinct_estimate", 519 "approx_geography_intersects", 520 "approx_percentile", 521 "arghistory", 522 "arrange", 523 "arrangement", 524 "array", 525 "as", 526 "asc", 527 "ascii", 528 "asensitive", 529 "asin", 530 "asm", 531 "assertion", 532 "assignment", 533 "ast", 534 "asymmetric", 535 "async", 536 "at", 537 "atan", 538 "atan2", 539 "attach", 540 "attribute", 541 "authorization", 542 "auto", 543 "auto_increment", 544 "auto_reprovision", 545 "autostats", 546 "autostats_cardinality_mode", 547 "autostats_enabled", 548 "autostats_histogram_mode", 549 "autostats_sampling", 550 "availability", 551 "avg", 552 "avg_row_length", 553 "avro", 554 "azure", 555 "background", 556 "_background_threads_for_cleanup", 557 "backup", 558 "backup_history", 559 "backup_id", 560 "backward", 561 "batch", 562 "batches", 563 "batch_interval", 564 "_batch_size_limit", 565 "before", 566 "begin", 567 "between", 568 "bigint", 569 "bin", 570 "binary", 571 "_binary", 572 "bit", 573 "bit_and", 574 "bit_count", 575 "bit_or", 576 "bit_xor", 577 "blob", 578 "bool", 579 "boolean", 580 "bootstrap", 581 "both", 582 "_bt", 583 "btree", 584 "bucket_count", 585 "by", 586 "byte", 587 "byte_length", 588 "cache", 589 "call", 590 "call_for_pipeline", 591 "called", 592 "capture", 593 "cascade", 594 "cascaded", 595 "case", 596 "cast", 597 "catalog", 598 "ceil", 599 "ceiling", 600 "chain", 601 "change", 602 "char", 603 "character", 604 "characteristics", 605 "character_length", 606 "char_length", 607 "charset", 608 "check", 609 "checkpoint", 610 "_check_can_connect", 611 "_check_consistency", 612 "checksum", 613 "_checksum", 614 "class", 615 "clear", 616 "client", 617 "client_found_rows", 618 "close", 619 "cluster", 620 "clustered", 621 "cnf", 622 "coalesce", 623 "coercibility", 624 "collate", 625 "collation", 626 "collect", 627 "column", 628 "columnar", 629 "columns", 630 "columnstore", 631 "columnstore_segment_rows", 632 "comment", 633 "comments", 634 "commit", 635 "committed", 636 "_commit_log_tail", 637 "committed", 638 "compact", 639 "compile", 640 "compressed", 641 "compression", 642 "concat", 643 "concat_ws", 644 "concurrent", 645 "concurrently", 646 "condition", 647 "configuration", 648 "connection", 649 "connection_id", 650 "connections", 651 "config", 652 "constraint", 653 "constraints", 654 "content", 655 "continue", 656 "_continue_replay", 657 "conv", 658 "conversion", 659 "convert", 660 "convert_tz", 661 "copy", 662 "_core", 663 "cos", 664 "cost", 665 "cot", 666 "count", 667 "create", 668 "credentials", 669 "cross", 670 "cube", 671 "csv", 672 "cume_dist", 673 "curdate", 674 "current", 675 "current_catalog", 676 "current_date", 677 "current_role", 678 "current_schema", 679 "current_security_groups", 680 "current_security_roles", 681 "current_time", 682 "current_timestamp", 683 "current_user", 684 "cursor", 685 "curtime", 686 "cycle", 687 "data", 688 "database", 689 "databases", 690 "date", 691 "date_add", 692 "datediff", 693 "date_format", 694 "date_sub", 695 "date_trunc", 696 "datetime", 697 "day", 698 "day_hour", 699 "day_microsecond", 700 "day_minute", 701 "dayname", 702 "dayofmonth", 703 "dayofweek", 704 "dayofyear", 705 "day_second", 706 "deallocate", 707 "dec", 708 "decimal", 709 "declare", 710 "decode", 711 "default", 712 "defaults", 713 "deferrable", 714 "deferred", 715 "defined", 716 "definer", 717 "degrees", 718 "delayed", 719 "delay_key_write", 720 "delete", 721 "delimiter", 722 "delimiters", 723 "dense_rank", 724 "desc", 725 "describe", 726 "detach", 727 "deterministic", 728 "dictionary", 729 "differential", 730 "directory", 731 "disable", 732 "discard", 733 "_disconnect", 734 "disk", 735 "distinct", 736 "distinctrow", 737 "distributed_joins", 738 "div", 739 "do", 740 "document", 741 "domain", 742 "dot_product", 743 "double", 744 "drop", 745 "_drop_profile", 746 "dual", 747 "dump", 748 "duplicate", 749 "dynamic", 750 "earliest", 751 "each", 752 "echo", 753 "election", 754 "else", 755 "elseif", 756 "elt", 757 "enable", 758 "enclosed", 759 "encoding", 760 "encrypted", 761 "end", 762 "engine", 763 "engines", 764 "enum", 765 "errors", 766 "escape", 767 "escaped", 768 "estimate", 769 "euclidean_distance", 770 "event", 771 "events", 772 "except", 773 "exclude", 774 "excluding", 775 "exclusive", 776 "execute", 777 "exists", 778 "exit", 779 "exp", 780 "explain", 781 "extended", 782 "extension", 783 "external", 784 "external_host", 785 "external_port", 786 "extract", 787 "extractor", 788 "extractors", 789 "extra_join", 790 "_failover", 791 "failed_login_attempts", 792 "failure", 793 "false", 794 "family", 795 "fault", 796 "fetch", 797 "field", 798 "fields", 799 "file", 800 "files", 801 "fill", 802 "first", 803 "first_value", 804 "fix_alter", 805 "fixed", 806 "float", 807 "float4", 808 "float8", 809 "floor", 810 "flush", 811 "following", 812 "for", 813 "force", 814 "force_compiled_mode", 815 "force_interpreter_mode", 816 "foreground", 817 "foreign", 818 "format", 819 "forward", 820 "found_rows", 821 "freeze", 822 "from", 823 "from_base64", 824 "from_days", 825 "from_unixtime", 826 "fs", 827 "_fsync", 828 "full", 829 "fulltext", 830 "function", 831 "functions", 832 "gc", 833 "gcs", 834 "get_format", 835 "_gc", 836 "_gcx", 837 "generate", 838 "geography", 839 "geography_area", 840 "geography_contains", 841 "geography_distance", 842 "geography_intersects", 843 "geography_latitude", 844 "geography_length", 845 "geography_longitude", 846 "geographypoint", 847 "geography_point", 848 "geography_within_distance", 849 "geometry", 850 "geometry_area", 851 "geometry_contains", 852 "geometry_distance", 853 "geometry_filter", 854 "geometry_intersects", 855 "geometry_length", 856 "geometrypoint", 857 "geometry_point", 858 "geometry_within_distance", 859 "geometry_x", 860 "geometry_y", 861 "global", 862 "_global_version_timestamp", 863 "grant", 864 "granted", 865 "grants", 866 "greatest", 867 "group", 868 "grouping", 869 "groups", 870 "group_concat", 871 "gzip", 872 "handle", 873 "handler", 874 "hard_cpu_limit_percentage", 875 "hash", 876 "has_temp_tables", 877 "having", 878 "hdfs", 879 "header", 880 "heartbeat_no_logging", 881 "hex", 882 "highlight", 883 "high_priority", 884 "hold", 885 "holding", 886 "host", 887 "hosts", 888 "hour", 889 "hour_microsecond", 890 "hour_minute", 891 "hour_second", 892 "identified", 893 "identity", 894 "if", 895 "ifnull", 896 "ignore", 897 "ilike", 898 "immediate", 899 "immutable", 900 "implicit", 901 "import", 902 "in", 903 "including", 904 "increment", 905 "incremental", 906 "index", 907 "indexes", 908 "inet_aton", 909 "inet_ntoa", 910 "inet6_aton", 911 "inet6_ntoa", 912 "infile", 913 "inherit", 914 "inherits", 915 "_init_profile", 916 "init", 917 "initcap", 918 "initialize", 919 "initially", 920 "inject", 921 "inline", 922 "inner", 923 "inout", 924 "input", 925 "insensitive", 926 "insert", 927 "insert_method", 928 "instance", 929 "instead", 930 "instr", 931 "int", 932 "int1", 933 "int2", 934 "int3", 935 "int4", 936 "int8", 937 "integer", 938 "_internal_dynamic_typecast", 939 "interpreter_mode", 940 "intersect", 941 "interval", 942 "into", 943 "invoker", 944 "is", 945 "isnull", 946 "isolation", 947 "iterate", 948 "join", 949 "json", 950 "json_agg", 951 "json_array_contains_double", 952 "json_array_contains_json", 953 "json_array_contains_string", 954 "json_array_push_double", 955 "json_array_push_json", 956 "json_array_push_string", 957 "json_delete_key", 958 "json_extract_double", 959 "json_extract_json", 960 "json_extract_string", 961 "json_extract_bigint", 962 "json_get_type", 963 "json_length", 964 "json_set_double", 965 "json_set_json", 966 "json_set_string", 967 "json_splice_double", 968 "json_splice_json", 969 "json_splice_string", 970 "kafka", 971 "key", 972 "key_block_size", 973 "keys", 974 "kill", 975 "killall", 976 "label", 977 "lag", 978 "language", 979 "large", 980 "last", 981 "last_day", 982 "last_insert_id", 983 "last_value", 984 "lateral", 985 "latest", 986 "lc_collate", 987 "lc_ctype", 988 "lcase", 989 "lead", 990 "leading", 991 "leaf", 992 "leakproof", 993 "least", 994 "leave", 995 "leaves", 996 "left", 997 "length", 998 "level", 999 "license", 1000 "like", 1001 "limit", 1002 "lines", 1003 "listen", 1004 "llvm", 1005 "ln", 1006 "load", 1007 "loaddata_where", 1008 "_load", 1009 "local", 1010 "localtime", 1011 "localtimestamp", 1012 "locate", 1013 "location", 1014 "lock", 1015 "log", 1016 "log10", 1017 "log2", 1018 "long", 1019 "longblob", 1020 "longtext", 1021 "loop", 1022 "lower", 1023 "low_priority", 1024 "lpad", 1025 "_ls", 1026 "ltrim", 1027 "lz4", 1028 "management", 1029 "_management_thread", 1030 "mapping", 1031 "master", 1032 "match", 1033 "materialized", 1034 "max", 1035 "maxvalue", 1036 "max_concurrency", 1037 "max_errors", 1038 "max_partitions_per_batch", 1039 "max_queue_depth", 1040 "max_retries_per_batch_partition", 1041 "max_rows", 1042 "mbc", 1043 "md5", 1044 "mpl", 1045 "median", 1046 "mediumblob", 1047 "mediumint", 1048 "mediumtext", 1049 "member", 1050 "memory", 1051 "memory_percentage", 1052 "_memsql_table_id_lookup", 1053 "memsql", 1054 "memsql_deserialize", 1055 "memsql_imitating_kafka", 1056 "memsql_serialize", 1057 "merge", 1058 "metadata", 1059 "microsecond", 1060 "middleint", 1061 "min", 1062 "min_rows", 1063 "minus", 1064 "minute", 1065 "minute_microsecond", 1066 "minute_second", 1067 "minvalue", 1068 "mod", 1069 "mode", 1070 "model", 1071 "modifies", 1072 "modify", 1073 "month", 1074 "monthname", 1075 "months_between", 1076 "move", 1077 "mpl", 1078 "names", 1079 "named", 1080 "namespace", 1081 "national", 1082 "natural", 1083 "nchar", 1084 "next", 1085 "no", 1086 "node", 1087 "none", 1088 "no_query_rewrite", 1089 "noparam", 1090 "not", 1091 "nothing", 1092 "notify", 1093 "now", 1094 "nowait", 1095 "no_write_to_binlog", 1096 "no_query_rewrite", 1097 "norely", 1098 "nth_value", 1099 "ntile", 1100 "null", 1101 "nullcols", 1102 "nullif", 1103 "nulls", 1104 "numeric", 1105 "nvarchar", 1106 "object", 1107 "octet_length", 1108 "of", 1109 "off", 1110 "offline", 1111 "offset", 1112 "offsets", 1113 "oids", 1114 "on", 1115 "online", 1116 "only", 1117 "open", 1118 "operator", 1119 "optimization", 1120 "optimize", 1121 "optimizer", 1122 "optimizer_state", 1123 "option", 1124 "options", 1125 "optionally", 1126 "or", 1127 "order", 1128 "ordered_serialize", 1129 "orphan", 1130 "out", 1131 "out_of_order", 1132 "outer", 1133 "outfile", 1134 "over", 1135 "overlaps", 1136 "overlay", 1137 "owned", 1138 "owner", 1139 "pack_keys", 1140 "paired", 1141 "parser", 1142 "parquet", 1143 "partial", 1144 "partition", 1145 "partition_id", 1146 "partitioning", 1147 "partitions", 1148 "passing", 1149 "password", 1150 "password_lock_time", 1151 "parser", 1152 "pause", 1153 "_pause_replay", 1154 "percent_rank", 1155 "percentile_cont", 1156 "percentile_disc", 1157 "periodic", 1158 "persisted", 1159 "pi", 1160 "pipeline", 1161 "pipelines", 1162 "pivot", 1163 "placing", 1164 "plan", 1165 "plans", 1166 "plancache", 1167 "plugins", 1168 "pool", 1169 "pools", 1170 "port", 1171 "position", 1172 "pow", 1173 "power", 1174 "preceding", 1175 "precision", 1176 "prepare", 1177 "prepared", 1178 "preserve", 1179 "primary", 1180 "prior", 1181 "privileges", 1182 "procedural", 1183 "procedure", 1184 "procedures", 1185 "process", 1186 "processlist", 1187 "profile", 1188 "profiles", 1189 "program", 1190 "promote", 1191 "proxy", 1192 "purge", 1193 "quarter", 1194 "queries", 1195 "query", 1196 "query_timeout", 1197 "queue", 1198 "quote", 1199 "radians", 1200 "rand", 1201 "range", 1202 "rank", 1203 "read", 1204 "_read", 1205 "reads", 1206 "real", 1207 "reassign", 1208 "rebalance", 1209 "recheck", 1210 "record", 1211 "recursive", 1212 "redundancy", 1213 "redundant", 1214 "ref", 1215 "reference", 1216 "references", 1217 "refresh", 1218 "regexp", 1219 "reindex", 1220 "relative", 1221 "release", 1222 "reload", 1223 "rely", 1224 "remote", 1225 "remove", 1226 "rename", 1227 "repair", 1228 "_repair_table", 1229 "repeat", 1230 "repeatable", 1231 "_repl", 1232 "_reprovisioning", 1233 "replace", 1234 "replica", 1235 "replicate", 1236 "replicating", 1237 "replication", 1238 "durability", 1239 "require", 1240 "resource", 1241 "resource_pool", 1242 "reset", 1243 "restart", 1244 "restore", 1245 "restrict", 1246 "result", 1247 "_resurrect", 1248 "retry", 1249 "return", 1250 "returning", 1251 "returns", 1252 "reverse", 1253 "revoke", 1254 "rg_pool", 1255 "right", 1256 "right_anti_join", 1257 "right_semi_join", 1258 "right_straight_join", 1259 "rlike", 1260 "role", 1261 "roles", 1262 "rollback", 1263 "rollup", 1264 "round", 1265 "routine", 1266 "row", 1267 "row_count", 1268 "row_format", 1269 "row_number", 1270 "rows", 1271 "rowstore", 1272 "rule", 1273 "rpad", 1274 "_rpc", 1275 "rtrim", 1276 "running", 1277 "s3", 1278 "safe", 1279 "save", 1280 "savepoint", 1281 "scalar", 1282 "schema", 1283 "schemas", 1284 "schema_binding", 1285 "scroll", 1286 "search", 1287 "second", 1288 "second_microsecond", 1289 "sec_to_time", 1290 "security", 1291 "select", 1292 "semi_join", 1293 "_send_threads", 1294 "sensitive", 1295 "separator", 1296 "sequence", 1297 "sequences", 1298 "serial", 1299 "serializable", 1300 "series", 1301 "service_user", 1302 "server", 1303 "session", 1304 "session_user", 1305 "set", 1306 "setof", 1307 "security_lists_intersect", 1308 "sha", 1309 "sha1", 1310 "sha2", 1311 "shard", 1312 "sharded", 1313 "sharded_id", 1314 "share", 1315 "show", 1316 "shutdown", 1317 "sigmoid", 1318 "sign", 1319 "signal", 1320 "similar", 1321 "simple", 1322 "site", 1323 "signed", 1324 "sin", 1325 "skip", 1326 "skipped_batches", 1327 "sleep", 1328 "_sleep", 1329 "smallint", 1330 "snapshot", 1331 "_snapshot", 1332 "_snapshots", 1333 "soft_cpu_limit_percentage", 1334 "some", 1335 "soname", 1336 "sparse", 1337 "spatial", 1338 "spatial_check_index", 1339 "specific", 1340 "split", 1341 "sql", 1342 "sql_big_result", 1343 "sql_buffer_result", 1344 "sql_cache", 1345 "sql_calc_found_rows", 1346 "sqlexception", 1347 "sql_mode", 1348 "sql_no_cache", 1349 "sql_no_logging", 1350 "sql_small_result", 1351 "sqlstate", 1352 "sqlwarning", 1353 "sqrt", 1354 "ssl", 1355 "stable", 1356 "standalone", 1357 "start", 1358 "starting", 1359 "state", 1360 "statement", 1361 "statistics", 1362 "stats", 1363 "status", 1364 "std", 1365 "stddev", 1366 "stddev_pop", 1367 "stddev_samp", 1368 "stdin", 1369 "stdout", 1370 "stop", 1371 "storage", 1372 "str_to_date", 1373 "straight_join", 1374 "strict", 1375 "string", 1376 "strip", 1377 "subdate", 1378 "substr", 1379 "substring", 1380 "substring_index", 1381 "success", 1382 "sum", 1383 "super", 1384 "symmetric", 1385 "sync_snapshot", 1386 "sync", 1387 "_sync", 1388 "_sync2", 1389 "_sync_partitions", 1390 "_sync_snapshot", 1391 "synchronize", 1392 "sysid", 1393 "system", 1394 "table", 1395 "table_checksum", 1396 "tables", 1397 "tablespace", 1398 "tags", 1399 "tan", 1400 "target_size", 1401 "task", 1402 "temp", 1403 "template", 1404 "temporary", 1405 "temptable", 1406 "_term_bump", 1407 "terminate", 1408 "terminated", 1409 "test", 1410 "text", 1411 "then", 1412 "time", 1413 "timediff", 1414 "time_bucket", 1415 "time_format", 1416 "timeout", 1417 "timestamp", 1418 "timestampadd", 1419 "timestampdiff", 1420 "timezone", 1421 "time_to_sec", 1422 "tinyblob", 1423 "tinyint", 1424 "tinytext", 1425 "to", 1426 "to_base64", 1427 "to_char", 1428 "to_date", 1429 "to_days", 1430 "to_json", 1431 "to_number", 1432 "to_seconds", 1433 "to_timestamp", 1434 "tracelogs", 1435 "traditional", 1436 "trailing", 1437 "transform", 1438 "transaction", 1439 "_transactions_experimental", 1440 "treat", 1441 "trigger", 1442 "triggers", 1443 "trim", 1444 "true", 1445 "trunc", 1446 "truncate", 1447 "trusted", 1448 "two_phase", 1449 "_twopcid", 1450 "type", 1451 "types", 1452 "ucase", 1453 "unbounded", 1454 "uncommitted", 1455 "undefined", 1456 "undo", 1457 "unencrypted", 1458 "unenforced", 1459 "unhex", 1460 "unhold", 1461 "unicode", 1462 "union", 1463 "unique", 1464 "_unittest", 1465 "unix_timestamp", 1466 "unknown", 1467 "unlisten", 1468 "_unload", 1469 "unlock", 1470 "unlogged", 1471 "unpivot", 1472 "unsigned", 1473 "until", 1474 "update", 1475 "upgrade", 1476 "upper", 1477 "usage", 1478 "use", 1479 "user", 1480 "users", 1481 "using", 1482 "utc_date", 1483 "utc_time", 1484 "utc_timestamp", 1485 "_utf8", 1486 "vacuum", 1487 "valid", 1488 "validate", 1489 "validator", 1490 "value", 1491 "values", 1492 "varbinary", 1493 "varchar", 1494 "varcharacter", 1495 "variables", 1496 "variadic", 1497 "variance", 1498 "var_pop", 1499 "var_samp", 1500 "varying", 1501 "vector_sub", 1502 "verbose", 1503 "version", 1504 "view", 1505 "void", 1506 "volatile", 1507 "voting", 1508 "wait", 1509 "_wake", 1510 "warnings", 1511 "week", 1512 "weekday", 1513 "weekofyear", 1514 "when", 1515 "where", 1516 "while", 1517 "whitespace", 1518 "window", 1519 "with", 1520 "without", 1521 "within", 1522 "_wm_heartbeat", 1523 "work", 1524 "workload", 1525 "wrapper", 1526 "write", 1527 "xact_id", 1528 "xor", 1529 "year", 1530 "year_month", 1531 "yes", 1532 "zerofill", 1533 "zone", 1534 } 1535 1536 def jsonextractscalar_sql(self, expression: exp.JSONExtractScalar) -> str: 1537 json_type = expression.args.get("json_type") 1538 func_name = "JSON_EXTRACT_JSON" if json_type is None else f"JSON_EXTRACT_{json_type}" 1539 return json_extract_segments(func_name)(self, expression) 1540 1541 def jsonbextractscalar_sql(self, expression: exp.JSONBExtractScalar) -> str: 1542 json_type = expression.args.get("json_type") 1543 func_name = "BSON_EXTRACT_BSON" if json_type is None else f"BSON_EXTRACT_{json_type}" 1544 return json_extract_segments(func_name)(self, expression) 1545 1546 def jsonextractarray_sql(self, expression: exp.JSONExtractArray) -> str: 1547 self.unsupported("Arrays are not supported in SingleStore") 1548 return self.function_fallback_sql(expression) 1549 1550 @unsupported_args("on_condition") 1551 def jsonvalue_sql(self, expression: exp.JSONValue) -> str: 1552 res: exp.Expression = exp.JSONExtractScalar( 1553 this=expression.this, 1554 expression=expression.args.get("path"), 1555 json_type="STRING", 1556 ) 1557 1558 returning = expression.args.get("returning") 1559 if returning is not None: 1560 res = exp.Cast(this=res, to=returning) 1561 1562 return self.sql(res) 1563 1564 def all_sql(self, expression: exp.All) -> str: 1565 self.unsupported("ALL subquery predicate is not supported in SingleStore") 1566 return super().all_sql(expression) 1567 1568 def jsonarraycontains_sql(self, expression: exp.JSONArrayContains) -> str: 1569 json_type = expression.text("json_type").upper() 1570 1571 if json_type: 1572 return self.func( 1573 f"JSON_ARRAY_CONTAINS_{json_type}", expression.expression, expression.this 1574 ) 1575 1576 return self.func( 1577 "JSON_ARRAY_CONTAINS_JSON", 1578 expression.expression, 1579 self.func("TO_JSON", expression.this), 1580 ) 1581 1582 @unsupported_args("kind", "nested", "values") 1583 def datatype_sql(self, expression: exp.DataType) -> str: 1584 if expression.is_type(exp.DataType.Type.VARBINARY) and not expression.expressions: 1585 # `VARBINARY` must always have a size - if it doesn't, we always generate `BLOB` 1586 return "BLOB" 1587 if expression.is_type( 1588 exp.DataType.Type.DECIMAL32, 1589 exp.DataType.Type.DECIMAL64, 1590 exp.DataType.Type.DECIMAL128, 1591 exp.DataType.Type.DECIMAL256, 1592 ): 1593 scale = self.expressions(expression, flat=True) 1594 1595 if expression.is_type(exp.DataType.Type.DECIMAL32): 1596 precision = "9" 1597 elif expression.is_type(exp.DataType.Type.DECIMAL64): 1598 precision = "18" 1599 elif expression.is_type(exp.DataType.Type.DECIMAL128): 1600 precision = "38" 1601 else: 1602 # 65 is a maximum precision supported in SingleStore 1603 precision = "65" 1604 if scale is not None: 1605 return f"DECIMAL({precision}, {scale[0]})" 1606 else: 1607 return f"DECIMAL({precision})" 1608 1609 return super().datatype_sql(expression)
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
SUPPORTED_JSON_PATH_PARTS =
{<class 'sqlglot.expressions.JSONPathKey'>, <class 'sqlglot.expressions.JSONPathSubscript'>, <class 'sqlglot.expressions.JSONPathRoot'>}
TRANSFORMS =
{<class 'sqlglot.expressions.JSONPathKey'>: <function json_path_key_only_name>, <class 'sqlglot.expressions.JSONPathRoot'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.JSONPathSubscript'>: <function SingleStore.Generator.<lambda>>, <class 'sqlglot.expressions.AllowedValuesProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.AnalyzeColumns'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.AnalyzeWith'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ArrayContainsAll'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ArrayOverlaps'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.AutoRefreshProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.BackupProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CaseSpecificColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Ceil'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CharacterSetColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CharacterSetProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ClusteredColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CollateColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CommentColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ConnectByRoot'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ConvertToCharset'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CopyGrantsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.CredentialsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.DateFormatColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.DefaultColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.DynamicProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.EmptyProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.EncodeColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.EnviromentProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.EphemeralColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ExcludeColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ExecuteAsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Except'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ExternalProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Floor'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Get'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.GlobalProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.HeapProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.IcebergProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.InheritsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.InlineLengthColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.InputModelProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Intersect'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.IntervalSpan'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Int64'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.LanguageProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.LocationProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.LogProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.MaterializedProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.NonClusteredColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.NoPrimaryIndexProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.NotForReplicationColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.OnCommitProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.OnProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.OnUpdateColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Operator'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.OutputModelProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.PathColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.PartitionedByBucket'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.PartitionByTruncate'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.PivotAny'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.PositionalColumn'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ProjectionPolicyColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Put'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.RemoteWithConnectionModelProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ReturnsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SampleProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SecureProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SecurityProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SetConfigProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SetProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SettingsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SharingProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SqlReadWriteProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SqlSecurityProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.StabilityProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Stream'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.StreamingTableProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.StrictProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.SwapTable'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.TableColumn'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Tags'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.TemporaryProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.TitleColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ToMap'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ToTableProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.TransformModelProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.TransientProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Union'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.UnloggedProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.UsingTemplateProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.UsingData'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.Uuid'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.UppercaseColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.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.CurrentDate'>: <function no_paren_current_date_sql>, <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 rename_func.<locals>.<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 MySQL.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.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.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.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.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.Reduce'>: <function SingleStore.Generator.<lambda>>}
UNSUPPORTED_TYPES =
{<Type.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <Type.INT8RANGE: 'INT8RANGE'>, <Type.LIST: 'LIST'>, <Type.INT128: 'INT128'>, <Type.DYNAMIC: 'DYNAMIC'>, <Type.VARIANT: 'VARIANT'>, <Type.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <Type.NESTED: 'NESTED'>, <Type.INT256: 'INT256'>, <Type.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <Type.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <Type.RANGE: 'RANGE'>, <Type.UNION: 'UNION'>, <Type.UINT256: 'UINT256'>, <Type.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <Type.ARRAY: 'ARRAY'>, <Type.MONEY: 'MONEY'>, <Type.SERIAL: 'SERIAL'>, <Type.TSTZRANGE: 'TSTZRANGE'>, <Type.DATERANGE: 'DATERANGE'>, <Type.BIGSERIAL: 'BIGSERIAL'>, <Type.INT4RANGE: 'INT4RANGE'>, <Type.NUMRANGE: 'NUMRANGE'>, <Type.TSRANGE: 'TSRANGE'>, <Type.UNKNOWN: 'UNKNOWN'>, <Type.IPV4: 'IPV4'>, <Type.LOWCARDINALITY: 'LOWCARDINALITY'>, <Type.OBJECT: 'OBJECT'>, <Type.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <Type.NULL: 'NULL'>, <Type.SUPER: 'SUPER'>, <Type.TDIGEST: 'TDIGEST'>, <Type.SMALLMONEY: 'SMALLMONEY'>, <Type.UUID: 'UUID'>, <Type.HLLSKETCH: 'HLLSKETCH'>, <Type.STRUCT: 'STRUCT'>, <Type.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <Type.XML: 'XML'>, <Type.USERDEFINED: 'USER-DEFINED'>, <Type.IPV6: 'IPV6'>, <Type.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <Type.HSTORE: 'HSTORE'>, <Type.TIMETZ: 'TIMETZ'>, <Type.TSMULTIRANGE: 'TSMULTIRANGE'>, <Type.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <Type.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <Type.IPADDRESS: 'IPADDRESS'>, <Type.IMAGE: 'IMAGE'>, <Type.ROWVERSION: 'ROWVERSION'>, <Type.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <Type.MULTILINESTRING: 'MULTILINESTRING'>, <Type.SMALLSERIAL: 'SMALLSERIAL'>, <Type.NAME: 'NAME'>, <Type.MAP: 'MAP'>, <Type.INET: 'INET'>, <Type.INTERVAL: 'INTERVAL'>, <Type.NOTHING: 'NOTHING'>, <Type.BPCHAR: 'BPCHAR'>, <Type.UINT128: 'UINT128'>, <Type.IPPREFIX: 'IPPREFIX'>}
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 =
{'varcharacter', 'cascade', 'lead', 'sigmoid', 'traditional', 'refresh', 'killall', 'dayofmonth', 'second', 'granted', 'length', 'sql_mode', 'until', 'dump', 'external', 'row_format', 'schema', 'inline', 'approx_count_distinct_combine', 'storage', 'date', 'unencrypted', 'memsql_deserialize', '_read', 'sqrt', 'unique', 'tan', 'to_number', 'transaction', 'partition_id', 'concat_ws', 'terminate', 'checksum', 'float8', 'using', '_sync2', 'instance', 'geometry_area', 'pivot', 'highlight', 'prior', 'union', 'datetime', 'autostats', 'hold', 'file', 'pack_keys', 'real', 'spatial_check_index', 'symmetric', 'compact', 'cascaded', 'access', 'hour_microsecond', 'json_extract_string', '_failover', 'tinyblob', 'yes', 'mpl', 'after', 'move', 'server', '_core', 'update', 'failed_login_attempts', 'optimize', 'plans', 'share', 'tinytext', 'current_role', 'geometry_length', 'against', 'procedure', 'json_agg', 'in', 'nchar', 'hosts', 'super', 'license', 'auto_reprovision', 'if', 'geography_distance', 'statistics', 'substring', 'straight_join', 'encoding', 'bigint', 'class', 'ignore', 'json_array_contains_string', '_bt', 'to_json', 'owner', 'encrypted', 'repair', 'state', 'aggregates', 'undefined', 'specific', 'on', 'column', 'comment', 'sha', 'zone', '_gc', 'admin', 'inet6_ntoa', 'leading', 'fulltext', 'always', 'cluster', 'end', 'volatile', 'void', 'json', 'cast', 'range', 'session', 'function', 'inout', 'backup_history', 'limit', 'simple', 'timezone', 'charset', 'current_catalog', 'json_array_contains_json', '_continue_replay', 'middleint', 'only', 'preceding', 'differential', 'compression', 'chain', 'strip', '_sync_snapshot', 'temp', 'timestamp', 'date_add', 'declare', 'checkpoint', 'replace', 'current_time', 'unpivot', 'geography_longitude', 'within', 'connection_id', 'count', 'semi_join', 'privileges', 'memsql_imitating_kafka', 'json_splice_string', 'stable', 'deallocate', 'partitioning', 'geography', 'sensitive', 'databases', '_global_version_timestamp', 'varying', 'standalone', '_load', 'proxy', 'namespace', 'degrees', 'datediff', 'fields', 'references', 'adddate', '_commit_log_tail', 'invoker', 'rollup', 'role', 'snapshot', 'power', 'require', 'join', 'orphan', 'and', 'users', 'to', 'merge', '_pause_replay', 'rollback', 'cache', 'failure', 'hard_cpu_limit_percentage', 'signal', 'time_format', 'ceiling', 'true', 'operator', 'minvalue', 'client_found_rows', 'background', 'out_of_order', 'sql_buffer_result', 'dec', 'from', 'overlay', 'geometry_filter', 'no', 'replica', 'warnings', 'autostats_cardinality_mode', 'dual', 'iterate', 'from_unixtime', 'listen', 'microsecond', 'shard', 'partial', 'bin', 'exp', 'rlike', '_check_consistency', 'order', 'partition', 'nth_value', 'asin', 'array', 'sql_big_result', 'inet_ntoa', 'pool', 'indexes', 'sequences', 'current', 'ascii', 'assignment', 'json_get_type', 'inet6_aton', 'some', 'delayed', 'explain', 'connection', 'engine', 'global', 'rule', 'localtimestamp', 'reload', 'rtrim', 'columnar', 'minute_second', 'md5', 'day_minute', 'batches', 'addtime', 'following', 'min_rows', 'profiles', 'groups', 'unknown', 'while', 'interval', 'outfile', 'atan2', 'uncommitted', 'then', 'hash', 'check', 'json_length', 'percent_rank', 'year', 'availability', 'defaults', 'immediate', 'vector_sub', 'rename', 'nvarchar', 'var_pop', 'periodic', 'algorithm', 'arrange', 'resource_pool', 'stdout', '_fsync', 'fault', 'to_base64', 'valid', 'shutdown', 'sparse', 'disable', 'owned', 'exists', 'decode', '_init_profile', 'convert', '_unload', 'sqlstate', 'schemas', 'schema_binding', 'varbinary', 'sync', 'extractors', 'json_splice_double', 'sharded_id', '_disconnect', 'fetch', 'system', 'replicate', '_wake', 'clear', 'float', '_sync_partitions', 'abs', 'geography_latitude', 'estimate', 'account', 'std', 'minus', 'both', '_check_can_connect', 'identity', 'acos', 'password_lock_time', 'queue', 'work', 'regexp', 'right_straight_join', 'sqlwarning', 'elt', 'call_for_pipeline', 'last', 'view', 'prepared', 'immutable', 'delete', 'insert_method', 'user', 'soft_cpu_limit_percentage', 'show', 'series', 'ref', 'soname', '_batch_size_limit', 'mbc', 'timestampadd', 'parser', 'dynamic', 'program', 'else', 'geometry_x', 'log10', 'nullif', 'geometry_distance', 'result', 'lower', 'lz4', 'geometry_within_distance', 'handle', 'credentials', 'between', 'delimiters', 'bucket_count', 'grants', 'port', 'int3', 'sequence', 'temptable', 'safe', 'dot_product', 'timeout', 'norely', 'signed', 'sql_cache', 'version', 'grant', 'host', 'aggregator_plan_hash', 'position', 'undo', 'release', 'ast', 'placing', 'lc_collate', 'last_insert_id', '_internal_dynamic_typecast', 'earliest', 'identified', 'deferrable', 'fs', 'pi', 'json_array_push_double', 'procedural', 'cube', 'call', 'discard', 'local', 'binary', 'catalog', 'all', 'ln', 'cnf', 'months_between', 'trim', 'load', 'loop', 'attribute', 'backup', 'separator', 'quarter', 'success', 'mapping', 'directory', 'current_user', 'coalesce', 'exit', 'to_seconds', 'scalar', 'input', 'dense_rank', 'management', 'node', 'resource', 'service_user', 'assertion', 'radians', 'sql_small_result', 'approx_count_distinct_estimate', 'sync_snapshot', 'octet_length', 'distinct', 'lock', 'holding', 'stop', 'unlogged', 'rebalance', 'date_trunc', 'strict', 'time_bucket', 'month', 'time_to_sec', 'batch_interval', 'wrapper', 'elseif', 'unsigned', 'spatial', 'or', 'json_array_contains_double', 'reference', 'record', 'configuration', 'quote', 'collect', 'unlisten', 'upper', 'columnstore', 'duplicate', 'hour_second', 'stdin', 'named', 'ssl', 'options', 'language', 'variables', 'alter', 'day_microsecond', 'hour_minute', 'backward', 'any', 'compressed', 'statement', 'foreground', 'int4', 'floor', 'memsql_serialize', 'of', 'restrict', 'inet_aton', 'generate', 'unicode', 'verbose', '_utf8', 'tracelogs', 'auto_increment', 'heartbeat_no_logging', 'interpreter_mode', 'keys', 'geography_area', 'freeze', '_sleep', 'cost', 'compile', 'unenforced', 'key', 'hex', 'incremental', 'initcap', 'variadic', 'geography_intersects', 'serializable', 'start', 'capture', 'gc', 'attach', 'handler', 'running', 'avg', 'vacuum', 'when', 'nullcols', 'forward', 'instead', 'by', 'character_length', 'geometry', 'natural', 'approx_percentile', 'committed', 'hour', 'convert_tz', 'high_priority', 'trigger', 'log2', 'utc_timestamp', 'curdate', 'log', '_memsql_table_id_lookup', 'type', 'connections', '_drop_profile', 'aes_encrypt', 'xact_id', 'deterministic', 'from_base64', 'session_user', 'memsql', 'for', '_transactions_experimental', 'parquet', 'notify', 'asm', 'also', 'option', 'leave', 'unhold', 'monthname', 'gzip', 'pow', 'modify', 'text', 'value', 'drop', 'ucase', 'offsets', 'external_host', 'skip', '_sync', 'cross', 'lateral', 'truncate', 'substr', 'subdate', 'conversion', 'greatest', 'bit', 'defined', 'latest', 'maxvalue', 'level', 'absolute', 'paired', 'returning', 'left', 'boolean', 'async', 'force', '_repl', 'distributed_joins', 'row', 'pause', 'constraints', '_ls', 'terminated', 'files', 'temporary', 'excluding', 'including', 'exclude', 'lpad', '_management_thread', 'action', 'setof', 'max', 'task', 'int2', 'escaped', 'var_samp', 'query', 'execute', 'concurrent', 'label', 'instr', 'stddev_pop', 'profile', '_gcx', 'mediumblob', 'approx_count_distinct_accumulate', 'foreign', 'noparam', 'validate', 'llvm', 'security_lists_intersect', 'template', 'has_temp_tables', 'deferred', 'sum', 'date_format', 'client', 'str_to_date', 'materialized', 'window', 'max_partitions_per_batch', 'leaves', 'functions', 'next', 'insensitive', 'right', 'sign', 'pools', 'group_concat', 'analyse', 'max_rows', 'atan', 'prepare', 'aggregate', 'insert', 'preserve', 'rely', 'primary', 'extract', 'max_retries_per_batch_partition', 'called', 'passing', 'external_port', 'int8', 'backup_id', 'gcs', 'long', 'is', 'rows', 'cycle', 'transform', 'redundant', 'durability', 'lc_ctype', 'nulls', 'echo', 'reads', 'describe', 'add', '_rpc', 'inner', 'any_value', 'aes_decrypt', 'smallint', 'like', 'row_number', 'current_timestamp', 'use', 'least', 'authorization', 'aggregator', 'geometry_point', 'utc_time', 'autostats_histogram_mode', 'pipelines', 'character', 'return', 'errors', 'trailing', 'char_length', 'events', 'geometry_y', 'flush', 'ltrim', 'euclidean_distance', 'content', '_wm_heartbeat', 'open', 'json_extract_bigint', 'serial', 'inherits', 'enum', 'zerofill', 'geography_length', 'unlock', 'now', 'procedures', 'ordered_serialize', 'replication', 'two_phase', 'whitespace', 'out', 'round', 'at', 'values', 'localtime', 'json_extract_double', 'family', 'reassign', 'autostats_sampling', 'remove', 'varchar', 'national', '_reprovisioning', 'concurrently', 'no_query_rewrite', 'last_value', 'mode', 'table', 'timediff', 'optimizer', 'save', 'ilike', 'blob', 'election', '_unittest', 'rank', 'promote', 'sql', 'batch', 'loaddata_where', 'dayname', 'full', 'sin', 'target_size', 'remote', 'revoke', 'max_concurrency', 'kill', 'event', 'nowait', 'isolation', 'do', 'sql_calc_found_rows', 'plancache', 'init', 'field', 'azure', 'test', 'fill', 'mediumtext', 'rg_pool', 'sql_no_logging', 'csv', 'as', 'no_write_to_binlog', 'div', 'retry', 'extension', 'kafka', 'geometrypoint', 'sysid', 'concat', 'found_rows', 'stddev', 'arghistory', 'group', 'inherit', 'into', 'get_format', 'large', 'asc', 'geography_point', 'current_security_groups', 'usage', 'minute_microsecond', 'before', 'data', 'int1', 'current_security_roles', 'off', 'sqlexception', 'cume_dist', 'table_checksum', 'recursive', 'json_extract_json', 'triggers', 'aggregators', 'redundancy', 'to_char', 'having', 'integer', 'right_anti_join', 'status', 'sha2', 'aggregator_id', 'sec_to_time', 'ntile', 'enclosed', 'extra_join', 'percentile_cont', 'first', 'trunc', 'leaf', 'domain', 'replicating', 'tables', 'case', '_checksum', 'day_hour', 'trusted', 'mod', 'timestampdiff', 'object', 'scroll', 'int', 'curtime', '_binary', 'match', 'read', 'ceil', 'metadata', 'bit_xor', 'recheck', 'auto', 'online', 'first_value', 'to_date', 'isnull', 'master', '_repair_table', 'close', 'index', 'force_compiled_mode', 'minute', 'pipeline', 'persisted', 'unix_timestamp', 'bootstrap', 'over', 'modifies', 'outer', 'default', 'json_set_json', 'tags', 'upgrade', 'geographypoint', 'avg_row_length', 'weekday', 'geometry_intersects', 'sleep', 'dictionary', 'force_interpreter_mode', 'null', '_twopcid', 'repeat', 'lines', 'none', 'model', 'database', 'unbounded', 'queries', 'bit_and', 'locate', 'commit', 'where', 'false', 'constraint', 'json_array_push_json', 'security', 'json_set_string', 'exclusive', 'fix_alter', 'infile', 'lag', 'geography_contains', 'starting', 'tablespace', '_term_bump', 'inject', 'except', 'second_microsecond', 'year_month', '_send_threads', 'with', 'tinyint', 'increment', 'optimizer_state', 'json_array_push_string', 'skipped_batches', 's3', 'set', 'leakproof', 'xor', 'fixed', '_snapshot', 'columnstore_segment_rows', 'plugins', 'bool', 'member', 'optimization', 'routine', 'delimiter', 'comments', 'treat', 'current_schema', 'format', 'split', 'delay_key_write', 'dayofyear', 'longtext', 'similar', 'enable', 'max_errors', 'disk', 'last_day', 'weekofyear', 'write', 'cot', 'day', 'site', 'double', 'begin', 'rand', 'median', 'btree', 'dayofweek', 'roles', 'offset', 'lcase', 'relative', 'import', 'char', 'document', 'rowstore', 'precision', 'ifnull', 'optionally', 'query_timeout', 'grouping', 'select', 'workload', 'detach', '_snapshots', 'cursor', 'analyze', 'key_block_size', 'numeric', '_background_threads_for_cleanup', 'change', 'password', 'process', 'time', 'overlaps', 'reset', 'from_days', 'utc_date', 'copy', 'definer', 'reindex', 'names', 'initialize', 'restart', 'avro', 'wait', 'extractor', 'intersect', 'validator', 'bit_count', 'types', 'plan', 'week', 'sha1', 'row_count', 'synchronize', 'json_delete_key', 'header', 'memory', 'characteristics', 'to_timestamp', 'initially', 'coercibility', 'escape', 'nothing', 'processlist', 'collation', 'mediumint', 'memory_percentage', 'offline', 'string', 'asymmetric', 'min', 'float4', 'approx_count_distinct', 'repeatable', 'distinctrow', 'arrangement', 'cos', 'rpad', 'continue', 'purge', 'config', 'search', 'stats', 'returns', 'oids', 'byte', 'asensitive', 'clustered', 'voting', 'each', 'sharded', 'substring_index', 'current_date', 'extended', 'condition', 'savepoint', 'not', 'restore', 'without', 'unhex', 'collate', 'date_sub', 'low_priority', 'partitions', 'columns', 'anti_join', 'percentile_disc', 'conv', 'byte_length', 'json_set_double', 'hdfs', 'right_semi_join', 'autostats_enabled', 'json_splice_json', 'stddev_samp', 'longblob', 'day_second', 'create', 'bit_or', 'to_days', 'reverse', 'decimal', 'engines', 'geography_within_distance', 'max_queue_depth', 'desc', 'geometry_contains', '_resurrect', 'variance', 'location', 'implicit', 'approx_geography_intersects', 'sql_no_cache'}
@unsupported_args('on_condition')
def
jsonvalue_sql(self, expression: sqlglot.expressions.JSONValue) -> str:
1550 @unsupported_args("on_condition") 1551 def jsonvalue_sql(self, expression: exp.JSONValue) -> str: 1552 res: exp.Expression = exp.JSONExtractScalar( 1553 this=expression.this, 1554 expression=expression.args.get("path"), 1555 json_type="STRING", 1556 ) 1557 1558 returning = expression.args.get("returning") 1559 if returning is not None: 1560 res = exp.Cast(this=res, to=returning) 1561 1562 return self.sql(res)
1568 def jsonarraycontains_sql(self, expression: exp.JSONArrayContains) -> str: 1569 json_type = expression.text("json_type").upper() 1570 1571 if json_type: 1572 return self.func( 1573 f"JSON_ARRAY_CONTAINS_{json_type}", expression.expression, expression.this 1574 ) 1575 1576 return self.func( 1577 "JSON_ARRAY_CONTAINS_JSON", 1578 expression.expression, 1579 self.func("TO_JSON", expression.this), 1580 )
@unsupported_args('kind', 'nested', 'values')
def
datatype_sql(self, expression: sqlglot.expressions.DataType) -> str:
1582 @unsupported_args("kind", "nested", "values") 1583 def datatype_sql(self, expression: exp.DataType) -> str: 1584 if expression.is_type(exp.DataType.Type.VARBINARY) and not expression.expressions: 1585 # `VARBINARY` must always have a size - if it doesn't, we always generate `BLOB` 1586 return "BLOB" 1587 if expression.is_type( 1588 exp.DataType.Type.DECIMAL32, 1589 exp.DataType.Type.DECIMAL64, 1590 exp.DataType.Type.DECIMAL128, 1591 exp.DataType.Type.DECIMAL256, 1592 ): 1593 scale = self.expressions(expression, flat=True) 1594 1595 if expression.is_type(exp.DataType.Type.DECIMAL32): 1596 precision = "9" 1597 elif expression.is_type(exp.DataType.Type.DECIMAL64): 1598 precision = "18" 1599 elif expression.is_type(exp.DataType.Type.DECIMAL128): 1600 precision = "38" 1601 else: 1602 # 65 is a maximum precision supported in SingleStore 1603 precision = "65" 1604 if scale is not None: 1605 return f"DECIMAL({precision}, {scale[0]})" 1606 else: 1607 return f"DECIMAL({precision})" 1608 1609 return super().datatype_sql(expression)
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
- currentdate_sql
- collate_sql
- command_sql
- comment_sql
- mergetreettlaction_sql
- mergetreettl_sql
- transaction_sql
- commit_sql
- rollback_sql
- alterindex_sql
- alterdiststyle_sql
- altersortkey_sql
- alterrename_sql
- renamecolumn_sql
- alterset_sql
- alter_sql
- add_column_sql
- droppartition_sql
- addconstraint_sql
- addpartition_sql
- distinct_sql
- ignorenulls_sql
- respectnulls_sql
- havingmax_sql
- intdiv_sql
- div_sql
- safedivide_sql
- overlaps_sql
- distance_sql
- dot_sql
- eq_sql
- propertyeq_sql
- escape_sql
- glob_sql
- gt_sql
- gte_sql
- is_sql
- like_sql
- ilike_sql
- similarto_sql
- lt_sql
- lte_sql
- mod_sql
- mul_sql
- neq_sql
- nullsafeeq_sql
- nullsafeneq_sql
- slice_sql
- sub_sql
- trycast_sql
- jsoncast_sql
- try_sql
- log_sql
- use_sql
- binary
- ceil_floor
- function_fallback_sql
- func
- format_args
- too_wide
- format_time
- expressions
- op_expressions
- naked_property
- tag_sql
- token_sql
- userdefinedfunction_sql
- joinhint_sql
- kwarg_sql
- when_sql
- whens_sql
- merge_sql
- tochar_sql
- tonumber_sql
- dictproperty_sql
- dictrange_sql
- dictsubproperty_sql
- duplicatekeyproperty_sql
- uniquekeyproperty_sql
- distributedbyproperty_sql
- oncluster_sql
- clusteredbyproperty_sql
- anyvalue_sql
- querytransform_sql
- indexconstraintoption_sql
- checkcolumnconstraint_sql
- indexcolumnconstraint_sql
- nvl2_sql
- comprehension_sql
- columnprefix_sql
- opclass_sql
- predict_sql
- generateembedding_sql
- featuresattime_sql
- vectorsearch_sql
- forin_sql
- refresh_sql
- toarray_sql
- tsordstotime_sql
- tsordstotimestamp_sql
- tsordstodatetime_sql
- tsordstodate_sql
- unixdate_sql
- lastday_sql
- dateadd_sql
- arrayany_sql
- struct_sql
- partitionrange_sql
- truncatetable_sql
- convert_sql
- copyparameter_sql
- credentials_sql
- copy_sql
- semicolon_sql
- datadeletionproperty_sql
- maskingpolicycolumnconstraint_sql
- gapfill_sql
- scope_resolution
- scoperesolution_sql
- parsejson_sql
- rand_sql
- changes_sql
- pad_sql
- summarize_sql
- explodinggenerateseries_sql
- arrayconcat_sql
- json_sql
- conditionalinsert_sql
- multitableinserts_sql
- oncondition_sql
- jsonextractquote_sql
- jsonexists_sql
- arrayagg_sql
- apply_sql
- grant_sql
- revoke_sql
- grantprivilege_sql
- grantprincipal_sql
- columns_sql
- overlay_sql
- todouble_sql
- string_sql
- median_sql
- overflowtruncatebehavior_sql
- unixseconds_sql
- arraysize_sql
- attach_sql
- detach_sql
- attachoption_sql
- watermarkcolumnconstraint_sql
- encodeproperty_sql
- includeproperty_sql
- xmlelement_sql
- xmlkeyvalueoption_sql
- partitionbyrangeproperty_sql
- partitionbyrangepropertydynamic_sql
- unpivotcolumns_sql
- analyzesample_sql
- analyzestatistics_sql
- analyzehistogram_sql
- analyzedelete_sql
- analyzelistchainedrows_sql
- analyzevalidate_sql
- analyze_sql
- xmltable_sql
- xmlnamespace_sql
- export_sql
- declare_sql
- declareitem_sql
- recursivewithsearch_sql
- parameterizedagg_sql
- anonymousaggfunc_sql
- combinedaggfunc_sql
- combinedparameterizedagg_sql
- get_put_sql
- translatecharacters_sql
- decodecase_sql
- semanticview_sql
- getextract_sql
- datefromunixdate_sql
- space_sql
- buildproperty_sql
- refreshtriggerproperty_sql
- sqlglot.dialects.mysql.MySQL.Generator
- INTERVAL_ALLOWS_PLURAL_FORM
- LOCKING_READS_SUPPORTED
- NULL_ORDERING_SUPPORTED
- JOIN_HINTS
- TABLE_HINTS
- DUPLICATE_KEY_UPDATE_WITH_SET
- QUERY_HINT_SEP
- VALUES_AS_TABLE
- NVL2_SUPPORTED
- LAST_DAY_SUPPORTS_DATE_PART
- JSON_TYPE_REQUIRED_FOR_EXTRACTION
- JSON_PATH_BRACKETED_KEY_SUPPORTED
- JSON_KEY_VALUE_PAIR_SEP
- SUPPORTS_TO_NUMBER
- PARSE_JSON_NAME
- PAD_FILL_PATTERN_IS_REQUIRED
- WRAP_DERIVED_VALUES
- VARCHAR_REQUIRES_SIZE
- SUPPORTS_MEDIAN
- UNSIGNED_TYPE_MAPPING
- TIMESTAMP_TYPE_MAPPING
- PROPERTIES_LOCATION
- LIMIT_FETCH
- LIMIT_ONLY_LITERALS
- CHAR_CAST_MAPPING
- SIGNED_CAST_MAPPING
- CAST_MAPPING
- TIMESTAMP_FUNC_TYPES
- computedcolumnconstraint_sql
- array_sql
- arraycontainsall_sql
- dpipe_sql
- extract_sql
- cast_sql
- show_sql
- altercolumn_sql
- chr_sql
- timestamptrunc_sql
- converttimezone_sql
- attimezone_sql
- isascii_sql
- currentschema_sql