sqlglot.generators.exasol
1from __future__ import annotations 2 3import typing as t 4 5from sqlglot import exp, generator 6from sqlglot.dialects.dialect import ( 7 DATE_ADD_OR_SUB, 8 Dialect, 9 date_trunc_to_trunc_sql, 10 groupconcat_sql, 11 mod_func_sql, 12 no_last_day_sql, 13 rename_func, 14 strposition_sql, 15 timestrtotime_sql, 16 timestamptrunc_sql, 17 weekstart_unit_to_str, 18) 19from sqlglot.errors import UnsupportedError 20from sqlglot.generator import unsupported_args 21from sqlglot.optimizer.scope import build_scope, find_in_scope 22from sqlglot.parsers.exasol import DATE_UNITS 23 24 25def _sha2_sql(self: ExasolGenerator, expression: exp.SHA2) -> str: 26 length = expression.text("length") 27 func_name = "HASH_SHA256" if length == "256" else "HASH_SHA512" 28 return self.func(func_name, expression.this) 29 30 31def _date_diff_sql(self: ExasolGenerator, expression: exp.DateDiff | exp.TsOrDsDiff) -> str: 32 unit = expression.text("unit").upper() or "DAY" 33 34 if unit not in DATE_UNITS: 35 self.unsupported(f"'{unit}' is not supported in Exasol.") 36 return self.function_fallback_sql(expression) 37 38 return self.func(f"{unit}S_BETWEEN", expression.this, expression.expression) 39 40 41# https://docs.exasol.com/db/latest/sql/select.htm#:~:text=If%20you%20have,local.x%3E10 42def _add_local_prefix_for_aliases(expression: exp.Expr, dialect: Dialect) -> exp.Expr: 43 def _key(ident: exp.Identifier) -> str: 44 return dialect.normalize_identifier(ident.copy()).this 45 46 if isinstance(expression, exp.Select): 47 aliases: dict[str, exp.Identifier] = { 48 _key(alias): alias 49 for sel in expression.selects 50 if isinstance(sel, exp.Alias) and (alias := sel.args.get("alias")) 51 } 52 53 table = expression.find(exp.Table) 54 table_ident = table.this if table else None 55 56 if ( 57 table_ident 58 and table_ident.name.upper() == "LOCAL" 59 and not bool(table_ident.args.get("quoted")) 60 ): 61 table_ident.replace(exp.to_identifier(table_ident.name.upper(), quoted=True)) 62 63 def prefix_local(node: exp.Expr, visible_aliases: dict[str, exp.Identifier]) -> exp.Expr: 64 if isinstance(node, exp.Column) and not node.table: 65 alias = visible_aliases.get(_key(node.this)) 66 if alias is not None: 67 return exp.Column( 68 this=alias, 69 table=exp.to_identifier("LOCAL", quoted=False), 70 ) 71 return node 72 73 for key in ("where", "group", "having"): 74 if arg := expression.args.get(key): 75 expression.set(key, arg.transform(lambda node: prefix_local(node, aliases))) 76 77 seen_aliases: dict[str, exp.Identifier] = {} 78 new_selects: list[exp.Expr] = [] 79 for sel in expression.selects: 80 if isinstance(sel, exp.Alias): 81 inner = sel.this.transform(lambda node: prefix_local(node, seen_aliases)) 82 sel.set("this", inner) 83 84 if alias_node := sel.args.get("alias"): 85 seen_aliases[_key(alias_node)] = alias_node 86 new_selects.append(sel) 87 else: 88 new_selects.append(sel.transform(lambda node: prefix_local(node, seen_aliases))) 89 expression.set("expressions", new_selects) 90 91 return expression 92 93 94def _trunc_sql( 95 self: ExasolGenerator, kind: str, expression: exp.DateTrunc | exp.TimestampTrunc 96) -> str: 97 unit = weekstart_unit_to_str(self, expression) 98 node = expression.this.this if isinstance(expression.this, exp.Cast) else expression.this 99 expr_sql = self.sql(node) 100 if isinstance(node, exp.Literal) and node.is_string: 101 text = node.this.replace("T", " ") if kind == "TIMESTAMP" else node.this 102 expr_sql = f"{kind} {self.sql(exp.Literal.string(text))}" 103 return f"DATE_TRUNC({self.sql(unit)}, {expr_sql})" 104 105 106def _timestamp_trunc_sql( 107 self: ExasolGenerator, expression: exp.DateTrunc | exp.TimestampTrunc 108) -> str: 109 return _trunc_sql(self, "TIMESTAMP", expression) 110 111 112def is_case_insensitive(node: exp.Expr) -> bool: 113 return isinstance(node, exp.Collate) and node.text("expression").upper() == "UTF8_LCASE" 114 115 116def _substring_index_sql(self: ExasolGenerator, expression: exp.SubstringIndex) -> str: 117 this = expression.this 118 delimiter = expression.args["delimiter"] 119 count_node = expression.args["count"] 120 count_sql = self.sql(expression, "count") 121 num = count_node.to_py() if count_node.is_number else 0 122 123 haystack_sql = self.sql(this) 124 if num == 0: 125 return self.func("SUBSTR", haystack_sql, "1", "0") 126 127 from_right = num < 0 128 direction = "-1" if from_right else "1" 129 occur = self.func("ABS", count_sql) if from_right else count_sql 130 131 delimiter_sql = self.sql(delimiter) 132 133 position = self.func( 134 "INSTR", 135 self.func("LOWER", haystack_sql) if is_case_insensitive(this) else haystack_sql, 136 self.func("LOWER", delimiter_sql) if is_case_insensitive(delimiter) else delimiter_sql, 137 direction, 138 occur, 139 ) 140 nullable_pos = self.func("NULLIF", position, "0") 141 142 if from_right: 143 start = self.func( 144 "NVL", f"{nullable_pos} + {self.func('LENGTH', delimiter_sql)}", direction 145 ) 146 return self.func("SUBSTR", haystack_sql, start) 147 148 length = self.func("NVL", f"{nullable_pos} - 1", self.func("LENGTH", haystack_sql)) 149 return self.func("SUBSTR", haystack_sql, direction, length) 150 151 152# https://docs.exasol.com/db/latest/sql/select.htm#:~:text=The%20select_list%20defines%20the%20columns%20of%20the%20result%20table.%20If%20*%20is%20used%2C%20all%20columns%20are%20listed.%20You%20can%20use%20an%20expression%20like%20t.*%20to%20list%20all%20columns%20of%20the%20table%20t%2C%20the%20view%20t%2C%20or%20the%20object%20with%20the%20table%20alias%20t. 153def _qualify_unscoped_star(expression: exp.Expr) -> exp.Expr: 154 """ 155 Exasol doesn't support a bare * alongside other select items, so we rewrite it 156 Rewrite: SELECT *, <other> FROM <Table> 157 Into: SELECT T.*, <other> FROM <Table> AS T 158 """ 159 160 if not isinstance(expression, exp.Select): 161 return expression 162 163 select_expressions = expression.expressions or [] 164 165 def is_bare_star(expr: exp.Expr) -> bool: 166 return isinstance(expr, exp.Star) and expr.this is None 167 168 has_other_expression = False 169 bare_star_expr: exp.Expr | None = None 170 for expr in select_expressions: 171 has_bare_star = is_bare_star(expr) 172 if has_bare_star and bare_star_expr is None: 173 bare_star_expr = expr 174 elif not has_bare_star: 175 has_other_expression = True 176 if bare_star_expr and has_other_expression: 177 break 178 179 if not (bare_star_expr and has_other_expression): 180 return expression 181 182 scope = build_scope(expression) 183 184 if not scope or not scope.selected_sources: 185 return expression 186 187 table_identifiers: list[exp.Identifier] = [] 188 189 for source_name, (source_expr, _) in scope.selected_sources.items(): 190 ident = ( 191 source_expr.this.copy() 192 if isinstance(source_expr, exp.Table) and isinstance(source_expr.this, exp.Identifier) 193 else exp.to_identifier(source_name) 194 ) 195 table_identifiers.append(ident) 196 197 qualified_star_columns = [ 198 exp.Column(this=bare_star_expr.copy(), table=ident) for ident in table_identifiers 199 ] 200 201 new_select_expressions: list[exp.Expr] = [] 202 203 for select_expr in select_expressions: 204 new_select_expressions.extend(qualified_star_columns) if is_bare_star( 205 select_expr 206 ) else new_select_expressions.append(select_expr) 207 208 expression.set("expressions", new_select_expressions) 209 return expression 210 211 212def _add_date_sql(self: ExasolGenerator, expression: DATE_ADD_OR_SUB) -> str: 213 interval = expression.expression if isinstance(expression.expression, exp.Interval) else None 214 215 unit = ( 216 (interval.text("unit") or "DAY").upper() 217 if interval is not None 218 else (expression.text("unit") or "DAY").upper() 219 ) 220 221 if unit not in DATE_UNITS: 222 self.unsupported(f"'{unit}' is not supported in Exasol.") 223 return self.function_fallback_sql(expression) 224 225 offset_expr: exp.Expr = expression.expression 226 if interval is not None: 227 offset_expr = interval.this 228 229 if isinstance(expression, exp.DateSub): 230 offset_expr = exp.Neg(this=offset_expr) 231 232 return self.func(f"ADD_{unit}S", expression.this, offset_expr) 233 234 235def _group_by_all(expression: exp.Expr) -> exp.Expr: 236 if not isinstance(expression, exp.Select): 237 return expression 238 239 group = expression.args.get("group") 240 if not group or not group.args.get("all"): 241 return expression 242 243 if expression.is_star: 244 if any(find_in_scope(proj, exp.AggFunc) for proj in expression.expressions): 245 raise UnsupportedError( 246 "GROUP BY ALL with star projection and aggregates is not supported by Exasol" 247 ) 248 expression.set("distinct", exp.Distinct()) 249 expression.set("group", None) 250 return expression 251 252 group_positions = [ 253 exp.Literal.number(i) 254 for i, proj in enumerate(expression.expressions, start=1) 255 if not find_in_scope(proj, exp.AggFunc) 256 ] 257 258 if not group_positions: 259 expression.set("group", None) 260 return expression 261 262 group.set("expressions", group_positions) 263 group.set("all", None) 264 265 return expression 266 267 268class ExasolGenerator(generator.Generator): 269 DATA_TYPE_SPECIFIERS_ALLOWED = True 270 SELECT_KINDS = () 271 TRY_SUPPORTED = False 272 SUPPORTS_UESCAPE = False 273 SUPPORTS_DECODE_CASE = False 274 275 AFTER_HAVING_MODIFIER_TRANSFORMS = generator.AFTER_HAVING_MODIFIER_TRANSFORMS 276 277 # https://docs.exasol.com/db/latest/sql_references/data_types/datatypedetails.htm#StringDataType 278 STRING_TYPE_MAPPING: t.ClassVar = { 279 exp.DType.BLOB: "VARCHAR", 280 exp.DType.LONGBLOB: "VARCHAR", 281 exp.DType.LONGTEXT: "VARCHAR", 282 exp.DType.MEDIUMBLOB: "VARCHAR", 283 exp.DType.MEDIUMTEXT: "VARCHAR", 284 exp.DType.TINYBLOB: "VARCHAR", 285 exp.DType.TINYTEXT: "VARCHAR", 286 # https://docs.exasol.com/db/latest/sql_references/data_types/datatypealiases.htm 287 exp.DType.TEXT: "LONG VARCHAR", 288 exp.DType.VARBINARY: "VARCHAR", 289 } 290 291 # https://docs.exasol.com/db/latest/sql_references/data_types/datatypealiases.htm 292 TYPE_MAPPING = { 293 **generator.Generator.TYPE_MAPPING, 294 **STRING_TYPE_MAPPING, 295 exp.DType.TINYINT: "SMALLINT", 296 exp.DType.MEDIUMINT: "INT", 297 exp.DType.DECIMAL32: "DECIMAL", 298 exp.DType.DECIMAL64: "DECIMAL", 299 exp.DType.DECIMAL128: "DECIMAL", 300 exp.DType.DECIMAL256: "DECIMAL", 301 exp.DType.DATETIME: "TIMESTAMP", 302 exp.DType.TIMESTAMPTZ: "TIMESTAMP", 303 exp.DType.TIMESTAMPLTZ: "TIMESTAMP", 304 exp.DType.TIMESTAMPNTZ: "TIMESTAMP", 305 } 306 307 def datetrunc_sql(self, expression: exp.DateTrunc) -> str: 308 if isinstance(expression.unit, exp.WeekStart) or expression.unit.name in ( 309 "CENTURY", 310 "WEEK_OF_MONTH", 311 "WEEK_OF_YEAR", 312 "ISOYEAR", 313 ): 314 return date_trunc_to_trunc_sql(self, expression) 315 return _trunc_sql(self, "DATE", expression) 316 317 def select_sql(self, expression: exp.Select) -> str: 318 processed = _qualify_unscoped_star(expression) 319 processed = _add_local_prefix_for_aliases(processed, self.dialect) 320 processed = _group_by_all(processed) 321 return super().select_sql(t.cast(exp.Select, processed)) 322 323 def _native_dayofweek_sql(self, expression: exp.DayOfWeek) -> str: 324 return f"CAST(TO_CHAR({self.sql(expression, 'this')}, 'D') AS INTEGER)" 325 326 def datatype_sql(self, expression: exp.DataType) -> str: 327 # Exasol supports a fixed default precision of 3 for TIMESTAMP WITH LOCAL TIME ZONE 328 # and does not allow specifying a different custom precision 329 if expression.is_type(exp.DType.TIMESTAMPLTZ): 330 return "TIMESTAMP WITH LOCAL TIME ZONE" 331 332 return super().datatype_sql(expression) 333 334 TRANSFORMS = { 335 **generator.Generator.TRANSFORMS, 336 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/every.htm 337 exp.All: rename_func("EVERY"), 338 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/bit_and.htm 339 exp.BitwiseAnd: rename_func("BIT_AND"), 340 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/bit_or.htm 341 exp.BitwiseOr: rename_func("BIT_OR"), 342 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/bit_not.htm 343 exp.BitwiseNot: rename_func("BIT_NOT"), 344 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/bit_lshift.htm 345 exp.BitwiseLeftShift: rename_func("BIT_LSHIFT"), 346 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/bit_rshift.htm 347 exp.BitwiseRightShift: rename_func("BIT_RSHIFT"), 348 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/bit_xor.htm 349 exp.BitwiseXor: rename_func("BIT_XOR"), 350 exp.CurrentSchema: lambda *_: "CURRENT_SCHEMA", 351 exp.DateDiff: _date_diff_sql, 352 exp.DateAdd: _add_date_sql, 353 exp.TsOrDsAdd: _add_date_sql, 354 exp.DateSub: _add_date_sql, 355 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/div.htm#DIV 356 exp.IntDiv: rename_func("DIV"), 357 exp.TsOrDsDiff: _date_diff_sql, 358 exp.DatetimeTrunc: timestamptrunc_sql(), 359 exp.GroupConcat: lambda self, e: groupconcat_sql(self, e, on_overflow=True), 360 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/edit_distance.htm#EDIT_DISTANCE 361 exp.Levenshtein: unsupported_args("ins_cost", "del_cost", "sub_cost", "max_dist")( 362 rename_func("EDIT_DISTANCE") 363 ), 364 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/mod.htm 365 exp.Mod: mod_func_sql, 366 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/from_posix_time.htm 367 exp.UnixToTime: lambda self, e: self.func("FROM_POSIX_TIME", e.this), 368 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/rank.htm 369 exp.Rank: unsupported_args("expressions")(lambda *_: "RANK()"), 370 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/dense_rank.htm 371 exp.DenseRank: unsupported_args("expressions")(lambda *_: "DENSE_RANK()"), 372 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/regexp_substr.htm 373 exp.RegexpExtract: unsupported_args("parameters", "group")(rename_func("REGEXP_SUBSTR")), 374 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/regexp_replace.htm 375 exp.RegexpReplace: unsupported_args("modifiers")(rename_func("REGEXP_REPLACE")), 376 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/var_pop.htm 377 exp.VariancePop: rename_func("VAR_POP"), 378 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/approximate_count_distinct.htm 379 exp.ApproxDistinct: unsupported_args("accuracy")(rename_func("APPROXIMATE_COUNT_DISTINCT")), 380 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/to_char%20(datetime).htm 381 exp.TimeToStr: lambda self, e: self.func("TO_CHAR", e.this, self.format_time(e)), 382 exp.ToChar: lambda self, e: self.func("TO_CHAR", e.this, self.format_time(e)), 383 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/to_date.htm 384 exp.TsOrDsToDate: lambda self, e: self.func("TO_DATE", e.this, self.format_time(e)), 385 exp.TimeStrToTime: timestrtotime_sql, 386 exp.TimestampTrunc: _timestamp_trunc_sql, 387 exp.StrToTime: lambda self, e: self.func("TO_DATE", e.this, self.format_time(e)), 388 exp.CurrentUser: lambda *_: "CURRENT_USER", 389 exp.AtTimeZone: lambda self, e: self.func( 390 "CONVERT_TZ", 391 e.this, 392 "'UTC'", 393 e.args.get("zone"), 394 ), 395 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/instr.htm 396 exp.StrPosition: lambda self, e: strposition_sql( 397 self, e, func_name="INSTR", supports_position=True, supports_occurrence=True 398 ), 399 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/hash_sha%5B1%5D.htm#HASH_SHA%5B1%5D 400 exp.SHA: rename_func("HASH_SHA"), 401 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/hash_sha256.htm 402 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/hash_sha512.htm 403 exp.SHA2: _sha2_sql, 404 exp.MD5: rename_func("HASH_MD5"), 405 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/hashtype_md5.htm 406 exp.MD5Digest: rename_func("HASHTYPE_MD5"), 407 # https://docs.exasol.com/db/latest/sql/create_view.htm 408 exp.CommentColumnConstraint: lambda self, e: f"COMMENT IS {self.sql(e, 'this')}", 409 exp.SubstringIndex: _substring_index_sql, 410 exp.WeekOfYear: rename_func("WEEK"), 411 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/to_date.htm 412 exp.Date: rename_func("TO_DATE"), 413 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/to_timestamp.htm 414 exp.Timestamp: rename_func("TO_TIMESTAMP"), 415 exp.Quarter: lambda self, e: f"CEIL(MONTH(TO_DATE({self.sql(e, 'this')}))/3)", 416 exp.LastDay: no_last_day_sql, 417 } 418 419 # https://docs.exasol.com/db/7.1/sql_references/system_tables/metadata/exa_sql_keywords.htm 420 RESERVED_KEYWORDS = { 421 "absolute", 422 "action", 423 "add", 424 "after", 425 "all", 426 "allocate", 427 "alter", 428 "and", 429 "any", 430 "append", 431 "are", 432 "array", 433 "as", 434 "asc", 435 "asensitive", 436 "assertion", 437 "at", 438 "attribute", 439 "authid", 440 "authorization", 441 "before", 442 "begin", 443 "between", 444 "bigint", 445 "binary", 446 "bit", 447 "blob", 448 "blocked", 449 "bool", 450 "boolean", 451 "both", 452 "by", 453 "byte", 454 "call", 455 "called", 456 "cardinality", 457 "cascade", 458 "cascaded", 459 "case", 460 "casespecific", 461 "cast", 462 "catalog", 463 "chain", 464 "char", 465 "character", 466 "character_set_catalog", 467 "character_set_name", 468 "character_set_schema", 469 "characteristics", 470 "check", 471 "checked", 472 "clob", 473 "close", 474 "coalesce", 475 "collate", 476 "collation", 477 "collation_catalog", 478 "collation_name", 479 "collation_schema", 480 "column", 481 "commit", 482 "condition", 483 "connect_by_iscycle", 484 "connect_by_isleaf", 485 "connect_by_root", 486 "connection", 487 "constant", 488 "constraint", 489 "constraint_state_default", 490 "constraints", 491 "constructor", 492 "contains", 493 "continue", 494 "control", 495 "convert", 496 "corresponding", 497 "create", 498 "cs", 499 "csv", 500 "cube", 501 "current", 502 "current_cluster", 503 "current_cluster_uid", 504 "current_date", 505 "current_path", 506 "current_role", 507 "current_schema", 508 "current_session", 509 "current_statement", 510 "current_time", 511 "current_timestamp", 512 "current_user", 513 "cursor", 514 "cycle", 515 "data", 516 "datalink", 517 "datetime_interval_code", 518 "datetime_interval_precision", 519 "day", 520 "dbtimezone", 521 "deallocate", 522 "dec", 523 "decimal", 524 "declare", 525 "default", 526 "default_like_escape_character", 527 "deferrable", 528 "deferred", 529 "defined", 530 "definer", 531 "delete", 532 "deref", 533 "derived", 534 "desc", 535 "describe", 536 "descriptor", 537 "deterministic", 538 "disable", 539 "disabled", 540 "disconnect", 541 "dispatch", 542 "distinct", 543 "dlurlcomplete", 544 "dlurlpath", 545 "dlurlpathonly", 546 "dlurlscheme", 547 "dlurlserver", 548 "dlvalue", 549 "do", 550 "domain", 551 "double", 552 "drop", 553 "dynamic", 554 "dynamic_function", 555 "dynamic_function_code", 556 "each", 557 "else", 558 "elseif", 559 "elsif", 560 "emits", 561 "enable", 562 "enabled", 563 "end", 564 "end-exec", 565 "endif", 566 "enforce", 567 "equals", 568 "errors", 569 "escape", 570 "except", 571 "exception", 572 "exec", 573 "execute", 574 "exists", 575 "exit", 576 "export", 577 "external", 578 "extract", 579 "false", 580 "fbv", 581 "fetch", 582 "file", 583 "final", 584 "first", 585 "float", 586 "following", 587 "for", 588 "forall", 589 "force", 590 "format", 591 "found", 592 "free", 593 "from", 594 "fs", 595 "full", 596 "function", 597 "general", 598 "generated", 599 "geometry", 600 "get", 601 "global", 602 "go", 603 "goto", 604 "grant", 605 "granted", 606 "group", 607 "group_concat", 608 "grouping", 609 "groups", 610 "hashtype", 611 "hashtype_format", 612 "having", 613 "high", 614 "hold", 615 "hour", 616 "identity", 617 "if", 618 "ifnull", 619 "immediate", 620 "impersonate", 621 "implementation", 622 "import", 623 "in", 624 "index", 625 "indicator", 626 "inner", 627 "inout", 628 "input", 629 "insensitive", 630 "insert", 631 "instance", 632 "instantiable", 633 "int", 634 "integer", 635 "integrity", 636 "intersect", 637 "interval", 638 "into", 639 "inverse", 640 "invoker", 641 "is", 642 "iterate", 643 "join", 644 "key_member", 645 "key_type", 646 "large", 647 "last", 648 "lateral", 649 "ldap", 650 "leading", 651 "leave", 652 "left", 653 "level", 654 "like", 655 "limit", 656 "listagg", 657 "localtime", 658 "localtimestamp", 659 "locator", 660 "log", 661 "longvarchar", 662 "loop", 663 "low", 664 "map", 665 "match", 666 "matched", 667 "merge", 668 "method", 669 "minus", 670 "minute", 671 "mod", 672 "modifies", 673 "modify", 674 "module", 675 "month", 676 "names", 677 "national", 678 "natural", 679 "nchar", 680 "nclob", 681 "new", 682 "next", 683 "nls_date_format", 684 "nls_date_language", 685 "nls_first_day_of_week", 686 "nls_numeric_characters", 687 "nls_timestamp_format", 688 "no", 689 "nocycle", 690 "nologging", 691 "none", 692 "not", 693 "null", 694 "nullif", 695 "number", 696 "numeric", 697 "nvarchar", 698 "nvarchar2", 699 "object", 700 "of", 701 "off", 702 "old", 703 "on", 704 "only", 705 "open", 706 "option", 707 "options", 708 "or", 709 "order", 710 "ordering", 711 "ordinality", 712 "others", 713 "out", 714 "outer", 715 "output", 716 "over", 717 "overlaps", 718 "overlay", 719 "overriding", 720 "pad", 721 "parallel_enable", 722 "parameter", 723 "parameter_specific_catalog", 724 "parameter_specific_name", 725 "parameter_specific_schema", 726 "parquet", 727 "partial", 728 "path", 729 "permission", 730 "placing", 731 "plus", 732 "preceding", 733 "preferring", 734 "prepare", 735 "preserve", 736 "prior", 737 "privileges", 738 "procedure", 739 "profile", 740 "qualify", 741 "random", 742 "range", 743 "read", 744 "reads", 745 "real", 746 "recovery", 747 "recursive", 748 "ref", 749 "references", 750 "referencing", 751 "refresh", 752 "regexp_like", 753 "relative", 754 "release", 755 "rename", 756 "repeat", 757 "replace", 758 "restore", 759 "restrict", 760 "result", 761 "return", 762 "returned_length", 763 "returned_octet_length", 764 "returns", 765 "revoke", 766 "right", 767 "rollback", 768 "rollup", 769 "routine", 770 "row", 771 "rows", 772 "rowtype", 773 "savepoint", 774 "schema", 775 "scope", 776 "scope_user", 777 "script", 778 "scroll", 779 "search", 780 "second", 781 "section", 782 "security", 783 "select", 784 "selective", 785 "self", 786 "sensitive", 787 "separator", 788 "sequence", 789 "session", 790 "session_user", 791 "sessiontimezone", 792 "set", 793 "sets", 794 "shortint", 795 "similar", 796 "smallint", 797 "some", 798 "source", 799 "space", 800 "specific", 801 "specifictype", 802 "sql", 803 "sql_bigint", 804 "sql_bit", 805 "sql_char", 806 "sql_date", 807 "sql_decimal", 808 "sql_double", 809 "sql_float", 810 "sql_integer", 811 "sql_longvarchar", 812 "sql_numeric", 813 "sql_preprocessor_script", 814 "sql_real", 815 "sql_smallint", 816 "sql_timestamp", 817 "sql_tinyint", 818 "sql_type_date", 819 "sql_type_timestamp", 820 "sql_varchar", 821 "sqlexception", 822 "sqlstate", 823 "sqlwarning", 824 "start", 825 "state", 826 "statement", 827 "static", 828 "structure", 829 "style", 830 "substring", 831 "subtype", 832 "sysdate", 833 "system", 834 "system_user", 835 "systimestamp", 836 "table", 837 "temporary", 838 "text", 839 "then", 840 "time", 841 "timestamp", 842 "timezone_hour", 843 "timezone_minute", 844 "tinyint", 845 "to", 846 "trailing", 847 "transaction", 848 "transform", 849 "transforms", 850 "translation", 851 "treat", 852 "trigger", 853 "trim", 854 "true", 855 "truncate", 856 "under", 857 "union", 858 "unique", 859 "unknown", 860 "unlink", 861 "unnest", 862 "until", 863 "update", 864 "usage", 865 "user", 866 "using", 867 "value", 868 "values", 869 "varchar", 870 "varchar2", 871 "varray", 872 "verify", 873 "view", 874 "when", 875 "whenever", 876 "where", 877 "while", 878 "window", 879 "with", 880 "within", 881 "without", 882 "work", 883 "year", 884 "yes", 885 "zone", 886 } 887 888 def converttimezone_sql(self, expression: exp.ConvertTimezone) -> str: 889 from_tz = expression.args.get("source_tz") 890 to_tz = expression.args.get("target_tz") 891 datetime = expression.args.get("timestamp") 892 options = expression.args.get("options") 893 894 return self.func("CONVERT_TZ", datetime, from_tz, to_tz, options) 895 896 def if_sql(self, expression: exp.If) -> str: 897 this = self.sql(expression, "this") 898 true = self.sql(expression, "true") 899 false = self.sql(expression, "false") 900 return f"IF {this} THEN {true} ELSE {false} ENDIF" 901 902 # https://docs.exasol.com/db/latest/sql/open_schema.htm 903 def use_sql(self, expression: exp.Use) -> str: 904 kind = expression.args.get("kind") 905 if kind and self.sql(kind).upper() != "SCHEMA": 906 self.unsupported(f"'USE {self.sql(kind)}' is not supported in Exasol") 907 return super().use_sql(expression) 908 this = self.sql(expression, "this") 909 return f"OPEN SCHEMA {this}" 910 911 # https://docs.exasol.com/db/latest/sql_references/metadata/metadata_system_tables.htm 912 def show_sql(self, expression: exp.Show) -> str: 913 if expression.name == "TABLES": 914 db_name = expression.text("db") 915 schema_filter: exp.Expression = ( 916 exp.Literal.string(db_name.upper()) if db_name else exp.CurrentSchema() 917 ) 918 select = ( 919 exp.select(exp.column("TABLE_NAME")) 920 .from_(exp.table_("EXA_ALL_TABLES", db="SYS")) 921 .where(exp.column("TABLE_SCHEMA").eq(schema_filter)) 922 ) 923 return self.sql(select) 924 925 if expression.name == "DATABASES": 926 select = exp.select(exp.column("SCHEMA_NAME")).from_( 927 exp.table_("EXA_SCHEMAS", db="SYS") 928 ) 929 return self.sql(select) 930 931 return super().show_sql(expression) 932 933 def collate_sql(self, expression: exp.Collate) -> str: 934 return self.sql(expression.this) 935 936 def jsonextract_sql(self, expression: exp.JSONExtract) -> str: 937 sql = self.func( 938 "JSON_EXTRACT", expression.this, expression.expression, *expression.expressions 939 ) 940 941 emits = self.sql(expression, "emits") 942 if emits: 943 sql = f"{sql} EMITS {emits}" 944 945 return sql 946 947 @unsupported_args("flag") 948 def regexplike_sql(self, expression: exp.RegexpLike) -> str: 949 if not expression.args.get("full_match"): 950 pattern = expression.expression 951 if pattern.is_string: 952 expression.set("expression", exp.Literal.string(f".*{pattern.name}.*")) 953 else: 954 expression.set( 955 "expression", 956 exp.Paren( 957 this=exp.Concat( 958 expressions=[ 959 exp.Literal.string(".*"), 960 pattern, 961 exp.Literal.string(".*"), 962 ] 963 ) 964 ), 965 ) 966 return self.binary(expression, "REGEXP_LIKE")
269class ExasolGenerator(generator.Generator): 270 DATA_TYPE_SPECIFIERS_ALLOWED = True 271 SELECT_KINDS = () 272 TRY_SUPPORTED = False 273 SUPPORTS_UESCAPE = False 274 SUPPORTS_DECODE_CASE = False 275 276 AFTER_HAVING_MODIFIER_TRANSFORMS = generator.AFTER_HAVING_MODIFIER_TRANSFORMS 277 278 # https://docs.exasol.com/db/latest/sql_references/data_types/datatypedetails.htm#StringDataType 279 STRING_TYPE_MAPPING: t.ClassVar = { 280 exp.DType.BLOB: "VARCHAR", 281 exp.DType.LONGBLOB: "VARCHAR", 282 exp.DType.LONGTEXT: "VARCHAR", 283 exp.DType.MEDIUMBLOB: "VARCHAR", 284 exp.DType.MEDIUMTEXT: "VARCHAR", 285 exp.DType.TINYBLOB: "VARCHAR", 286 exp.DType.TINYTEXT: "VARCHAR", 287 # https://docs.exasol.com/db/latest/sql_references/data_types/datatypealiases.htm 288 exp.DType.TEXT: "LONG VARCHAR", 289 exp.DType.VARBINARY: "VARCHAR", 290 } 291 292 # https://docs.exasol.com/db/latest/sql_references/data_types/datatypealiases.htm 293 TYPE_MAPPING = { 294 **generator.Generator.TYPE_MAPPING, 295 **STRING_TYPE_MAPPING, 296 exp.DType.TINYINT: "SMALLINT", 297 exp.DType.MEDIUMINT: "INT", 298 exp.DType.DECIMAL32: "DECIMAL", 299 exp.DType.DECIMAL64: "DECIMAL", 300 exp.DType.DECIMAL128: "DECIMAL", 301 exp.DType.DECIMAL256: "DECIMAL", 302 exp.DType.DATETIME: "TIMESTAMP", 303 exp.DType.TIMESTAMPTZ: "TIMESTAMP", 304 exp.DType.TIMESTAMPLTZ: "TIMESTAMP", 305 exp.DType.TIMESTAMPNTZ: "TIMESTAMP", 306 } 307 308 def datetrunc_sql(self, expression: exp.DateTrunc) -> str: 309 if isinstance(expression.unit, exp.WeekStart) or expression.unit.name in ( 310 "CENTURY", 311 "WEEK_OF_MONTH", 312 "WEEK_OF_YEAR", 313 "ISOYEAR", 314 ): 315 return date_trunc_to_trunc_sql(self, expression) 316 return _trunc_sql(self, "DATE", expression) 317 318 def select_sql(self, expression: exp.Select) -> str: 319 processed = _qualify_unscoped_star(expression) 320 processed = _add_local_prefix_for_aliases(processed, self.dialect) 321 processed = _group_by_all(processed) 322 return super().select_sql(t.cast(exp.Select, processed)) 323 324 def _native_dayofweek_sql(self, expression: exp.DayOfWeek) -> str: 325 return f"CAST(TO_CHAR({self.sql(expression, 'this')}, 'D') AS INTEGER)" 326 327 def datatype_sql(self, expression: exp.DataType) -> str: 328 # Exasol supports a fixed default precision of 3 for TIMESTAMP WITH LOCAL TIME ZONE 329 # and does not allow specifying a different custom precision 330 if expression.is_type(exp.DType.TIMESTAMPLTZ): 331 return "TIMESTAMP WITH LOCAL TIME ZONE" 332 333 return super().datatype_sql(expression) 334 335 TRANSFORMS = { 336 **generator.Generator.TRANSFORMS, 337 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/every.htm 338 exp.All: rename_func("EVERY"), 339 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/bit_and.htm 340 exp.BitwiseAnd: rename_func("BIT_AND"), 341 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/bit_or.htm 342 exp.BitwiseOr: rename_func("BIT_OR"), 343 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/bit_not.htm 344 exp.BitwiseNot: rename_func("BIT_NOT"), 345 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/bit_lshift.htm 346 exp.BitwiseLeftShift: rename_func("BIT_LSHIFT"), 347 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/bit_rshift.htm 348 exp.BitwiseRightShift: rename_func("BIT_RSHIFT"), 349 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/bit_xor.htm 350 exp.BitwiseXor: rename_func("BIT_XOR"), 351 exp.CurrentSchema: lambda *_: "CURRENT_SCHEMA", 352 exp.DateDiff: _date_diff_sql, 353 exp.DateAdd: _add_date_sql, 354 exp.TsOrDsAdd: _add_date_sql, 355 exp.DateSub: _add_date_sql, 356 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/div.htm#DIV 357 exp.IntDiv: rename_func("DIV"), 358 exp.TsOrDsDiff: _date_diff_sql, 359 exp.DatetimeTrunc: timestamptrunc_sql(), 360 exp.GroupConcat: lambda self, e: groupconcat_sql(self, e, on_overflow=True), 361 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/edit_distance.htm#EDIT_DISTANCE 362 exp.Levenshtein: unsupported_args("ins_cost", "del_cost", "sub_cost", "max_dist")( 363 rename_func("EDIT_DISTANCE") 364 ), 365 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/mod.htm 366 exp.Mod: mod_func_sql, 367 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/from_posix_time.htm 368 exp.UnixToTime: lambda self, e: self.func("FROM_POSIX_TIME", e.this), 369 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/rank.htm 370 exp.Rank: unsupported_args("expressions")(lambda *_: "RANK()"), 371 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/dense_rank.htm 372 exp.DenseRank: unsupported_args("expressions")(lambda *_: "DENSE_RANK()"), 373 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/regexp_substr.htm 374 exp.RegexpExtract: unsupported_args("parameters", "group")(rename_func("REGEXP_SUBSTR")), 375 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/regexp_replace.htm 376 exp.RegexpReplace: unsupported_args("modifiers")(rename_func("REGEXP_REPLACE")), 377 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/var_pop.htm 378 exp.VariancePop: rename_func("VAR_POP"), 379 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/approximate_count_distinct.htm 380 exp.ApproxDistinct: unsupported_args("accuracy")(rename_func("APPROXIMATE_COUNT_DISTINCT")), 381 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/to_char%20(datetime).htm 382 exp.TimeToStr: lambda self, e: self.func("TO_CHAR", e.this, self.format_time(e)), 383 exp.ToChar: lambda self, e: self.func("TO_CHAR", e.this, self.format_time(e)), 384 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/to_date.htm 385 exp.TsOrDsToDate: lambda self, e: self.func("TO_DATE", e.this, self.format_time(e)), 386 exp.TimeStrToTime: timestrtotime_sql, 387 exp.TimestampTrunc: _timestamp_trunc_sql, 388 exp.StrToTime: lambda self, e: self.func("TO_DATE", e.this, self.format_time(e)), 389 exp.CurrentUser: lambda *_: "CURRENT_USER", 390 exp.AtTimeZone: lambda self, e: self.func( 391 "CONVERT_TZ", 392 e.this, 393 "'UTC'", 394 e.args.get("zone"), 395 ), 396 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/instr.htm 397 exp.StrPosition: lambda self, e: strposition_sql( 398 self, e, func_name="INSTR", supports_position=True, supports_occurrence=True 399 ), 400 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/hash_sha%5B1%5D.htm#HASH_SHA%5B1%5D 401 exp.SHA: rename_func("HASH_SHA"), 402 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/hash_sha256.htm 403 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/hash_sha512.htm 404 exp.SHA2: _sha2_sql, 405 exp.MD5: rename_func("HASH_MD5"), 406 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/hashtype_md5.htm 407 exp.MD5Digest: rename_func("HASHTYPE_MD5"), 408 # https://docs.exasol.com/db/latest/sql/create_view.htm 409 exp.CommentColumnConstraint: lambda self, e: f"COMMENT IS {self.sql(e, 'this')}", 410 exp.SubstringIndex: _substring_index_sql, 411 exp.WeekOfYear: rename_func("WEEK"), 412 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/to_date.htm 413 exp.Date: rename_func("TO_DATE"), 414 # https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/to_timestamp.htm 415 exp.Timestamp: rename_func("TO_TIMESTAMP"), 416 exp.Quarter: lambda self, e: f"CEIL(MONTH(TO_DATE({self.sql(e, 'this')}))/3)", 417 exp.LastDay: no_last_day_sql, 418 } 419 420 # https://docs.exasol.com/db/7.1/sql_references/system_tables/metadata/exa_sql_keywords.htm 421 RESERVED_KEYWORDS = { 422 "absolute", 423 "action", 424 "add", 425 "after", 426 "all", 427 "allocate", 428 "alter", 429 "and", 430 "any", 431 "append", 432 "are", 433 "array", 434 "as", 435 "asc", 436 "asensitive", 437 "assertion", 438 "at", 439 "attribute", 440 "authid", 441 "authorization", 442 "before", 443 "begin", 444 "between", 445 "bigint", 446 "binary", 447 "bit", 448 "blob", 449 "blocked", 450 "bool", 451 "boolean", 452 "both", 453 "by", 454 "byte", 455 "call", 456 "called", 457 "cardinality", 458 "cascade", 459 "cascaded", 460 "case", 461 "casespecific", 462 "cast", 463 "catalog", 464 "chain", 465 "char", 466 "character", 467 "character_set_catalog", 468 "character_set_name", 469 "character_set_schema", 470 "characteristics", 471 "check", 472 "checked", 473 "clob", 474 "close", 475 "coalesce", 476 "collate", 477 "collation", 478 "collation_catalog", 479 "collation_name", 480 "collation_schema", 481 "column", 482 "commit", 483 "condition", 484 "connect_by_iscycle", 485 "connect_by_isleaf", 486 "connect_by_root", 487 "connection", 488 "constant", 489 "constraint", 490 "constraint_state_default", 491 "constraints", 492 "constructor", 493 "contains", 494 "continue", 495 "control", 496 "convert", 497 "corresponding", 498 "create", 499 "cs", 500 "csv", 501 "cube", 502 "current", 503 "current_cluster", 504 "current_cluster_uid", 505 "current_date", 506 "current_path", 507 "current_role", 508 "current_schema", 509 "current_session", 510 "current_statement", 511 "current_time", 512 "current_timestamp", 513 "current_user", 514 "cursor", 515 "cycle", 516 "data", 517 "datalink", 518 "datetime_interval_code", 519 "datetime_interval_precision", 520 "day", 521 "dbtimezone", 522 "deallocate", 523 "dec", 524 "decimal", 525 "declare", 526 "default", 527 "default_like_escape_character", 528 "deferrable", 529 "deferred", 530 "defined", 531 "definer", 532 "delete", 533 "deref", 534 "derived", 535 "desc", 536 "describe", 537 "descriptor", 538 "deterministic", 539 "disable", 540 "disabled", 541 "disconnect", 542 "dispatch", 543 "distinct", 544 "dlurlcomplete", 545 "dlurlpath", 546 "dlurlpathonly", 547 "dlurlscheme", 548 "dlurlserver", 549 "dlvalue", 550 "do", 551 "domain", 552 "double", 553 "drop", 554 "dynamic", 555 "dynamic_function", 556 "dynamic_function_code", 557 "each", 558 "else", 559 "elseif", 560 "elsif", 561 "emits", 562 "enable", 563 "enabled", 564 "end", 565 "end-exec", 566 "endif", 567 "enforce", 568 "equals", 569 "errors", 570 "escape", 571 "except", 572 "exception", 573 "exec", 574 "execute", 575 "exists", 576 "exit", 577 "export", 578 "external", 579 "extract", 580 "false", 581 "fbv", 582 "fetch", 583 "file", 584 "final", 585 "first", 586 "float", 587 "following", 588 "for", 589 "forall", 590 "force", 591 "format", 592 "found", 593 "free", 594 "from", 595 "fs", 596 "full", 597 "function", 598 "general", 599 "generated", 600 "geometry", 601 "get", 602 "global", 603 "go", 604 "goto", 605 "grant", 606 "granted", 607 "group", 608 "group_concat", 609 "grouping", 610 "groups", 611 "hashtype", 612 "hashtype_format", 613 "having", 614 "high", 615 "hold", 616 "hour", 617 "identity", 618 "if", 619 "ifnull", 620 "immediate", 621 "impersonate", 622 "implementation", 623 "import", 624 "in", 625 "index", 626 "indicator", 627 "inner", 628 "inout", 629 "input", 630 "insensitive", 631 "insert", 632 "instance", 633 "instantiable", 634 "int", 635 "integer", 636 "integrity", 637 "intersect", 638 "interval", 639 "into", 640 "inverse", 641 "invoker", 642 "is", 643 "iterate", 644 "join", 645 "key_member", 646 "key_type", 647 "large", 648 "last", 649 "lateral", 650 "ldap", 651 "leading", 652 "leave", 653 "left", 654 "level", 655 "like", 656 "limit", 657 "listagg", 658 "localtime", 659 "localtimestamp", 660 "locator", 661 "log", 662 "longvarchar", 663 "loop", 664 "low", 665 "map", 666 "match", 667 "matched", 668 "merge", 669 "method", 670 "minus", 671 "minute", 672 "mod", 673 "modifies", 674 "modify", 675 "module", 676 "month", 677 "names", 678 "national", 679 "natural", 680 "nchar", 681 "nclob", 682 "new", 683 "next", 684 "nls_date_format", 685 "nls_date_language", 686 "nls_first_day_of_week", 687 "nls_numeric_characters", 688 "nls_timestamp_format", 689 "no", 690 "nocycle", 691 "nologging", 692 "none", 693 "not", 694 "null", 695 "nullif", 696 "number", 697 "numeric", 698 "nvarchar", 699 "nvarchar2", 700 "object", 701 "of", 702 "off", 703 "old", 704 "on", 705 "only", 706 "open", 707 "option", 708 "options", 709 "or", 710 "order", 711 "ordering", 712 "ordinality", 713 "others", 714 "out", 715 "outer", 716 "output", 717 "over", 718 "overlaps", 719 "overlay", 720 "overriding", 721 "pad", 722 "parallel_enable", 723 "parameter", 724 "parameter_specific_catalog", 725 "parameter_specific_name", 726 "parameter_specific_schema", 727 "parquet", 728 "partial", 729 "path", 730 "permission", 731 "placing", 732 "plus", 733 "preceding", 734 "preferring", 735 "prepare", 736 "preserve", 737 "prior", 738 "privileges", 739 "procedure", 740 "profile", 741 "qualify", 742 "random", 743 "range", 744 "read", 745 "reads", 746 "real", 747 "recovery", 748 "recursive", 749 "ref", 750 "references", 751 "referencing", 752 "refresh", 753 "regexp_like", 754 "relative", 755 "release", 756 "rename", 757 "repeat", 758 "replace", 759 "restore", 760 "restrict", 761 "result", 762 "return", 763 "returned_length", 764 "returned_octet_length", 765 "returns", 766 "revoke", 767 "right", 768 "rollback", 769 "rollup", 770 "routine", 771 "row", 772 "rows", 773 "rowtype", 774 "savepoint", 775 "schema", 776 "scope", 777 "scope_user", 778 "script", 779 "scroll", 780 "search", 781 "second", 782 "section", 783 "security", 784 "select", 785 "selective", 786 "self", 787 "sensitive", 788 "separator", 789 "sequence", 790 "session", 791 "session_user", 792 "sessiontimezone", 793 "set", 794 "sets", 795 "shortint", 796 "similar", 797 "smallint", 798 "some", 799 "source", 800 "space", 801 "specific", 802 "specifictype", 803 "sql", 804 "sql_bigint", 805 "sql_bit", 806 "sql_char", 807 "sql_date", 808 "sql_decimal", 809 "sql_double", 810 "sql_float", 811 "sql_integer", 812 "sql_longvarchar", 813 "sql_numeric", 814 "sql_preprocessor_script", 815 "sql_real", 816 "sql_smallint", 817 "sql_timestamp", 818 "sql_tinyint", 819 "sql_type_date", 820 "sql_type_timestamp", 821 "sql_varchar", 822 "sqlexception", 823 "sqlstate", 824 "sqlwarning", 825 "start", 826 "state", 827 "statement", 828 "static", 829 "structure", 830 "style", 831 "substring", 832 "subtype", 833 "sysdate", 834 "system", 835 "system_user", 836 "systimestamp", 837 "table", 838 "temporary", 839 "text", 840 "then", 841 "time", 842 "timestamp", 843 "timezone_hour", 844 "timezone_minute", 845 "tinyint", 846 "to", 847 "trailing", 848 "transaction", 849 "transform", 850 "transforms", 851 "translation", 852 "treat", 853 "trigger", 854 "trim", 855 "true", 856 "truncate", 857 "under", 858 "union", 859 "unique", 860 "unknown", 861 "unlink", 862 "unnest", 863 "until", 864 "update", 865 "usage", 866 "user", 867 "using", 868 "value", 869 "values", 870 "varchar", 871 "varchar2", 872 "varray", 873 "verify", 874 "view", 875 "when", 876 "whenever", 877 "where", 878 "while", 879 "window", 880 "with", 881 "within", 882 "without", 883 "work", 884 "year", 885 "yes", 886 "zone", 887 } 888 889 def converttimezone_sql(self, expression: exp.ConvertTimezone) -> str: 890 from_tz = expression.args.get("source_tz") 891 to_tz = expression.args.get("target_tz") 892 datetime = expression.args.get("timestamp") 893 options = expression.args.get("options") 894 895 return self.func("CONVERT_TZ", datetime, from_tz, to_tz, options) 896 897 def if_sql(self, expression: exp.If) -> str: 898 this = self.sql(expression, "this") 899 true = self.sql(expression, "true") 900 false = self.sql(expression, "false") 901 return f"IF {this} THEN {true} ELSE {false} ENDIF" 902 903 # https://docs.exasol.com/db/latest/sql/open_schema.htm 904 def use_sql(self, expression: exp.Use) -> str: 905 kind = expression.args.get("kind") 906 if kind and self.sql(kind).upper() != "SCHEMA": 907 self.unsupported(f"'USE {self.sql(kind)}' is not supported in Exasol") 908 return super().use_sql(expression) 909 this = self.sql(expression, "this") 910 return f"OPEN SCHEMA {this}" 911 912 # https://docs.exasol.com/db/latest/sql_references/metadata/metadata_system_tables.htm 913 def show_sql(self, expression: exp.Show) -> str: 914 if expression.name == "TABLES": 915 db_name = expression.text("db") 916 schema_filter: exp.Expression = ( 917 exp.Literal.string(db_name.upper()) if db_name else exp.CurrentSchema() 918 ) 919 select = ( 920 exp.select(exp.column("TABLE_NAME")) 921 .from_(exp.table_("EXA_ALL_TABLES", db="SYS")) 922 .where(exp.column("TABLE_SCHEMA").eq(schema_filter)) 923 ) 924 return self.sql(select) 925 926 if expression.name == "DATABASES": 927 select = exp.select(exp.column("SCHEMA_NAME")).from_( 928 exp.table_("EXA_SCHEMAS", db="SYS") 929 ) 930 return self.sql(select) 931 932 return super().show_sql(expression) 933 934 def collate_sql(self, expression: exp.Collate) -> str: 935 return self.sql(expression.this) 936 937 def jsonextract_sql(self, expression: exp.JSONExtract) -> str: 938 sql = self.func( 939 "JSON_EXTRACT", expression.this, expression.expression, *expression.expressions 940 ) 941 942 emits = self.sql(expression, "emits") 943 if emits: 944 sql = f"{sql} EMITS {emits}" 945 946 return sql 947 948 @unsupported_args("flag") 949 def regexplike_sql(self, expression: exp.RegexpLike) -> str: 950 if not expression.args.get("full_match"): 951 pattern = expression.expression 952 if pattern.is_string: 953 expression.set("expression", exp.Literal.string(f".*{pattern.name}.*")) 954 else: 955 expression.set( 956 "expression", 957 exp.Paren( 958 this=exp.Concat( 959 expressions=[ 960 exp.Literal.string(".*"), 961 pattern, 962 exp.Literal.string(".*"), 963 ] 964 ) 965 ), 966 ) 967 return self.binary(expression, "REGEXP_LIKE")
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: Always quote except for specials cases. '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
WHEREclause. 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
STRING_TYPE_MAPPING: ClassVar =
{<DType.BLOB: 'BLOB'>: 'VARCHAR', <DType.LONGBLOB: 'LONGBLOB'>: 'VARCHAR', <DType.LONGTEXT: 'LONGTEXT'>: 'VARCHAR', <DType.MEDIUMBLOB: 'MEDIUMBLOB'>: 'VARCHAR', <DType.MEDIUMTEXT: 'MEDIUMTEXT'>: 'VARCHAR', <DType.TINYBLOB: 'TINYBLOB'>: 'VARCHAR', <DType.TINYTEXT: 'TINYTEXT'>: 'VARCHAR', <DType.TEXT: 'TEXT'>: 'LONG VARCHAR', <DType.VARBINARY: 'VARBINARY'>: 'VARCHAR'}
TYPE_MAPPING =
{<DType.DATETIME2: 'DATETIME2'>: 'TIMESTAMP', <DType.NCHAR: 'NCHAR'>: 'CHAR', <DType.NVARCHAR: 'NVARCHAR'>: 'VARCHAR', <DType.MEDIUMTEXT: 'MEDIUMTEXT'>: 'VARCHAR', <DType.LONGTEXT: 'LONGTEXT'>: 'VARCHAR', <DType.TINYTEXT: 'TINYTEXT'>: 'VARCHAR', <DType.BLOB: 'BLOB'>: 'VARCHAR', <DType.MEDIUMBLOB: 'MEDIUMBLOB'>: 'VARCHAR', <DType.LONGBLOB: 'LONGBLOB'>: 'VARCHAR', <DType.TINYBLOB: 'TINYBLOB'>: 'VARCHAR', <DType.INET: 'INET'>: 'INET', <DType.ROWVERSION: 'ROWVERSION'>: 'VARBINARY', <DType.SMALLDATETIME: 'SMALLDATETIME'>: 'TIMESTAMP', <DType.TEXT: 'TEXT'>: 'LONG VARCHAR', <DType.VARBINARY: 'VARBINARY'>: 'VARCHAR', <DType.TINYINT: 'TINYINT'>: 'SMALLINT', <DType.MEDIUMINT: 'MEDIUMINT'>: 'INT', <DType.DECIMAL32: 'DECIMAL32'>: 'DECIMAL', <DType.DECIMAL64: 'DECIMAL64'>: 'DECIMAL', <DType.DECIMAL128: 'DECIMAL128'>: 'DECIMAL', <DType.DECIMAL256: 'DECIMAL256'>: 'DECIMAL', <DType.DATETIME: 'DATETIME'>: 'TIMESTAMP', <DType.TIMESTAMPTZ: 'TIMESTAMPTZ'>: 'TIMESTAMP', <DType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>: 'TIMESTAMP', <DType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>: 'TIMESTAMP'}
308 def datetrunc_sql(self, expression: exp.DateTrunc) -> str: 309 if isinstance(expression.unit, exp.WeekStart) or expression.unit.name in ( 310 "CENTURY", 311 "WEEK_OF_MONTH", 312 "WEEK_OF_YEAR", 313 "ISOYEAR", 314 ): 315 return date_trunc_to_trunc_sql(self, expression) 316 return _trunc_sql(self, "DATE", expression)
327 def datatype_sql(self, expression: exp.DataType) -> str: 328 # Exasol supports a fixed default precision of 3 for TIMESTAMP WITH LOCAL TIME ZONE 329 # and does not allow specifying a different custom precision 330 if expression.is_type(exp.DType.TIMESTAMPLTZ): 331 return "TIMESTAMP WITH LOCAL TIME ZONE" 332 333 return super().datatype_sql(expression)
TRANSFORMS =
{<class 'sqlglot.expressions.query.JSONPathFilter'>: <function <lambda>>, <class 'sqlglot.expressions.query.JSONPathKey'>: <function <lambda>>, <class 'sqlglot.expressions.query.JSONPathRecursive'>: <function <lambda>>, <class 'sqlglot.expressions.query.JSONPathRoot'>: <function <lambda>>, <class 'sqlglot.expressions.query.JSONPathScript'>: <function <lambda>>, <class 'sqlglot.expressions.query.JSONPathSelector'>: <function <lambda>>, <class 'sqlglot.expressions.query.JSONPathSlice'>: <function <lambda>>, <class 'sqlglot.expressions.query.JSONPathSubscript'>: <function <lambda>>, <class 'sqlglot.expressions.query.JSONPathUnion'>: <function <lambda>>, <class 'sqlglot.expressions.query.JSONPathWildcard'>: <function <lambda>>, <class 'sqlglot.expressions.core.Adjacent'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.AllowedValuesProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.AnalyzeColumns'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.AnalyzeWith'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.array.ArrayContainedBy'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.array.ArrayContainsAll'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.array.ArrayOverlaps'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.AssumeColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.AutoRefreshProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.BackupProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.BinaryColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.CaseSpecificColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.CalledOnNullInputProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.math.Ceil'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.CharacterSetColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.CharacterSetProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.ClusteredColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.CollateColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.CommentColumnConstraint'>: <function ExasolGenerator.<lambda>>, <class 'sqlglot.expressions.functions.ConnectByRoot'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.string.ConvertToCharset'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.CopyGrantsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.CopyTagsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.CredentialsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.functions.CurrentCatalog'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.functions.SessionUser'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.DateFormatColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.DefaultColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ApiProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ApplicationProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.CatalogProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ComputeProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.DatabaseProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.DynamicProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.EmptyProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.EncodeColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.EndStatement'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.EnviromentProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.HandlerProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ParameterStyleProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.EphemeralColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.ExcludeColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ExecuteAsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.Except'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ExternalProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.math.Floor'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.Get'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.GlobalProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.HeapProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.HybridProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.IcebergProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.IgnoreGrantsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.InheritsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.InlineLengthColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.InputModelProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.Intersect'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.datatypes.IntervalSpan'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.functions.Int64'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.json.JSONBContainsAnyTopKeys'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.json.JSONBContainsAllTopKeys'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.json.JSONBContainsTopKey'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.json.JSONBDeleteAtPath'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.json.JSONBPathExists'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.json.JSONObject'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.json.JSONObjectAgg'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.LanguageProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.LocationProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.LogProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.MaskingProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.MaterializedProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.functions.NetFunc'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.NetworkProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.NonClusteredColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.NoPrimaryIndexProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.NotForReplicationColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.OnCommitProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.OnProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.OnUpdateColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.core.Operator'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.OutputModelProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.core.ExtendsLeft'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.core.ExtendsRight'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.PathColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.PartitionedByBucket'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.PartitionByTruncate'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.core.PivotAny'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.array.PositionalColumn'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.ProjectionPolicyColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.InvisibleColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.ZeroFillColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.Put'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.RemoteWithConnectionModelProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ReturnsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.RowAccessProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.core.SafeFunc'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SampleProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SecureProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SecurityIntegrationProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SetConfigProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SetProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SettingsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SharingProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SqlReadWriteProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SqlSecurityProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.StabilityProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.Stream'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.StreamingTableProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.StrictProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ddl.SwapTable'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.TableColumn'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.Tags'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.TemporaryProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.TitleColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.array.ToMap'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ToTableProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.TransformModelProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.TransientProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.VirtualProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ddl.TriggerExecute'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.Union'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.UnloggedProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.UsingTemplateProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.UsingData'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.UppercaseColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.temporal.UtcDate'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.temporal.UtcTime'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.temporal.UtcTimestamp'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.Variadic'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.array.VarMap'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ViewAttributeProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.VolatileProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.WithJournalTableProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.WithProcedureOptions'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.WithSchemaBindingProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.WithOperator'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.WithoutRowidProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ForceProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.core.All'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.core.BitwiseAnd'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.core.BitwiseOr'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.core.BitwiseNot'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.core.BitwiseLeftShift'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.core.BitwiseRightShift'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.core.BitwiseXor'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.functions.CurrentSchema'>: <function ExasolGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.DateDiff'>: <function _date_diff_sql>, <class 'sqlglot.expressions.temporal.DateAdd'>: <function _add_date_sql>, <class 'sqlglot.expressions.temporal.TsOrDsAdd'>: <function _add_date_sql>, <class 'sqlglot.expressions.temporal.DateSub'>: <function _add_date_sql>, <class 'sqlglot.expressions.core.IntDiv'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.TsOrDsDiff'>: <function _date_diff_sql>, <class 'sqlglot.expressions.temporal.DatetimeTrunc'>: <function timestamptrunc_sql.<locals>._timestamptrunc_sql>, <class 'sqlglot.expressions.aggregate.GroupConcat'>: <function ExasolGenerator.<lambda>>, <class 'sqlglot.expressions.string.Levenshtein'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.core.Mod'>: <function mod_func_sql>, <class 'sqlglot.expressions.temporal.UnixToTime'>: <function ExasolGenerator.<lambda>>, <class 'sqlglot.expressions.aggregate.Rank'>: <function ExasolGenerator.<lambda>>, <class 'sqlglot.expressions.aggregate.DenseRank'>: <function ExasolGenerator.<lambda>>, <class 'sqlglot.expressions.string.RegexpExtract'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.string.RegexpReplace'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.aggregate.VariancePop'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.core.ApproxDistinct'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.TimeToStr'>: <function ExasolGenerator.<lambda>>, <class 'sqlglot.expressions.string.ToChar'>: <function ExasolGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.TsOrDsToDate'>: <function ExasolGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.TimeStrToTime'>: <function timestrtotime_sql>, <class 'sqlglot.expressions.temporal.TimestampTrunc'>: <function _timestamp_trunc_sql>, <class 'sqlglot.expressions.temporal.StrToTime'>: <function ExasolGenerator.<lambda>>, <class 'sqlglot.expressions.functions.CurrentUser'>: <function ExasolGenerator.<lambda>>, <class 'sqlglot.expressions.core.AtTimeZone'>: <function ExasolGenerator.<lambda>>, <class 'sqlglot.expressions.string.StrPosition'>: <function ExasolGenerator.<lambda>>, <class 'sqlglot.expressions.string.SHA'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.string.SHA2'>: <function _sha2_sql>, <class 'sqlglot.expressions.string.MD5'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.string.MD5Digest'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.string.SubstringIndex'>: <function _substring_index_sql>, <class 'sqlglot.expressions.temporal.WeekOfYear'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.Date'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.Timestamp'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.Quarter'>: <function ExasolGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.LastDay'>: <function no_last_day_sql>}
RESERVED_KEYWORDS =
{'real', 'locator', 'permission', 'merge', 'sessiontimezone', 'minute', 'bool', 'sqlwarning', 'sql_numeric', 'inout', 'float', 'options', 'output', 'system', 'specifictype', 'references', 'domain', 'desc', 'where', 'char', 'enable', 'nclob', 'sql_bigint', 'escape', 'character_set_catalog', 'work', 'instantiable', 'dlvalue', 'index', 'similar', 'deallocate', 'sql_timestamp', 'zone', 'schema', 'restrict', 'decimal', 'default_like_escape_character', 'asensitive', 'any', 'binary', 'translation', 'as', 'rows', 'append', 'bit', 'security', 'checked', 'nologging', 'returned_length', 'low', 'order', 'null', 'boolean', 'rowtype', 'elsif', 'system_user', 'blocked', 'check', 'window', 'unknown', 'replace', 'time', 'connect_by_isleaf', 'mod', 'nls_numeric_characters', 'sql_decimal', 'nls_first_day_of_week', 'loop', 'export', 'of', 'by', 'goto', 'current_session', 'first', 'dbtimezone', 'begin', 'into', 'dispatch', 'cycle', 'grant', 'current', 'section', 'scope_user', 'derived', 'overriding', 'rollup', 'parallel_enable', 'sqlexception', 'until', 'implementation', 'lateral', 'parameter_specific_schema', 'treat', 'large', 'character', 'session', 'sql_type_date', 'insert', 'overlaps', 'localtimestamp', 'fs', 'connect_by_root', 'after', 'emits', 'at', 'integer', 'clob', 'static', 'transforms', 'collation', 'do', 'sensitive', 'errors', 'key_type', 'sqlstate', 'relative', 'full', 'to', 'using', 'deferrable', 'off', 'longvarchar', 'referencing', 'from', 'allocate', 'continue', 'dynamic', 'scroll', 'default', 'int', 'end', 'recursive', 'inner', 'exit', 'ifnull', 'chain', 'reads', 'geometry', 'module', 'verify', 'action', 'out', 'level', 'current_statement', 'release', 'natural', 'select', 'attribute', 'authid', 'space', 'recovery', 'generated', 'option', 'sql_varchar', 'unlink', 'varchar2', 'byte', 'constructor', 'cast', 'true', 'cube', 'get', 'characteristics', 'contains', 'on', 'like', 'defined', 'cursor', 'constraint_state_default', 'number', 'and', 'separator', 'extract', 'hashtype_format', 'alter', 'old', 'savepoint', 'descriptor', 'coalesce', 'group_concat', 'rollback', 'datalink', 'map', 'profile', 'between', 'csv', 'enforce', 'sql_float', 'dlurlcomplete', 'except', 'national', 'nls_date_language', 'returns', 'qualify', 'leave', 'varchar', 'catalog', 'new', 'global', 'value', 'create', 'dlurlpath', 'data', 'nullif', 'nocycle', 'return', 'dlurlpathonly', 'deref', 'insensitive', 'systimestamp', 'partial', 'without', 'range', 'matched', 'current_cluster_uid', 'with', 'restore', 'groups', 'dec', 'control', 'all', 'general', 'update', 'current_date', 'for', 'year', 'others', 'parquet', 'union', 'ref', 'plus', 'day', 'sql_type_timestamp', 'path', 'numeric', 'disable', 'following', 'user', 'cs', 'dynamic_function', 'some', 'cascade', 'disabled', 'under', 'returned_octet_length', 'rename', 'invoker', 'routine', 'ordinality', 'file', 'or', 'intersect', 'shortint', 'pad', 'minus', 'is', 'preserve', 'outer', 'deferred', 'disconnect', 'temporary', 'ordering', 'both', 'view', 'sql_preprocessor_script', 'modifies', 'found', 'refresh', 'trigger', 'call', 'distinct', 'exec', 'state', 'current_schema', 'preceding', 'current_timestamp', 'sql_real', 'dynamic_function_code', 'external', 'nls_timestamp_format', 'self', 'sql_smallint', 'localtime', 'collation_catalog', 'character_set_name', 'constraints', 'datetime_interval_code', 'asc', 'parameter', 'column', 'sql_char', 'sysdate', 'end-exec', 'constant', 'input', 'elseif', 'sets', 'leading', 'enabled', 'open', 'overlay', 'modify', 'deterministic', 'iterate', 'bigint', 'truncate', 'read', 'sql_double', 'immediate', 'right', 'nchar', 'no', 'values', 'function', 'having', 'procedure', 'preferring', 'varray', 'prior', 'cascaded', 'final', 'current_cluster', 'tinyint', 'false', 'sql_bit', 'revoke', 'unique', 'left', 'character_set_schema', 'result', 'regexp_like', 'repeat', 'timestamp', 'go', 'timezone_hour', 'trailing', 'array', 'session_user', 'declare', 'high', 'identity', 'format', 'double', 'execute', 'then', 'smallint', 'equals', 'instance', 'privileges', 'style', 'log', 'nvarchar2', 'hashtype', 'limit', 'are', 'last', 'sequence', 'commit', 'set', 'sql', 'granted', 'forall', 'delete', 'definer', 'transaction', 'endif', 'random', 'month', 'whenever', 'none', 'describe', 'exception', 'when', 'in', 'exists', 'join', 'current_user', 'ldap', 'scope', 'collate', 'hold', 'dlurlserver', 'impersonate', 'nls_date_format', 'placing', 'import', 'current_role', 'fetch', 'absolute', 'sql_date', 'inverse', 'sql_longvarchar', 'text', 'within', 'hour', 'search', 'next', 'fbv', 'selective', 'datetime_interval_precision', 'close', 'source', 'trim', 'key_member', 'script', 'before', 'method', 'dlurlscheme', 'authorization', 'object', 'start', 'convert', 'each', 'collation_schema', 'cardinality', 'condition', 'indicator', 'unnest', 'connect_by_iscycle', 'blob', 'while', 'prepare', 'else', 'integrity', 'names', 'current_path', 'usage', 'case', 'only', 'timezone_minute', 'match', 'parameter_specific_catalog', 'not', 'structure', 'transform', 'constraint', 'group', 'sql_integer', 'grouping', 'specific', 'substring', 'if', 'current_time', 'parameter_specific_name', 'table', 'subtype', 'called', 'interval', 'second', 'over', 'force', 'casespecific', 'free', 'nvarchar', 'row', 'sql_tinyint', 'connection', 'assertion', 'collation_name', 'drop', 'listagg', 'add', 'statement', 'yes', 'corresponding'}
889 def converttimezone_sql(self, expression: exp.ConvertTimezone) -> str: 890 from_tz = expression.args.get("source_tz") 891 to_tz = expression.args.get("target_tz") 892 datetime = expression.args.get("timestamp") 893 options = expression.args.get("options") 894 895 return self.func("CONVERT_TZ", datetime, from_tz, to_tz, options)
904 def use_sql(self, expression: exp.Use) -> str: 905 kind = expression.args.get("kind") 906 if kind and self.sql(kind).upper() != "SCHEMA": 907 self.unsupported(f"'USE {self.sql(kind)}' is not supported in Exasol") 908 return super().use_sql(expression) 909 this = self.sql(expression, "this") 910 return f"OPEN SCHEMA {this}"
913 def show_sql(self, expression: exp.Show) -> str: 914 if expression.name == "TABLES": 915 db_name = expression.text("db") 916 schema_filter: exp.Expression = ( 917 exp.Literal.string(db_name.upper()) if db_name else exp.CurrentSchema() 918 ) 919 select = ( 920 exp.select(exp.column("TABLE_NAME")) 921 .from_(exp.table_("EXA_ALL_TABLES", db="SYS")) 922 .where(exp.column("TABLE_SCHEMA").eq(schema_filter)) 923 ) 924 return self.sql(select) 925 926 if expression.name == "DATABASES": 927 select = exp.select(exp.column("SCHEMA_NAME")).from_( 928 exp.table_("EXA_SCHEMAS", db="SYS") 929 ) 930 return self.sql(select) 931 932 return super().show_sql(expression)
@unsupported_args('flag')
def
regexplike_sql(self, expression: sqlglot.expressions.core.RegexpLike) -> str:
948 @unsupported_args("flag") 949 def regexplike_sql(self, expression: exp.RegexpLike) -> str: 950 if not expression.args.get("full_match"): 951 pattern = expression.expression 952 if pattern.is_string: 953 expression.set("expression", exp.Literal.string(f".*{pattern.name}.*")) 954 else: 955 expression.set( 956 "expression", 957 exp.Paren( 958 this=exp.Concat( 959 expressions=[ 960 exp.Literal.string(".*"), 961 pattern, 962 exp.Literal.string(".*"), 963 ] 964 ) 965 ), 966 ) 967 return self.binary(expression, "REGEXP_LIKE")
Inherited Members
- sqlglot.generator.Generator
- Generator
- NULL_ORDERING_SUPPORTED
- WINDOW_FUNCS_WITH_NULL_ORDERING
- WINDOW_FUNCS_REQUIRING_ORDER
- IGNORE_NULLS_IN_FUNC
- IGNORE_NULLS_BEFORE_ORDER
- LOCKING_READS_SUPPORTED
- EXCEPT_INTERSECT_SUPPORT_ALL_CLAUSE
- WRAP_DERIVED_VALUES
- CREATE_FUNCTION_RETURN_AS
- MATCHED_BY_SOURCE
- SUPPORTS_MERGE_WHERE
- MERGE_SCHEMA_EVOLUTION_MIN_VERSION
- MERGE_ALL_BY_NAME
- SINGLE_STRING_INTERVAL
- INTERVAL_ALLOWS_PLURAL_FORM
- AUTO_REFRESH_BARE_INTERVALS
- LIMIT_FETCH
- LIMIT_ONLY_LITERALS
- RENAME_TABLE_WITH_DB
- GROUPINGS_SEP
- SUPPORTS_GROUPING_SETS_AS_SUFFIX
- INDEX_ON
- INOUT_SEPARATOR
- JOIN_HINTS
- DIRECTED_JOINS
- SUPPORTS_NEAREST_JOIN
- SUPPORTS_MATCH_CONDITION
- MATCH_CONDITION_IN_ON
- TABLE_HINTS
- QUERY_HINTS
- QUERY_HINT_SEP
- IS_BOOL_ALLOWED
- CAST_TO_INT_ROUNDS
- SAFE_INT_DIVISION
- INT_DIV_OPERATOR
- DUPLICATE_KEY_UPDATE_WITH_SET
- LIMIT_IS_TOP
- RETURNING_END
- EXTRACT_ALLOWS_QUOTES
- TZ_TO_WITH_TIME_ZONE
- NVL2_SUPPORTED
- VALUES_AS_TABLE
- ALTER_TABLE_INCLUDE_COLUMN_KEYWORD
- ALTER_TABLE_ADD_COLUMNS_WRAPPED
- UNNEST_WITH_ORDINALITY
- 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
- HISTORICAL_DATA_POST_ALIAS
- COLLATE_IS_FUNC
- ENSURE_BOOLS
- CTE_RECURSIVE_KEYWORD_REQUIRED
- SUPPORTS_SINGLE_ARG_CONCAT
- LAST_DAY_SUPPORTS_DATE_PART
- SUPPORTS_TABLE_ALIAS_COLUMNS
- SUPPORTS_NAMED_CTE_COLUMNS
- UNPIVOT_ALIASES_ARE_IDENTIFIERS
- PIVOT_ALIAS_WITH_AS
- JSON_KEY_VALUE_PAIR_SEP
- INSERT_OVERWRITE
- SUPPORTS_SELECT_INTO
- SUPPORTS_OPTIMIZE
- SUPPORTS_EXECUTE_IMMEDIATE
- SUPPORTS_UNLOGGED_TABLES
- SUPPORTS_CREATE_TABLE_LIKE
- SUPPORTS_MODIFY_COLUMN
- SUPPORTS_CHANGE_COLUMN
- SUPPORTS_ALTER_COLUMN_NULLABILITY
- SUPPORTS_ALTER_COLUMN_IF_EXISTS
- LIKE_PROPERTY_INSIDE_SCHEMA
- MULTI_ARG_DISTINCT
- JSON_TYPE_REQUIRED_FOR_EXTRACTION
- SUPPORTS_NESTED_JSON_SELECT
- JSON_PATH_BRACKETED_KEY_SUPPORTED
- JSON_PATH_SINGLE_QUOTE_ESCAPE
- JSON_PATH_KEY_QUOTED_FORCES_BRACKETS
- SUPPORTED_JSON_PATH_PARTS
- CAN_IMPLEMENT_ARRAY_ANY
- SUPPORTS_TO_NUMBER
- SUPPORTS_WINDOW_EXCLUDE
- SET_OP_MODIFIERS
- SET_OP_LIMITS
- SET_OP_PARENTHESIZED_OPERANDS
- COPY_PARAMS_ARE_WRAPPED
- COPY_PARAMS_EQ_REQUIRED
- COPY_HAS_INTO_KEYWORD
- UNICODE_SUBSTITUTE
- STAR_EXCEPT
- HEX_FUNC
- BYTE_STRING_FUNCTION
- WITH_PROPERTIES_PREFIX
- QUOTE_JSON_PATH
- PAD_FILL_PATTERN_IS_REQUIRED
- SUPPORTS_EXPLODING_PROJECTIONS
- ARRAY_CONCAT_IS_VAR_LEN
- SUPPORTS_CONVERT_TIMEZONE
- SUPPORTS_MEDIAN
- SUPPORTS_UNIX_SECONDS
- ALTER_SET_WRAPPED
- NORMALIZE_EXTRACT_DATE_PARTS
- PARSE_JSON_NAME
- ARRAY_SIZE_NAME
- DAYOFWEEK_NAME
- DAYOFWEEK_ZERO_BASED
- VARIANCE_NAME
- VARIANCE_RETURNS_ZERO_ON_SINGLE_VALUE
- ALTER_SET_TYPE
- ARRAY_SIZE_DIM_REQUIRED
- SUPPORTS_MULTI_ARG_CHR
- SUPPORTS_BETWEEN_FLAGS
- SUPPORTS_LIKE_QUANTIFIERS
- MATCH_AGAINST_TABLE_PREFIX
- SET_ASSIGNMENT_REQUIRES_VARIABLE_KEYWORD
- DECLARE_DEFAULT_ASSIGNMENT
- UPDATE_STATEMENT_SUPPORTS_FROM
- STAR_EXCLUDE_REQUIRES_DERIVED_TABLE
- SUPPORTS_DROP_ALTER_ICEBERG_PROPERTY
- UNSUPPORTED_TYPES
- TYPE_PARAM_SETTINGS
- TIME_PART_SINGULARS
- TOKEN_MAPPING
- STRUCT_DELIMITER
- PARAMETER_TOKEN
- NAMED_PLACEHOLDER_TOKEN
- EXPRESSION_PRECEDES_PROPERTIES_CREATABLES
- PROPERTIES_LOCATION
- WITH_SEPARATED_COMMENTS
- EXCLUDE_COMMENTS
- UNWRAPPED_INTERVAL_VALUES
- PARAMETERIZABLE_TEXT_TYPES
- EXPRESSIONS_WITHOUT_NESTED_CTES
- RESPECT_IGNORE_NULLS_UNSUPPORTED_EXPRESSIONS
- MOD_OPERATOR
- BARE_OPERATORS
- MOD_PAREN_PARENT_TYPES
- ALTER_PARTITION_OPTIONS
- 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
- pseudocolumn_sql
- columnposition_sql
- columndef_sql
- columnconstraint_sql
- computedcolumnconstraint_sql
- autoincrementcolumnconstraint_sql
- compresscolumnconstraint_sql
- generatedasidentitycolumnconstraint_sql
- generatedasrowcolumnconstraint_sql
- periodforsystemtimeconstraint_sql
- notnullcolumnconstraint_sql
- primarykeycolumnconstraint_sql
- uniquecolumnconstraint_sql
- inoutcolumnconstraint_sql
- createable_sql
- create_sql
- sequenceproperties_sql
- triggerproperties_sql
- triggerreferencing_sql
- triggerevent_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
- datatype_param_bound_limiter
- directory_sql
- delete_sql
- drop_sql
- set_operation
- set_operations
- fetch_sql
- limitoptions_sql
- filter_sql
- per_sql
- hint_sql
- indexparameters_sql
- index_sql
- dynamicidentifier_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
- uuidproperty_sql
- likeproperty_sql
- fallbackproperty_sql
- journalproperty_sql
- freespaceproperty_sql
- checksumproperty_sql
- mergeblockratioproperty_sql
- moduleproperty_sql
- datablocksizeproperty_sql
- blockcompressionproperty_sql
- isolatedloadingproperty_sql
- partitionboundspec_sql
- partitionedofproperty_sql
- lockingproperty_sql
- lockingstatement_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
- tableargument_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
- rollupindex_sql
- rollupproperty_sql
- cube_sql
- group_sql
- having_sql
- connectto_sql
- disconnect_sql
- connect_sql
- prior_sql
- join_sql
- nearest_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
- booland_sql
- boolor_sql
- order_sql
- withfill_sql
- cluster_sql
- clusterproperty_sql
- distribute_sql
- sort_sql
- ordered_sql
- matchrecognizemeasure_sql
- matchrecognize_sql
- query_modifiers
- options_modifier
- forclause_sql
- queryoption_sql
- offset_limit_modifiers
- after_limit_modifiers
- 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
- partitionbyexcluding_sql
- windowspec_sql
- withingroup_sql
- between_sql
- bracket_offset_expressions
- bracket_sql
- all_sql
- any_sql
- exists_sql
- case_sql
- constraint_sql
- nextvaluefor_sql
- dayofweek_sql
- extract_date_part
- extract_sql
- trim_sql
- convert_concat_args
- concat_sql
- concatws_sql
- check_sql
- foreignkey_sql
- primarykey_sql
- timeserieskey_sql
- matchagainst_sql
- jsonkeyvalue_sql
- jsonpath_sql
- json_path_part
- format_sql
- formatjson_sql
- formatphrase_sql
- teradataconversion_sql
- teradatatitle_sql
- teradatanamed_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
- pos_sql
- neg_sql
- not_sql
- alias_sql
- pivotalias_sql
- aliases_sql
- atindex_sql
- attimezone_sql
- fromtimezone_sql
- fromiso8601date_sql
- fromiso8601timestamp_sql
- fromiso8601timestampnanos_sql
- add_sql
- and_sql
- or_sql
- xor_sql
- connector_sql
- bitwiseand_sql
- bitwiseleftshift_sql
- bitwisenot_sql
- bitwiseor_sql
- bitwiserightshift_sql
- bitwisexor_sql
- cast_sql
- strtotime_sql
- strtodate_sql
- parsedatetime_sql
- currentdate_sql
- command_sql
- optimize_sql
- comment_sql
- mergetreettlaction_sql
- mergetreettl_sql
- transaction_sql
- commit_sql
- rollback_sql
- altercolumn_sql
- modifycolumn_sql
- alterindex_sql
- alterdiststyle_sql
- altersortkey_sql
- alterrename_sql
- renamecolumn_sql
- alterset_sql
- alter_sql
- altersession_sql
- add_column_sql
- droppartition_sql
- dropprimarykey_sql
- addconstraint_sql
- replacecolumns_sql
- addpartition_sql
- distinct_sql
- ignorenulls_sql
- respectnulls_sql
- havingmax_sql
- intdiv_sql
- dpipe_sql
- nullif_zero_divisor
- div_sql
- safedivide_sql
- overlaps_sql
- distance_sql
- distancend_sql
- dot_sql
- nestedjsonselect_sql
- eq_sql
- propertyeq_sql
- escape_sql
- glob_sql
- gt_sql
- gte_sql
- is_sql
- like_sql
- ilike_sql
- match_sql
- similarto_sql
- lt_sql
- lte_sql
- mod_sql
- mul_sql
- neq_sql
- nullsafeeq_sql
- nullsafeneq_sql
- sub_sql
- trycast_sql
- jsoncast_sql
- try_sql
- log_sql
- binary
- ceil_floor
- function_fallback_sql
- function_name
- func
- format_args
- too_wide
- format_time
- expressions
- op_expressions
- naked_property
- tag_sql
- token_sql
- userdefinedfunction_sql
- macrooverloads_sql
- macrooverload_sql
- joinhint_sql
- kwarg_sql
- when_sql
- whens_sql
- merge_sql
- tochar_sql
- tonumber_sql
- dictproperty_sql
- dictrange_sql
- dictsubproperty_sql
- aggregatekeyproperty_sql
- duplicatekeyproperty_sql
- uniquekeyproperty_sql
- distributedbyproperty_sql
- oncluster_sql
- clusteredbyproperty_sql
- anyvalue_sql
- querytransform_sql
- indexconstraintoption_sql
- checkcolumnconstraint_sql
- indexcolumnconstraint_sql
- nvl2_sql
- nthvalue_sql
- comprehension_sql
- columnprefix_sql
- opclass_sql
- predict_sql
- generateembedding_sql
- generatetext_sql
- generatetable_sql
- generatebool_sql
- generateint_sql
- generatedouble_sql
- mltranslate_sql
- mlforecast_sql
- aiforecast_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
- arrayinsert_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
- json_sql
- jsonvalue_sql
- skipjsoncolumn_sql
- conditionalinsert_sql
- multitableinserts_sql
- oncondition_sql
- jsonextractquote_sql
- jsonexists_sql
- min_sql
- max_sql
- arrayagg_sql
- timeslice_sql
- slice_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
- arraysort_sql
- variance_sql
- arraysize_sql
- attach_sql
- detach_sql
- attachoption_sql
- watermarkcolumnconstraint_sql
- encodeproperty_sql
- includeproperty_sql
- xmlelement_sql
- xmlkeyvalueoption_sql
- partitionbyrangeproperty_sql
- partitionbyrangepropertydynamic_sql
- unpivotcolumns_sql
- analyzesample_sql
- analyzestatistics_sql
- analyzehistogram_sql
- analyzedelete_sql
- analyzelistchainedrows_sql
- analyzevalidate_sql
- analyze_sql
- xmltable_sql
- xmlnamespace_sql
- export_sql
- declare_sql
- declareitem_sql
- recursivewithsearch_sql
- parameterizedagg_sql
- anonymousaggfunc_sql
- combinedaggfunc_sql
- combinedparameterizedagg_sql
- install_sql
- liststage_sql
- get_put_sql
- translatecharacters_sql
- decodecase_sql
- semanticview_sql
- getextract_sql
- datefromunixdate_sql
- space_sql
- buildproperty_sql
- refreshtriggerproperty_sql
- modelattribute_sql
- directorystage_sql
- uuid_sql
- initcap_sql
- localtime_sql
- localtimestamp_sql
- weekstart_name
- weekstart_sql
- chr_sql
- weightstring_sql
- block_sql
- functionspecification_sql
- storedprocedure_sql
- ifblock_sql
- casestatement_sql
- whileblock_sql
- loopblock_sql
- repeatblock_sql
- leave_sql
- iterate_sql
- execute_sql
- executesql_sql
- executeimmediate_sql
- altermodifysqlsecurity_sql
- usingproperty_sql
- renameindex_sql