Edit on GitHub

sqlglot.generators.doris

  1from __future__ import annotations
  2
  3import typing as t
  4
  5from sqlglot import exp, transforms
  6from sqlglot.dialects.dialect import (
  7    approx_count_distinct_sql,
  8    groupconcat_sql,
  9    map_date_part,
 10    no_filter_sql,
 11    property_sql,
 12    rename_func,
 13    time_format,
 14    var_map_sql,
 15    week_unit_to_dow,
 16    weekstart_unit_to_str,
 17)
 18from sqlglot.generators.mysql import MySQLGenerator
 19from sqlglot.optimizer.scope import find_in_scope
 20
 21
 22def _lag_lead_sql(self, expression: exp.Lag | exp.Lead) -> str:
 23    return self.func(
 24        "LAG" if isinstance(expression, exp.Lag) else "LEAD",
 25        expression.this,
 26        expression.args.get("offset") or exp.Literal.number(1),
 27        expression.args.get("default") or exp.null(),
 28    )
 29
 30
 31class DorisGenerator(MySQLGenerator):
 32    def match_sql(self, expression: exp.Match) -> str:
 33        kind = expression.text("kind")
 34        sql = self.binary(expression, f"MATCH_{kind}" if kind else "MATCH")
 35        analyzer = self.sql(expression, "analyzer")
 36        return f"{sql} USING ANALYZER {analyzer}" if analyzer else sql
 37
 38    ARRAY_SIZE_NAME = "ARRAY_SIZE"
 39    LAST_DAY_SUPPORTS_DATE_PART = False
 40    NULL_ORDERING_SUPPORTED: bool | None = True
 41    SUPPORTS_ALTER_COLUMN_NULLABILITY = False
 42    VARCHAR_REQUIRES_SIZE = False
 43    WITH_PROPERTIES_PREFIX = "PROPERTIES"
 44    RENAME_TABLE_WITH_DB = False
 45    UPDATE_STATEMENT_SUPPORTS_FROM = True
 46
 47    TYPE_MAPPING = {
 48        **MySQLGenerator.TYPE_MAPPING,
 49        exp.DType.INT128: "LARGEINT",
 50        exp.DType.TEXT: "STRING",
 51        exp.DType.TIMESTAMP: "DATETIME",
 52        exp.DType.TIMESTAMPTZ: "TIMESTAMPTZ",
 53    }
 54
 55    PROPERTIES_LOCATION = {
 56        **MySQLGenerator.PROPERTIES_LOCATION,
 57        exp.UniqueKeyProperty: exp.Properties.Location.POST_SCHEMA,
 58        exp.PartitionedByProperty: exp.Properties.Location.POST_SCHEMA,
 59        exp.BuildProperty: exp.Properties.Location.POST_SCHEMA,
 60        exp.Property: exp.Properties.Location.POST_WITH,
 61    }
 62
 63    CAST_MAPPING: t.ClassVar[dict[exp.DType, str]] = {}
 64    TIMESTAMP_FUNC_TYPES: t.ClassVar[set[exp.DType]] = set()
 65
 66    TRANSFORMS = {
 67        **{
 68            k: v
 69            for k, v in MySQLGenerator.TRANSFORMS.items()
 70            if k
 71            not in (
 72                exp.ArrayAgg,
 73                exp.CurrentCatalog,
 74                exp.DateDiff,
 75                exp.JSONExtractScalar,
 76                exp.TryCast,
 77            )
 78        },
 79        exp.AddMonths: rename_func("MONTHS_ADD"),
 80        exp.ApproxDistinct: approx_count_distinct_sql,
 81        exp.ArgMax: rename_func("MAX_BY"),
 82        exp.ArgMin: rename_func("MIN_BY"),
 83        exp.ArrayFilter: lambda self, e: self.func("ARRAY_FILTER", e.expression, e.this),
 84        exp.ArrayFirst: lambda self, e: self.func("ARRAY_FIRST", e.expression, e.this),
 85        exp.ArrayLast: lambda self, e: self.func("ARRAY_LAST", e.expression, e.this),
 86        exp.ArrayToString: rename_func("ARRAY_JOIN"),
 87        exp.ArrayUniqueAgg: rename_func("COLLECT_SET"),
 88        exp.CurrentDate: lambda self, _: self.func("CURRENT_DATE"),
 89        exp.CurrentTimestamp: lambda self, _: self.func("NOW"),
 90        exp.DateTrunc: lambda self, e: self.func(
 91            "DATE_TRUNC", e.this, weekstart_unit_to_str(self, e)
 92        ),
 93        exp.EuclideanDistance: rename_func("L2_DISTANCE"),
 94        exp.GroupConcat: lambda self, e: groupconcat_sql(
 95            self, e, func_name="GROUP_CONCAT", within_group=False
 96        ),
 97        exp.Lag: _lag_lead_sql,
 98        exp.Lead: _lag_lead_sql,
 99        exp.Map: var_map_sql,
100        exp.Property: property_sql,
101        exp.Quantile: rename_func("PERCENTILE"),
102        exp.RegexpLike: rename_func("REGEXP"),
103        exp.RegexpSplit: rename_func("SPLIT_BY_STRING"),
104        exp.SchemaCommentProperty: lambda self, e: self.naked_property(e),
105        exp.Select: transforms.preprocess(
106            [
107                transforms.eliminate_distinct_on,
108                transforms.unnest_generate_date_array_using_recursive_cte,
109            ]
110        ),
111        exp.Split: rename_func("SPLIT_BY_STRING"),
112        exp.StringToArray: rename_func("SPLIT_BY_STRING"),
113        exp.StrToUnix: lambda self, e: self.func("UNIX_TIMESTAMP", e.this, self.format_time(e)),
114        exp.TimeStrToDate: rename_func("TO_DATE"),
115        exp.TsOrDsAdd: lambda self, e: self.func("DATE_ADD", e.this, e.expression),
116        exp.TsOrDsToDate: lambda self, e: self.func("TO_DATE", e.this),
117        exp.TimeToUnix: rename_func("UNIX_TIMESTAMP"),
118        exp.TimestampTrunc: lambda self, e: self.func(
119            "DATE_TRUNC", e.this, weekstart_unit_to_str(self, e)
120        ),
121        exp.UnixToStr: lambda self, e: self.func(
122            "FROM_UNIXTIME", e.this, time_format("doris")(self, e)
123        ),
124        exp.UnixToTime: rename_func("FROM_UNIXTIME"),
125        exp.VarMap: var_map_sql,
126    }
127
128    # https://github.com/apache/doris/blob/e4f41dbf1ec03f5937fdeba2ee1454a20254015b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisLexer.g4#L93
129    RESERVED_KEYWORDS = {
130        "account_lock",
131        "account_unlock",
132        "add",
133        "adddate",
134        "admin",
135        "after",
136        "agg_state",
137        "aggregate",
138        "alias",
139        "all",
140        "alter",
141        "analyze",
142        "analyzed",
143        "analyzer",
144        "and",
145        "anti",
146        "append",
147        "array",
148        "array_range",
149        "as",
150        "asc",
151        "asof",
152        "at",
153        "authors",
154        "auto",
155        "auto_increment",
156        "backend",
157        "backends",
158        "backup",
159        "begin",
160        "belong",
161        "between",
162        "bigint",
163        "bin",
164        "binary",
165        "binlog",
166        "bitand",
167        "bitmap",
168        "bitmap_union",
169        "bitor",
170        "bitxor",
171        "blob",
172        "boolean",
173        "both",
174        "brief",
175        "broker",
176        "buckets",
177        "build",
178        "builtin",
179        "bulk",
180        "by",
181        "cached",
182        "call",
183        "cancel",
184        "case",
185        "cast",
186        "catalog",
187        "catalogs",
188        "chain",
189        "char",
190        "char_filter",
191        "character",
192        "charset",
193        "check",
194        "clean",
195        "cluster",
196        "clusters",
197        "collate",
198        "collation",
199        "collect",
200        "column",
201        "columns",
202        "comment",
203        "commit",
204        "committed",
205        "compact",
206        "complete",
207        "config",
208        "connection",
209        "connection_id",
210        "consistent",
211        "constraint",
212        "constraints",
213        "convert",
214        "copy",
215        "count",
216        "create",
217        "creation",
218        "cron",
219        "cross",
220        "cube",
221        "current",
222        "current_catalog",
223        "current_date",
224        "current_time",
225        "current_timestamp",
226        "current_user",
227        "data",
228        "database",
229        "databases",
230        "date",
231        "date_add",
232        "date_ceil",
233        "date_diff",
234        "date_floor",
235        "date_sub",
236        "dateadd",
237        "datediff",
238        "datetime",
239        "datetimev2",
240        "datev2",
241        "datetimev1",
242        "datev1",
243        "day",
244        "days_add",
245        "days_sub",
246        "decimal",
247        "decimalv2",
248        "decimalv3",
249        "decommission",
250        "default",
251        "deferred",
252        "delete",
253        "demand",
254        "desc",
255        "describe",
256        "diagnose",
257        "disk",
258        "distinct",
259        "distinctpc",
260        "distinctpcsa",
261        "distributed",
262        "distribution",
263        "div",
264        "do",
265        "doris_internal_table_id",
266        "double",
267        "drop",
268        "dropp",
269        "dual",
270        "dump",
271        "duplicate",
272        "dynamic",
273        "else",
274        "enable",
275        "encryptkey",
276        "encryptkeys",
277        "end",
278        "ends",
279        "engine",
280        "engines",
281        "enter",
282        "errors",
283        "events",
284        "every",
285        "except",
286        "exclude",
287        "execute",
288        "exists",
289        "expired",
290        "explain",
291        "export",
292        "extended",
293        "external",
294        "extract",
295        "failed_login_attempts",
296        "false",
297        "fast",
298        "feature",
299        "fields",
300        "file",
301        "filter",
302        "first",
303        "float",
304        "follower",
305        "following",
306        "for",
307        "foreign",
308        "force",
309        "format",
310        "free",
311        "from",
312        "frontend",
313        "frontends",
314        "full",
315        "function",
316        "functions",
317        "generic",
318        "global",
319        "grant",
320        "grants",
321        "graph",
322        "group",
323        "grouping",
324        "groups",
325        "hash",
326        "having",
327        "hdfs",
328        "help",
329        "histogram",
330        "hll",
331        "hll_union",
332        "hostname",
333        "hour",
334        "hub",
335        "identified",
336        "if",
337        "ignore",
338        "immediate",
339        "in",
340        "incremental",
341        "index",
342        "indexes",
343        "infile",
344        "inner",
345        "insert",
346        "install",
347        "int",
348        "integer",
349        "intermediate",
350        "intersect",
351        "interval",
352        "into",
353        "inverted",
354        "ipv4",
355        "ipv6",
356        "is",
357        "is_not_null_pred",
358        "is_null_pred",
359        "isnull",
360        "isolation",
361        "job",
362        "jobs",
363        "join",
364        "json",
365        "jsonb",
366        "key",
367        "keys",
368        "kill",
369        "label",
370        "largeint",
371        "last",
372        "lateral",
373        "layout",
374        "ldap",
375        "ldap_admin_password",
376        "leading",
377        "left",
378        "less",
379        "level",
380        "like",
381        "limit",
382        "lines",
383        "link",
384        "list",
385        "load",
386        "local",
387        "localtime",
388        "localtimestamp",
389        "location",
390        "lock",
391        "logical",
392        "low_priority",
393        "manual",
394        "map",
395        "match",
396        "match_all",
397        "match_any",
398        "match_condition",
399        "match_phrase",
400        "match_phrase_edge",
401        "match_phrase_prefix",
402        "match_regexp",
403        "materialized",
404        "max",
405        "maxvalue",
406        "memo",
407        "merge",
408        "migrate",
409        "migrations",
410        "min",
411        "minus",
412        "minute",
413        "modify",
414        "month",
415        "mtmv",
416        "name",
417        "names",
418        "natural",
419        "negative",
420        "never",
421        "next",
422        "ngram_bf",
423        "no",
424        "no_use_mv",
425        "non_nullable",
426        "not",
427        "null",
428        "nulls",
429        "observer",
430        "of",
431        "offset",
432        "on",
433        "only",
434        "open",
435        "optimized",
436        "or",
437        "order",
438        "outer",
439        "outfile",
440        "over",
441        "overwrite",
442        "parameter",
443        "parsed",
444        "partition",
445        "partitions",
446        "password",
447        "password_expire",
448        "password_history",
449        "password_lock_time",
450        "password_reuse",
451        "path",
452        "pause",
453        "percent",
454        "period",
455        "permissive",
456        "physical",
457        "plan",
458        "play",
459        "process",
460        "plugin",
461        "plugins",
462        "policy",
463        "preceding",
464        "prepare",
465        "primary",
466        "proc",
467        "procedure",
468        "processlist",
469        "profile",
470        "properties",
471        "property",
472        "quantile_state",
473        "quantile_union",
474        "query",
475        "quota",
476        "random",
477        "range",
478        "read",
479        "real",
480        "rebalance",
481        "recover",
482        "recycle",
483        "refresh",
484        "references",
485        "regexp",
486        "release",
487        "rename",
488        "repair",
489        "repeatable",
490        "replace",
491        "replace_if_not_null",
492        "replica",
493        "repositories",
494        "repository",
495        "resource",
496        "resources",
497        "restore",
498        "restrictive",
499        "resume",
500        "returns",
501        "revoke",
502        "rewritten",
503        "right",
504        "rlike",
505        "role",
506        "roles",
507        "rollback",
508        "rollup",
509        "routine",
510        "row",
511        "rows",
512        "s3",
513        "sample",
514        "schedule",
515        "scheduler",
516        "schema",
517        "schemas",
518        "second",
519        "select",
520        "semi",
521        "sequence",
522        "serializable",
523        "session",
524        "set",
525        "sets",
526        "shape",
527        "show",
528        "signed",
529        "skew",
530        "smallint",
531        "snapshot",
532        "soname",
533        "split",
534        "sql_block_rule",
535        "start",
536        "starts",
537        "stats",
538        "status",
539        "stop",
540        "storage",
541        "stream",
542        "streaming",
543        "string",
544        "struct",
545        "subdate",
546        "sum",
547        "superuser",
548        "switch",
549        "sync",
550        "system",
551        "table",
552        "tables",
553        "tablesample",
554        "tablet",
555        "tablets",
556        "task",
557        "tasks",
558        "temporary",
559        "terminated",
560        "text",
561        "than",
562        "then",
563        "time",
564        "timestamp",
565        "timestampadd",
566        "timestampdiff",
567        "tinyint",
568        "to",
569        "token_filter",
570        "tokenizer",
571        "trailing",
572        "transaction",
573        "trash",
574        "tree",
575        "triggers",
576        "trim",
577        "true",
578        "truncate",
579        "try_cast",
580        "type",
581        "type_cast",
582        "types",
583        "unbounded",
584        "uncommitted",
585        "uninstall",
586        "union",
587        "unique",
588        "unlock",
589        "unsigned",
590        "update",
591        "use",
592        "use_mv",
593        "user",
594        "using",
595        "value",
596        "values",
597        "varchar",
598        "variables",
599        "variant",
600        "vault",
601        "verbose",
602        "version",
603        "view",
604        "warnings",
605        "week",
606        "when",
607        "where",
608        "whitelist",
609        "with",
610        "work",
611        "workload",
612        "write",
613        "xor",
614        "year",
615    }
616
617    def join_sql(self, expression: exp.Join, join_op: str | None = None) -> str:
618        if expression.is_semi_or_anti_join and not expression.side:
619            expression.set("side", "LEFT")
620        return super().join_sql(expression, join_op=join_op)
621
622    def filter_sql(self, expression: exp.Filter) -> str:
623        agg = expression.this
624        arg = agg.this
625        count_star = isinstance(agg, exp.Count) and (arg is None or arg == exp.Star())
626        if isinstance(arg, exp.Distinct) and len(arg.expressions) == 1:
627            arg = arg.expressions[0]
628        if isinstance(arg, exp.Paren):
629            arg = arg.unnest()
630
631        if (
632            not isinstance(agg, (exp.Count, exp.Sum, exp.Avg, exp.Min, exp.Max, exp.AnyValue))
633            or (isinstance(expression.parent, exp.Window) and expression.arg_key == "this")
634            or agg.expressions
635            or isinstance(arg, (exp.Distinct, exp.Order, exp.Limit, exp.HavingMax, exp.Tuple))
636            or (not count_star and find_in_scope(agg, exp.Star))
637        ):
638            self.unsupported("Cannot rewrite this aggregate FILTER for Doris")
639            return super().filter_sql(expression)
640
641        return no_filter_sql(self, expression.copy())
642
643    def countif_sql(self, expression: exp.CountIf) -> str:
644        cond = expression.this
645        distinct = isinstance(cond, exp.Distinct)
646        arg = exp.If(this=cond.expressions[0] if distinct else cond, true=exp.Literal.number(1))
647        return self.func("COUNT", exp.Distinct(expressions=[arg]) if distinct else arg)
648
649    def jsonextractscalar_sql(self, expression: exp.JSONExtractScalar) -> str:
650        value = self.func("GET_JSON_STRING", expression.this, expression.expression)
651        if expression.args.get("scalar_only"):
652            kind = exp.JSONType(this=expression.this, expression=expression.expression)
653            return self.func("IF", kind.isin("array", "object"), exp.null(), value)
654        return value
655
656    def datediff_sql(self, expression: exp.DateDiff) -> str:
657        unit = map_date_part(expression.unit)
658        boundary = expression.args.get("date_part_boundary")
659        if not unit or (boundary and unit.name == "DAY"):
660            return MySQLGenerator.TRANSFORMS[exp.DateDiff](self, expression)
661
662        start, end = expression.expression, expression.this
663        if dow := week_unit_to_dow(unit):
664            unit = exp.var("WEEK")
665            if boundary and dow != 1:
666                # Align the requested week start with the Monday used by DATE_TRUNC.
667                shift = exp.Interval(this=exp.Literal.number(8 - dow), unit=exp.var("DAY"))
668                start, end = start + shift, end + shift
669
670        if unit.name == "MILLISECOND":
671            if boundary:
672                # Doris DATE_TRUNC stops at seconds. Count milliseconds from the earliest date.
673                origin = exp.Literal.string("0000-01-01")
674                end_ms = exp.func("MILLISECONDS_DIFF", end, origin)
675                start_ms = exp.func("MILLISECONDS_DIFF", start, origin)
676                return self.sql(exp.paren(end_ms - start_ms))
677            return self.func("MILLISECONDS_DIFF", end, start)
678
679        if unit.name in ("YEAR", "QUARTER", "MONTH", "WEEK", "DAY", "HOUR", "MINUTE", "SECOND"):
680            if boundary:
681                # TIMESTAMPDIFF counts complete units. Truncating both operands counts boundaries.
682                start = exp.TimestampTrunc(this=start, unit=unit.copy())
683                end = exp.TimestampTrunc(this=end, unit=unit.copy())
684        elif unit.name != "MICROSECOND":
685            self.unsupported(f"Unsupported Doris date difference unit: {unit.name}")
686
687        return self.func("TIMESTAMPDIFF", unit, start, end)
688
689    def array_sql(self, expression: exp.Array) -> str:
690        args = expression.expressions
691        has_single_query_arg = len(args) == 1 and isinstance(args[0], (exp.Query, exp.Values))
692        if has_single_query_arg and not expression.args.get("value_constructor"):
693            self.unsupported("Doris does not support ARRAY constructors from a query")
694        return self.func("ARRAY", *args)
695
696    def datatype_sql(self, expression: exp.DataType) -> str:
697        if self.dialect.version < (4, 0, 3) and expression.is_type(exp.DType.TIMESTAMPTZ):
698            self.unsupported("TIMESTAMPTZ requires Doris 4.0.3 or later")
699            expression = expression.copy()
700            expression.set("this", exp.DType.DATETIME)
701        return super().datatype_sql(expression)
702
703    def columndef_sql(self, expression: exp.ColumnDef, sep: str = " ") -> str:
704        parent = expression.parent
705        if isinstance(parent, exp.DataType) and parent.is_type(exp.DType.STRUCT):
706            sep = ": "
707        return super().columndef_sql(expression, sep)
708
709    def struct_sql(self, expression: exp.Struct) -> str:
710        fields = expression.expressions
711        if not any(isinstance(field, exp.PropertyEQ) for field in fields):
712            return self.func("STRUCT", *fields)
713
714        args: list[exp.Expr] = []
715        for i, field in enumerate(fields, 1):
716            if isinstance(field, exp.PropertyEQ):
717                key = field.this
718                if isinstance(key, exp.Identifier):
719                    key = exp.Literal.string(key.name)
720                elif not key.is_string:
721                    self.unsupported("Doris requires literal field names in NAMED_STRUCT")
722                args.extend((key, field.expression))
723            else:
724                args.extend((exp.Literal.string(f"col{i}"), field))
725
726        return self.func("NAMED_STRUCT", *args)
727
728    def arrayagg_sql(self, expression: exp.ArrayAgg) -> str:
729        name = "COLLECT_LIST" if expression.args.get("nulls_excluded") else "ARRAY_AGG"
730        sql = self.func(name, expression.this)
731        if isinstance(expression.this, exp.Order) or isinstance(
732            expression.parent, (exp.Filter, exp.WithinGroup)
733        ):
734            self.unsupported(f"Doris does not support aggregate ORDER BY or FILTER on {name}")
735            return sql
736        if expression.args.get("null_on_empty") and not (
737            isinstance(expression.parent, exp.Window) and expression.arg_key == "this"
738        ):
739            return self.func("NULLIF", sql, exp.array())
740        return sql
741
742    def window_sql(self, expression: exp.Window) -> str:
743        sql = super().window_sql(expression)
744        agg = expression.this
745        if isinstance(agg, exp.ArrayAgg) and agg.args.get("null_on_empty"):
746            return self.func("NULLIF", sql, exp.array())
747        return sql
748
749    def uniquekeyproperty_sql(
750        self, expression: exp.UniqueKeyProperty, prefix: str = "UNIQUE KEY"
751    ) -> str:
752        create_stmt = expression.find_ancestor(exp.Create)
753        if create_stmt and create_stmt.args["properties"].find(exp.MaterializedProperty):
754            return super().uniquekeyproperty_sql(expression, prefix="KEY")
755
756        return super().uniquekeyproperty_sql(expression)
757
758    def partitionrange_sql(self, expression: exp.PartitionRange) -> str:
759        name = self.sql(expression, "this")
760        values = expression.expressions
761
762        if len(values) != 1:
763            # Multiple values: use VALUES [ ... )
764            if values and isinstance(values[0], list):
765                values_sql = ", ".join(
766                    f"({', '.join(self.sql(v) for v in inner)})" for inner in values
767                )
768            else:
769                values_sql = ", ".join(f"({self.sql(v)})" for v in values)
770
771            return f"PARTITION {name} VALUES [{values_sql})"
772
773        return f"PARTITION {name} VALUES LESS THAN ({self.sql(values[0])})"
774
775    def partitionbyrangepropertydynamic_sql(
776        self, expression: exp.PartitionByRangePropertyDynamic
777    ) -> str:
778        # Generates: FROM ("start") TO ("end") INTERVAL N UNIT
779        start = self.sql(expression, "start")
780        end = self.sql(expression, "end")
781        every = expression.args.get("every")
782
783        if every:
784            number = self.sql(every, "this")
785            interval = f"INTERVAL {number} {self.sql(every, 'unit')}"
786        else:
787            interval = ""
788
789        return f"FROM ({start}) TO ({end}) {interval}"
790
791    def partitionedbyproperty_sql(self, expression: exp.PartitionedByProperty) -> str:
792        this = expression.this
793        if isinstance(this, exp.Schema):
794            return f"PARTITION BY ({self.expressions(this, flat=True)})"
795        return f"PARTITION BY ({self.sql(this)})"
796
797    def table_sql(self, expression: exp.Table, sep: str = " AS ") -> str:
798        """Override table_sql to avoid AS keyword in UPDATE and DELETE statements."""
799        ancestor = expression.find_ancestor(exp.Update, exp.Delete, exp.Select)
800        if not isinstance(ancestor, exp.Select):
801            sep = " "
802        return super().table_sql(expression, sep=sep)
803
804    def tsordstodatetime_sql(self, expression: exp.TsOrDsToDatetime) -> str:
805        if expression.this.is_string:
806            # A TIMESTAMP literal infers fractional precision. A bare DATETIME cast uses zero.
807            return f"TIMESTAMP {self.sql(expression, 'this')}"
808        return super().tsordstodatetime_sql(expression)
class DorisGenerator(sqlglot.generators.mysql.MySQLGenerator):
 32class DorisGenerator(MySQLGenerator):
 33    def match_sql(self, expression: exp.Match) -> str:
 34        kind = expression.text("kind")
 35        sql = self.binary(expression, f"MATCH_{kind}" if kind else "MATCH")
 36        analyzer = self.sql(expression, "analyzer")
 37        return f"{sql} USING ANALYZER {analyzer}" if analyzer else sql
 38
 39    ARRAY_SIZE_NAME = "ARRAY_SIZE"
 40    LAST_DAY_SUPPORTS_DATE_PART = False
 41    NULL_ORDERING_SUPPORTED: bool | None = True
 42    SUPPORTS_ALTER_COLUMN_NULLABILITY = False
 43    VARCHAR_REQUIRES_SIZE = False
 44    WITH_PROPERTIES_PREFIX = "PROPERTIES"
 45    RENAME_TABLE_WITH_DB = False
 46    UPDATE_STATEMENT_SUPPORTS_FROM = True
 47
 48    TYPE_MAPPING = {
 49        **MySQLGenerator.TYPE_MAPPING,
 50        exp.DType.INT128: "LARGEINT",
 51        exp.DType.TEXT: "STRING",
 52        exp.DType.TIMESTAMP: "DATETIME",
 53        exp.DType.TIMESTAMPTZ: "TIMESTAMPTZ",
 54    }
 55
 56    PROPERTIES_LOCATION = {
 57        **MySQLGenerator.PROPERTIES_LOCATION,
 58        exp.UniqueKeyProperty: exp.Properties.Location.POST_SCHEMA,
 59        exp.PartitionedByProperty: exp.Properties.Location.POST_SCHEMA,
 60        exp.BuildProperty: exp.Properties.Location.POST_SCHEMA,
 61        exp.Property: exp.Properties.Location.POST_WITH,
 62    }
 63
 64    CAST_MAPPING: t.ClassVar[dict[exp.DType, str]] = {}
 65    TIMESTAMP_FUNC_TYPES: t.ClassVar[set[exp.DType]] = set()
 66
 67    TRANSFORMS = {
 68        **{
 69            k: v
 70            for k, v in MySQLGenerator.TRANSFORMS.items()
 71            if k
 72            not in (
 73                exp.ArrayAgg,
 74                exp.CurrentCatalog,
 75                exp.DateDiff,
 76                exp.JSONExtractScalar,
 77                exp.TryCast,
 78            )
 79        },
 80        exp.AddMonths: rename_func("MONTHS_ADD"),
 81        exp.ApproxDistinct: approx_count_distinct_sql,
 82        exp.ArgMax: rename_func("MAX_BY"),
 83        exp.ArgMin: rename_func("MIN_BY"),
 84        exp.ArrayFilter: lambda self, e: self.func("ARRAY_FILTER", e.expression, e.this),
 85        exp.ArrayFirst: lambda self, e: self.func("ARRAY_FIRST", e.expression, e.this),
 86        exp.ArrayLast: lambda self, e: self.func("ARRAY_LAST", e.expression, e.this),
 87        exp.ArrayToString: rename_func("ARRAY_JOIN"),
 88        exp.ArrayUniqueAgg: rename_func("COLLECT_SET"),
 89        exp.CurrentDate: lambda self, _: self.func("CURRENT_DATE"),
 90        exp.CurrentTimestamp: lambda self, _: self.func("NOW"),
 91        exp.DateTrunc: lambda self, e: self.func(
 92            "DATE_TRUNC", e.this, weekstart_unit_to_str(self, e)
 93        ),
 94        exp.EuclideanDistance: rename_func("L2_DISTANCE"),
 95        exp.GroupConcat: lambda self, e: groupconcat_sql(
 96            self, e, func_name="GROUP_CONCAT", within_group=False
 97        ),
 98        exp.Lag: _lag_lead_sql,
 99        exp.Lead: _lag_lead_sql,
100        exp.Map: var_map_sql,
101        exp.Property: property_sql,
102        exp.Quantile: rename_func("PERCENTILE"),
103        exp.RegexpLike: rename_func("REGEXP"),
104        exp.RegexpSplit: rename_func("SPLIT_BY_STRING"),
105        exp.SchemaCommentProperty: lambda self, e: self.naked_property(e),
106        exp.Select: transforms.preprocess(
107            [
108                transforms.eliminate_distinct_on,
109                transforms.unnest_generate_date_array_using_recursive_cte,
110            ]
111        ),
112        exp.Split: rename_func("SPLIT_BY_STRING"),
113        exp.StringToArray: rename_func("SPLIT_BY_STRING"),
114        exp.StrToUnix: lambda self, e: self.func("UNIX_TIMESTAMP", e.this, self.format_time(e)),
115        exp.TimeStrToDate: rename_func("TO_DATE"),
116        exp.TsOrDsAdd: lambda self, e: self.func("DATE_ADD", e.this, e.expression),
117        exp.TsOrDsToDate: lambda self, e: self.func("TO_DATE", e.this),
118        exp.TimeToUnix: rename_func("UNIX_TIMESTAMP"),
119        exp.TimestampTrunc: lambda self, e: self.func(
120            "DATE_TRUNC", e.this, weekstart_unit_to_str(self, e)
121        ),
122        exp.UnixToStr: lambda self, e: self.func(
123            "FROM_UNIXTIME", e.this, time_format("doris")(self, e)
124        ),
125        exp.UnixToTime: rename_func("FROM_UNIXTIME"),
126        exp.VarMap: var_map_sql,
127    }
128
129    # https://github.com/apache/doris/blob/e4f41dbf1ec03f5937fdeba2ee1454a20254015b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisLexer.g4#L93
130    RESERVED_KEYWORDS = {
131        "account_lock",
132        "account_unlock",
133        "add",
134        "adddate",
135        "admin",
136        "after",
137        "agg_state",
138        "aggregate",
139        "alias",
140        "all",
141        "alter",
142        "analyze",
143        "analyzed",
144        "analyzer",
145        "and",
146        "anti",
147        "append",
148        "array",
149        "array_range",
150        "as",
151        "asc",
152        "asof",
153        "at",
154        "authors",
155        "auto",
156        "auto_increment",
157        "backend",
158        "backends",
159        "backup",
160        "begin",
161        "belong",
162        "between",
163        "bigint",
164        "bin",
165        "binary",
166        "binlog",
167        "bitand",
168        "bitmap",
169        "bitmap_union",
170        "bitor",
171        "bitxor",
172        "blob",
173        "boolean",
174        "both",
175        "brief",
176        "broker",
177        "buckets",
178        "build",
179        "builtin",
180        "bulk",
181        "by",
182        "cached",
183        "call",
184        "cancel",
185        "case",
186        "cast",
187        "catalog",
188        "catalogs",
189        "chain",
190        "char",
191        "char_filter",
192        "character",
193        "charset",
194        "check",
195        "clean",
196        "cluster",
197        "clusters",
198        "collate",
199        "collation",
200        "collect",
201        "column",
202        "columns",
203        "comment",
204        "commit",
205        "committed",
206        "compact",
207        "complete",
208        "config",
209        "connection",
210        "connection_id",
211        "consistent",
212        "constraint",
213        "constraints",
214        "convert",
215        "copy",
216        "count",
217        "create",
218        "creation",
219        "cron",
220        "cross",
221        "cube",
222        "current",
223        "current_catalog",
224        "current_date",
225        "current_time",
226        "current_timestamp",
227        "current_user",
228        "data",
229        "database",
230        "databases",
231        "date",
232        "date_add",
233        "date_ceil",
234        "date_diff",
235        "date_floor",
236        "date_sub",
237        "dateadd",
238        "datediff",
239        "datetime",
240        "datetimev2",
241        "datev2",
242        "datetimev1",
243        "datev1",
244        "day",
245        "days_add",
246        "days_sub",
247        "decimal",
248        "decimalv2",
249        "decimalv3",
250        "decommission",
251        "default",
252        "deferred",
253        "delete",
254        "demand",
255        "desc",
256        "describe",
257        "diagnose",
258        "disk",
259        "distinct",
260        "distinctpc",
261        "distinctpcsa",
262        "distributed",
263        "distribution",
264        "div",
265        "do",
266        "doris_internal_table_id",
267        "double",
268        "drop",
269        "dropp",
270        "dual",
271        "dump",
272        "duplicate",
273        "dynamic",
274        "else",
275        "enable",
276        "encryptkey",
277        "encryptkeys",
278        "end",
279        "ends",
280        "engine",
281        "engines",
282        "enter",
283        "errors",
284        "events",
285        "every",
286        "except",
287        "exclude",
288        "execute",
289        "exists",
290        "expired",
291        "explain",
292        "export",
293        "extended",
294        "external",
295        "extract",
296        "failed_login_attempts",
297        "false",
298        "fast",
299        "feature",
300        "fields",
301        "file",
302        "filter",
303        "first",
304        "float",
305        "follower",
306        "following",
307        "for",
308        "foreign",
309        "force",
310        "format",
311        "free",
312        "from",
313        "frontend",
314        "frontends",
315        "full",
316        "function",
317        "functions",
318        "generic",
319        "global",
320        "grant",
321        "grants",
322        "graph",
323        "group",
324        "grouping",
325        "groups",
326        "hash",
327        "having",
328        "hdfs",
329        "help",
330        "histogram",
331        "hll",
332        "hll_union",
333        "hostname",
334        "hour",
335        "hub",
336        "identified",
337        "if",
338        "ignore",
339        "immediate",
340        "in",
341        "incremental",
342        "index",
343        "indexes",
344        "infile",
345        "inner",
346        "insert",
347        "install",
348        "int",
349        "integer",
350        "intermediate",
351        "intersect",
352        "interval",
353        "into",
354        "inverted",
355        "ipv4",
356        "ipv6",
357        "is",
358        "is_not_null_pred",
359        "is_null_pred",
360        "isnull",
361        "isolation",
362        "job",
363        "jobs",
364        "join",
365        "json",
366        "jsonb",
367        "key",
368        "keys",
369        "kill",
370        "label",
371        "largeint",
372        "last",
373        "lateral",
374        "layout",
375        "ldap",
376        "ldap_admin_password",
377        "leading",
378        "left",
379        "less",
380        "level",
381        "like",
382        "limit",
383        "lines",
384        "link",
385        "list",
386        "load",
387        "local",
388        "localtime",
389        "localtimestamp",
390        "location",
391        "lock",
392        "logical",
393        "low_priority",
394        "manual",
395        "map",
396        "match",
397        "match_all",
398        "match_any",
399        "match_condition",
400        "match_phrase",
401        "match_phrase_edge",
402        "match_phrase_prefix",
403        "match_regexp",
404        "materialized",
405        "max",
406        "maxvalue",
407        "memo",
408        "merge",
409        "migrate",
410        "migrations",
411        "min",
412        "minus",
413        "minute",
414        "modify",
415        "month",
416        "mtmv",
417        "name",
418        "names",
419        "natural",
420        "negative",
421        "never",
422        "next",
423        "ngram_bf",
424        "no",
425        "no_use_mv",
426        "non_nullable",
427        "not",
428        "null",
429        "nulls",
430        "observer",
431        "of",
432        "offset",
433        "on",
434        "only",
435        "open",
436        "optimized",
437        "or",
438        "order",
439        "outer",
440        "outfile",
441        "over",
442        "overwrite",
443        "parameter",
444        "parsed",
445        "partition",
446        "partitions",
447        "password",
448        "password_expire",
449        "password_history",
450        "password_lock_time",
451        "password_reuse",
452        "path",
453        "pause",
454        "percent",
455        "period",
456        "permissive",
457        "physical",
458        "plan",
459        "play",
460        "process",
461        "plugin",
462        "plugins",
463        "policy",
464        "preceding",
465        "prepare",
466        "primary",
467        "proc",
468        "procedure",
469        "processlist",
470        "profile",
471        "properties",
472        "property",
473        "quantile_state",
474        "quantile_union",
475        "query",
476        "quota",
477        "random",
478        "range",
479        "read",
480        "real",
481        "rebalance",
482        "recover",
483        "recycle",
484        "refresh",
485        "references",
486        "regexp",
487        "release",
488        "rename",
489        "repair",
490        "repeatable",
491        "replace",
492        "replace_if_not_null",
493        "replica",
494        "repositories",
495        "repository",
496        "resource",
497        "resources",
498        "restore",
499        "restrictive",
500        "resume",
501        "returns",
502        "revoke",
503        "rewritten",
504        "right",
505        "rlike",
506        "role",
507        "roles",
508        "rollback",
509        "rollup",
510        "routine",
511        "row",
512        "rows",
513        "s3",
514        "sample",
515        "schedule",
516        "scheduler",
517        "schema",
518        "schemas",
519        "second",
520        "select",
521        "semi",
522        "sequence",
523        "serializable",
524        "session",
525        "set",
526        "sets",
527        "shape",
528        "show",
529        "signed",
530        "skew",
531        "smallint",
532        "snapshot",
533        "soname",
534        "split",
535        "sql_block_rule",
536        "start",
537        "starts",
538        "stats",
539        "status",
540        "stop",
541        "storage",
542        "stream",
543        "streaming",
544        "string",
545        "struct",
546        "subdate",
547        "sum",
548        "superuser",
549        "switch",
550        "sync",
551        "system",
552        "table",
553        "tables",
554        "tablesample",
555        "tablet",
556        "tablets",
557        "task",
558        "tasks",
559        "temporary",
560        "terminated",
561        "text",
562        "than",
563        "then",
564        "time",
565        "timestamp",
566        "timestampadd",
567        "timestampdiff",
568        "tinyint",
569        "to",
570        "token_filter",
571        "tokenizer",
572        "trailing",
573        "transaction",
574        "trash",
575        "tree",
576        "triggers",
577        "trim",
578        "true",
579        "truncate",
580        "try_cast",
581        "type",
582        "type_cast",
583        "types",
584        "unbounded",
585        "uncommitted",
586        "uninstall",
587        "union",
588        "unique",
589        "unlock",
590        "unsigned",
591        "update",
592        "use",
593        "use_mv",
594        "user",
595        "using",
596        "value",
597        "values",
598        "varchar",
599        "variables",
600        "variant",
601        "vault",
602        "verbose",
603        "version",
604        "view",
605        "warnings",
606        "week",
607        "when",
608        "where",
609        "whitelist",
610        "with",
611        "work",
612        "workload",
613        "write",
614        "xor",
615        "year",
616    }
617
618    def join_sql(self, expression: exp.Join, join_op: str | None = None) -> str:
619        if expression.is_semi_or_anti_join and not expression.side:
620            expression.set("side", "LEFT")
621        return super().join_sql(expression, join_op=join_op)
622
623    def filter_sql(self, expression: exp.Filter) -> str:
624        agg = expression.this
625        arg = agg.this
626        count_star = isinstance(agg, exp.Count) and (arg is None or arg == exp.Star())
627        if isinstance(arg, exp.Distinct) and len(arg.expressions) == 1:
628            arg = arg.expressions[0]
629        if isinstance(arg, exp.Paren):
630            arg = arg.unnest()
631
632        if (
633            not isinstance(agg, (exp.Count, exp.Sum, exp.Avg, exp.Min, exp.Max, exp.AnyValue))
634            or (isinstance(expression.parent, exp.Window) and expression.arg_key == "this")
635            or agg.expressions
636            or isinstance(arg, (exp.Distinct, exp.Order, exp.Limit, exp.HavingMax, exp.Tuple))
637            or (not count_star and find_in_scope(agg, exp.Star))
638        ):
639            self.unsupported("Cannot rewrite this aggregate FILTER for Doris")
640            return super().filter_sql(expression)
641
642        return no_filter_sql(self, expression.copy())
643
644    def countif_sql(self, expression: exp.CountIf) -> str:
645        cond = expression.this
646        distinct = isinstance(cond, exp.Distinct)
647        arg = exp.If(this=cond.expressions[0] if distinct else cond, true=exp.Literal.number(1))
648        return self.func("COUNT", exp.Distinct(expressions=[arg]) if distinct else arg)
649
650    def jsonextractscalar_sql(self, expression: exp.JSONExtractScalar) -> str:
651        value = self.func("GET_JSON_STRING", expression.this, expression.expression)
652        if expression.args.get("scalar_only"):
653            kind = exp.JSONType(this=expression.this, expression=expression.expression)
654            return self.func("IF", kind.isin("array", "object"), exp.null(), value)
655        return value
656
657    def datediff_sql(self, expression: exp.DateDiff) -> str:
658        unit = map_date_part(expression.unit)
659        boundary = expression.args.get("date_part_boundary")
660        if not unit or (boundary and unit.name == "DAY"):
661            return MySQLGenerator.TRANSFORMS[exp.DateDiff](self, expression)
662
663        start, end = expression.expression, expression.this
664        if dow := week_unit_to_dow(unit):
665            unit = exp.var("WEEK")
666            if boundary and dow != 1:
667                # Align the requested week start with the Monday used by DATE_TRUNC.
668                shift = exp.Interval(this=exp.Literal.number(8 - dow), unit=exp.var("DAY"))
669                start, end = start + shift, end + shift
670
671        if unit.name == "MILLISECOND":
672            if boundary:
673                # Doris DATE_TRUNC stops at seconds. Count milliseconds from the earliest date.
674                origin = exp.Literal.string("0000-01-01")
675                end_ms = exp.func("MILLISECONDS_DIFF", end, origin)
676                start_ms = exp.func("MILLISECONDS_DIFF", start, origin)
677                return self.sql(exp.paren(end_ms - start_ms))
678            return self.func("MILLISECONDS_DIFF", end, start)
679
680        if unit.name in ("YEAR", "QUARTER", "MONTH", "WEEK", "DAY", "HOUR", "MINUTE", "SECOND"):
681            if boundary:
682                # TIMESTAMPDIFF counts complete units. Truncating both operands counts boundaries.
683                start = exp.TimestampTrunc(this=start, unit=unit.copy())
684                end = exp.TimestampTrunc(this=end, unit=unit.copy())
685        elif unit.name != "MICROSECOND":
686            self.unsupported(f"Unsupported Doris date difference unit: {unit.name}")
687
688        return self.func("TIMESTAMPDIFF", unit, start, end)
689
690    def array_sql(self, expression: exp.Array) -> str:
691        args = expression.expressions
692        has_single_query_arg = len(args) == 1 and isinstance(args[0], (exp.Query, exp.Values))
693        if has_single_query_arg and not expression.args.get("value_constructor"):
694            self.unsupported("Doris does not support ARRAY constructors from a query")
695        return self.func("ARRAY", *args)
696
697    def datatype_sql(self, expression: exp.DataType) -> str:
698        if self.dialect.version < (4, 0, 3) and expression.is_type(exp.DType.TIMESTAMPTZ):
699            self.unsupported("TIMESTAMPTZ requires Doris 4.0.3 or later")
700            expression = expression.copy()
701            expression.set("this", exp.DType.DATETIME)
702        return super().datatype_sql(expression)
703
704    def columndef_sql(self, expression: exp.ColumnDef, sep: str = " ") -> str:
705        parent = expression.parent
706        if isinstance(parent, exp.DataType) and parent.is_type(exp.DType.STRUCT):
707            sep = ": "
708        return super().columndef_sql(expression, sep)
709
710    def struct_sql(self, expression: exp.Struct) -> str:
711        fields = expression.expressions
712        if not any(isinstance(field, exp.PropertyEQ) for field in fields):
713            return self.func("STRUCT", *fields)
714
715        args: list[exp.Expr] = []
716        for i, field in enumerate(fields, 1):
717            if isinstance(field, exp.PropertyEQ):
718                key = field.this
719                if isinstance(key, exp.Identifier):
720                    key = exp.Literal.string(key.name)
721                elif not key.is_string:
722                    self.unsupported("Doris requires literal field names in NAMED_STRUCT")
723                args.extend((key, field.expression))
724            else:
725                args.extend((exp.Literal.string(f"col{i}"), field))
726
727        return self.func("NAMED_STRUCT", *args)
728
729    def arrayagg_sql(self, expression: exp.ArrayAgg) -> str:
730        name = "COLLECT_LIST" if expression.args.get("nulls_excluded") else "ARRAY_AGG"
731        sql = self.func(name, expression.this)
732        if isinstance(expression.this, exp.Order) or isinstance(
733            expression.parent, (exp.Filter, exp.WithinGroup)
734        ):
735            self.unsupported(f"Doris does not support aggregate ORDER BY or FILTER on {name}")
736            return sql
737        if expression.args.get("null_on_empty") and not (
738            isinstance(expression.parent, exp.Window) and expression.arg_key == "this"
739        ):
740            return self.func("NULLIF", sql, exp.array())
741        return sql
742
743    def window_sql(self, expression: exp.Window) -> str:
744        sql = super().window_sql(expression)
745        agg = expression.this
746        if isinstance(agg, exp.ArrayAgg) and agg.args.get("null_on_empty"):
747            return self.func("NULLIF", sql, exp.array())
748        return sql
749
750    def uniquekeyproperty_sql(
751        self, expression: exp.UniqueKeyProperty, prefix: str = "UNIQUE KEY"
752    ) -> str:
753        create_stmt = expression.find_ancestor(exp.Create)
754        if create_stmt and create_stmt.args["properties"].find(exp.MaterializedProperty):
755            return super().uniquekeyproperty_sql(expression, prefix="KEY")
756
757        return super().uniquekeyproperty_sql(expression)
758
759    def partitionrange_sql(self, expression: exp.PartitionRange) -> str:
760        name = self.sql(expression, "this")
761        values = expression.expressions
762
763        if len(values) != 1:
764            # Multiple values: use VALUES [ ... )
765            if values and isinstance(values[0], list):
766                values_sql = ", ".join(
767                    f"({', '.join(self.sql(v) for v in inner)})" for inner in values
768                )
769            else:
770                values_sql = ", ".join(f"({self.sql(v)})" for v in values)
771
772            return f"PARTITION {name} VALUES [{values_sql})"
773
774        return f"PARTITION {name} VALUES LESS THAN ({self.sql(values[0])})"
775
776    def partitionbyrangepropertydynamic_sql(
777        self, expression: exp.PartitionByRangePropertyDynamic
778    ) -> str:
779        # Generates: FROM ("start") TO ("end") INTERVAL N UNIT
780        start = self.sql(expression, "start")
781        end = self.sql(expression, "end")
782        every = expression.args.get("every")
783
784        if every:
785            number = self.sql(every, "this")
786            interval = f"INTERVAL {number} {self.sql(every, 'unit')}"
787        else:
788            interval = ""
789
790        return f"FROM ({start}) TO ({end}) {interval}"
791
792    def partitionedbyproperty_sql(self, expression: exp.PartitionedByProperty) -> str:
793        this = expression.this
794        if isinstance(this, exp.Schema):
795            return f"PARTITION BY ({self.expressions(this, flat=True)})"
796        return f"PARTITION BY ({self.sql(this)})"
797
798    def table_sql(self, expression: exp.Table, sep: str = " AS ") -> str:
799        """Override table_sql to avoid AS keyword in UPDATE and DELETE statements."""
800        ancestor = expression.find_ancestor(exp.Update, exp.Delete, exp.Select)
801        if not isinstance(ancestor, exp.Select):
802            sep = " "
803        return super().table_sql(expression, sep=sep)
804
805    def tsordstodatetime_sql(self, expression: exp.TsOrDsToDatetime) -> str:
806        if expression.this.is_string:
807            # A TIMESTAMP literal infers fractional precision. A bare DATETIME cast uses zero.
808            return f"TIMESTAMP {self.sql(expression, 'this')}"
809        return super().tsordstodatetime_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: 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 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
def match_sql(self, expression: sqlglot.expressions.core.Match) -> str:
33    def match_sql(self, expression: exp.Match) -> str:
34        kind = expression.text("kind")
35        sql = self.binary(expression, f"MATCH_{kind}" if kind else "MATCH")
36        analyzer = self.sql(expression, "analyzer")
37        return f"{sql} USING ANALYZER {analyzer}" if analyzer else sql
ARRAY_SIZE_NAME = 'ARRAY_SIZE'
LAST_DAY_SUPPORTS_DATE_PART = False
NULL_ORDERING_SUPPORTED: bool | None = True
SUPPORTS_ALTER_COLUMN_NULLABILITY = False
VARCHAR_REQUIRES_SIZE = False
WITH_PROPERTIES_PREFIX = 'PROPERTIES'
RENAME_TABLE_WITH_DB = False
UPDATE_STATEMENT_SUPPORTS_FROM = True
TYPE_MAPPING = {<DType.NCHAR: 'NCHAR'>: 'CHAR', <DType.NVARCHAR: 'NVARCHAR'>: 'VARCHAR', <DType.INET: 'INET'>: 'INET', <DType.ROWVERSION: 'ROWVERSION'>: 'VARBINARY', <DType.UBIGINT: 'UBIGINT'>: 'BIGINT', <DType.UINT: 'UINT'>: 'INT', <DType.UMEDIUMINT: 'UMEDIUMINT'>: 'MEDIUMINT', <DType.USMALLINT: 'USMALLINT'>: 'SMALLINT', <DType.UTINYINT: 'UTINYINT'>: 'TINYINT', <DType.UDECIMAL: 'UDECIMAL'>: 'DECIMAL', <DType.UDOUBLE: 'UDOUBLE'>: 'DOUBLE', <DType.DATETIME2: 'DATETIME2'>: 'DATETIME', <DType.SMALLDATETIME: 'SMALLDATETIME'>: 'DATETIME', <DType.TIMESTAMP: 'TIMESTAMP'>: 'DATETIME', <DType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>: 'DATETIME', <DType.TIMESTAMPTZ: 'TIMESTAMPTZ'>: 'TIMESTAMPTZ', <DType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>: 'TIMESTAMP', <DType.INT128: 'INT128'>: 'LARGEINT', <DType.TEXT: 'TEXT'>: 'STRING'}
PROPERTIES_LOCATION = {<class 'sqlglot.expressions.properties.AggregateKeyProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.AllowedValuesProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.AlgorithmProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.ApiProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.ApplicationProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.AutoIncrementProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.AutoRefreshProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.BackupProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.BlockCompressionProperty'>: <PropertiesLocation.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.properties.CalledOnNullInputProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.CatalogProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.CharacterSetProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.ChecksumProperty'>: <PropertiesLocation.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.properties.CollateProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.ComputeProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.CopyGrantsProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.CopyTagsProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.query.Cluster'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.ClusteredByProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.ClusterProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.DistributedByProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.DuplicateKeyProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.DataBlocksizeProperty'>: <PropertiesLocation.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.properties.DatabaseProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.DataDeletionProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.DefinerProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.DictRange'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.DictProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.DynamicProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.DistKeyProperty'>: <PropertiesLocation.UNSUPPORTED: 'UNSUPPORTED'>, <class 'sqlglot.expressions.properties.DistStyleProperty'>: <PropertiesLocation.UNSUPPORTED: 'UNSUPPORTED'>, <class 'sqlglot.expressions.properties.EmptyProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.EncodeProperty'>: <PropertiesLocation.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.properties.EngineProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.EnviromentProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.HandlerProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.ParameterStyleProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.ExecuteAsProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.ExternalProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.FallbackProperty'>: <PropertiesLocation.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.properties.FileFormatProperty'>: <PropertiesLocation.POST_WITH: 'POST_WITH'>, <class 'sqlglot.expressions.properties.FreespaceProperty'>: <PropertiesLocation.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.properties.GlobalProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.HeapProperty'>: <PropertiesLocation.POST_WITH: 'POST_WITH'>, <class 'sqlglot.expressions.properties.HybridProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.InheritsProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.IcebergProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.IgnoreGrantsProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.IncludeProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.InputModelProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.InteractiveProperty'>: <PropertiesLocation.UNSUPPORTED: 'UNSUPPORTED'>, <class 'sqlglot.expressions.properties.IsolatedLoadingProperty'>: <PropertiesLocation.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.properties.JournalProperty'>: <PropertiesLocation.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.properties.LanguageProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.LikeProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.LocationProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.LockProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.LockingProperty'>: <PropertiesLocation.POST_ALIAS: 'POST_ALIAS'>, <class 'sqlglot.expressions.properties.LogProperty'>: <PropertiesLocation.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.properties.MaskingProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.MaterializedProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.MergeBlockRatioProperty'>: <PropertiesLocation.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.properties.ModuleProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.NetworkProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.NoPrimaryIndexProperty'>: <PropertiesLocation.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.properties.OnProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.OnCommitProperty'>: <PropertiesLocation.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.properties.OptionsProperty'>: <PropertiesLocation.UNSUPPORTED: 'UNSUPPORTED'>, <class 'sqlglot.expressions.query.Order'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.OutputModelProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.PartitionedByProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.PartitionedOfProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.PhysicalProperty'>: <PropertiesLocation.UNSUPPORTED: 'UNSUPPORTED'>, <class 'sqlglot.expressions.constraints.PrimaryKey'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.Property'>: <PropertiesLocation.POST_WITH: 'POST_WITH'>, <class 'sqlglot.expressions.properties.RefreshTriggerProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.RemoteWithConnectionModelProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.ReturnsProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.RollupProperty'>: <PropertiesLocation.UNSUPPORTED: 'UNSUPPORTED'>, <class 'sqlglot.expressions.properties.RowAccessProperty'>: <PropertiesLocation.UNSUPPORTED: 'UNSUPPORTED'>, <class 'sqlglot.expressions.properties.RowFormatProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.RowFormatDelimitedProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.RowFormatSerdeProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.SampleProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.SchemaCommentProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.SecureProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.SecurityIntegrationProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.SerdeProperties'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.ddl.Set'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.SettingsProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.SetProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.SetConfigProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.SharingProperty'>: <PropertiesLocation.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.ddl.SequenceProperties'>: <PropertiesLocation.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.ddl.TriggerProperties'>: <PropertiesLocation.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.properties.SortKeyProperty'>: <PropertiesLocation.UNSUPPORTED: 'UNSUPPORTED'>, <class 'sqlglot.expressions.properties.SqlReadWriteProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.SqlSecurityProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.StabilityProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.StorageHandlerProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.StorageProperty'>: <PropertiesLocation.UNSUPPORTED: 'UNSUPPORTED'>, <class 'sqlglot.expressions.properties.StreamingTableProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.StrictProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.Tags'>: <PropertiesLocation.POST_WITH: 'POST_WITH'>, <class 'sqlglot.expressions.properties.TableSpaceProperty'>: <PropertiesLocation.UNSUPPORTED: 'UNSUPPORTED'>, <class 'sqlglot.expressions.properties.TemporaryProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.ToTableProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.TransientProperty'>: <PropertiesLocation.UNSUPPORTED: 'UNSUPPORTED'>, <class 'sqlglot.expressions.properties.TransformModelProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.ddl.MergeTreeTTL'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.UnloggedProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.UsingProperty'>: <PropertiesLocation.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.properties.UsingTemplateProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.ViewAttributeProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.VirtualProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.VolatileProperty'>: <PropertiesLocation.UNSUPPORTED: 'UNSUPPORTED'>, <class 'sqlglot.expressions.properties.WithDataProperty'>: <PropertiesLocation.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.properties.WithJournalTableProperty'>: <PropertiesLocation.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.properties.WithProcedureOptions'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.WithSchemaBindingProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.WithSystemVersioningProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.WithoutRowidProperty'>: <PropertiesLocation.UNSUPPORTED: 'UNSUPPORTED'>, <class 'sqlglot.expressions.properties.ForceProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.PartitionByRangeProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.PartitionByListProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.UniqueKeyProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.BuildProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>}
CAST_MAPPING: ClassVar[dict[sqlglot.expressions.datatypes.DType, str]] = {}
TIMESTAMP_FUNC_TYPES: ClassVar[set[sqlglot.expressions.datatypes.DType]] = set()
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.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 Generator.<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.SessionUser'>: <function MySQLGenerator.<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 rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.UtcTimestamp'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.query.Variadic'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.array.VarMap'>: <function var_map_sql>, <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.math.BitwiseAndAgg'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.math.BitwiseOrAgg'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.math.BitwiseXorAgg'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.math.BitwiseCount'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.string.Chr'>: <function MySQLGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.CurrentDate'>: <function DorisGenerator.<lambda>>, <class 'sqlglot.expressions.functions.CurrentVersion'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.DateAdd'>: <function date_add_sql.<locals>.func>, <class 'sqlglot.expressions.temporal.DateStrToDate'>: <function datestrtodate_sql>, <class 'sqlglot.expressions.temporal.DateSub'>: <function date_add_sql.<locals>.func>, <class 'sqlglot.expressions.temporal.DateTrunc'>: <function DorisGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.Day'>: <function remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.temporal.DayOfMonth'>: <function remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.temporal.DayOfWeek'>: <function remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.temporal.DayOfYear'>: <function remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.aggregate.GroupConcat'>: <function DorisGenerator.<lambda>>, <class 'sqlglot.expressions.core.ILike'>: <function no_ilike_sql>, <class 'sqlglot.expressions.functions.If'>: <function if_sql.<locals>._if_sql>, <class 'sqlglot.expressions.string.Length'>: <function length_or_char_length_sql>, <class 'sqlglot.expressions.aggregate.LogicalOr'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.aggregate.LogicalAnd'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.aggregate.Max'>: <function max_or_greatest>, <class 'sqlglot.expressions.aggregate.Min'>: <function min_or_least>, <class 'sqlglot.expressions.temporal.Month'>: <function remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.core.NullSafeEQ'>: <function MySQLGenerator.<lambda>>, <class 'sqlglot.expressions.core.NullSafeNEQ'>: <function MySQLGenerator.<lambda>>, <class 'sqlglot.expressions.string.NumberToStr'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.query.Pivot'>: <function no_pivot_sql>, <class 'sqlglot.expressions.query.Select'>: <function preprocess.<locals>._to_sql>, <class 'sqlglot.expressions.aggregate.Stddev'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.string.StrPosition'>: <function MySQLGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.StrToDate'>: <function _str_to_date_sql>, <class 'sqlglot.expressions.temporal.StrToTime'>: <function _str_to_date_sql>, <class 'sqlglot.expressions.string.Stuff'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.query.TableSample'>: <function no_tablesample_sql>, <class 'sqlglot.expressions.temporal.TimeFromParts'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.TimestampAdd'>: <function date_add_interval_sql.<locals>.func>, <class 'sqlglot.expressions.temporal.TimestampDiff'>: <function MySQLGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.TimestampSub'>: <function date_add_interval_sql.<locals>.func>, <class 'sqlglot.expressions.temporal.TimeStrToUnix'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.TimeStrToTime'>: <function MySQLGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.TimeToStr'>: <function remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.string.Trim'>: <function trim_sql>, <class 'sqlglot.expressions.math.Trunc'>: <function MySQLGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.TsOrDsAdd'>: <function DorisGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.TsOrDsDiff'>: <function MySQLGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.TsOrDsToDate'>: <function DorisGenerator.<lambda>>, <class 'sqlglot.expressions.string.Unicode'>: <function MySQLGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.UnixToTime'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.aggregate.VariancePop'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.Week'>: <function remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.temporal.WeekOfYear'>: <function remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.temporal.Year'>: <function remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.temporal.AddMonths'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.core.ApproxDistinct'>: <function approx_count_distinct_sql>, <class 'sqlglot.expressions.aggregate.ArgMax'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.aggregate.ArgMin'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.array.ArrayFilter'>: <function DorisGenerator.<lambda>>, <class 'sqlglot.expressions.array.ArrayFirst'>: <function DorisGenerator.<lambda>>, <class 'sqlglot.expressions.array.ArrayLast'>: <function DorisGenerator.<lambda>>, <class 'sqlglot.expressions.array.ArrayToString'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.aggregate.ArrayUniqueAgg'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.CurrentTimestamp'>: <function DorisGenerator.<lambda>>, <class 'sqlglot.expressions.math.EuclideanDistance'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.aggregate.Lag'>: <function _lag_lead_sql>, <class 'sqlglot.expressions.aggregate.Lead'>: <function _lag_lead_sql>, <class 'sqlglot.expressions.array.Map'>: <function var_map_sql>, <class 'sqlglot.expressions.properties.Property'>: <function property_sql>, <class 'sqlglot.expressions.aggregate.Quantile'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.core.RegexpLike'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.string.RegexpSplit'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.properties.SchemaCommentProperty'>: <function DorisGenerator.<lambda>>, <class 'sqlglot.expressions.string.Split'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.array.StringToArray'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.StrToUnix'>: <function DorisGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.TimeStrToDate'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.TimeToUnix'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.TimestampTrunc'>: <function DorisGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.UnixToStr'>: <function DorisGenerator.<lambda>>}
RESERVED_KEYWORDS = {'real', 'merge', 'minute', 'repository', 'location', 'signed', 'float', 'tablets', 'follower', 'link', 'system', 'migrations', 'references', 'desc', 'where', 'match_phrase_edge', 'char', 'enable', 'lock', 'starts', 'connection_id', 'comment', 'cached', 'job', 'work', 'index', 'type_cast', 'database', 'tablesample', 'schema', 'auto', 'hostname', 'overwrite', 'decimal', 'account_lock', 'days_sub', 'name', 'binary', 'isnull', 'compact', 'as', 'rows', 'cross', 'append', 'load', 'datetimev1', 'order', 'null', 'repositories', 'stats', 'boolean', 'distributed', 'password_lock_time', 'check', 'alias', 'quantile_state', 'replace', 'datetimev2', 'time', 'decimalv2', 'rebalance', 'copy', 'failed_login_attempts', 'complete', 'dropp', 'ldap_admin_password', 'plugins', 'diagnose', 'export', 'query', 'of', 'variant', 'processlist', 'expired', 'by', 'clean', 'first', 'fields', 'begin', 'into', 'json', 'datetime', 'grant', 'current', 'committed', 'enter', 'migrate', 'rollup', 'sync', 'list', 'lateral', 'binlog', 'adddate', 'character', 'session', 'insert', 'duplicate', 'filter', 's3', 'distribution', 'localtimestamp', 'after', 'match_all', 'hub', 'low_priority', 'at', 'integer', 'password_expire', 'superuser', 'collation', 'do', 'generic', 'authors', 'errors', 'serializable', 'struct', 'build', 'demand', 'use_mv', 'full', 'to', 'hll_union', 'using', 'repeatable', 'from', 'recover', 'tables', 'dynamic', 'schedule', 'default', 'days_add', 'streaming', 'proc', 'creation', 'unbounded', 'int', 'end', 'subdate', 'inner', 'chain', 'min', 'verbose', 'scheduler', 'unsigned', 'process', 'level', 'frontends', 'decimalv3', 'is_null_pred', 'release', 'resources', 'natural', 'select', 'bin', 'skew', 'date_sub', 'terminated', 'ipv4', 'char_filter', 'regexp', 'cast', 'true', 'snapshot', 'cube', 'incremental', 'lines', 'on', 'like', 'div', 'analyzed', 'storage', 'date', 'semi', 'consistent', 'count', 'local', 'and', 'extract', 'than', 'alter', 'rlike', 'doris_internal_table_id', 'match_phrase', 'broker', 'decommission', 'offset', 'show', 'plan', 'rollback', 'map', 'profile', 'between', 'bitmap', 'tokenizer', 'key', 'distinctpc', 'except', 'returns', 'foreign', 'backend', 'varchar', 'catalog', 'datediff', 'engine', 'global', 'value', 'create', 'bulk', 'data', 'encryptkeys', 'period', 'warnings', 'play', 'less', 'largeint', 'restrictive', 'range', 'timestampadd', 'keys', 'restore', 'with', 'layout', 'groups', 'repair', 'install', 'all', 'update', 'current_date', 'for', 'year', 'union', 'grants', 'status', 'day', 'max', 'schemas', 'path', 'asof', 'following', 'config', 'user', 'brief', 'date_floor', 'non_nullable', 'match_phrase_prefix', 'rename', 'tablet', 'inverted', 'cancel', 'routine', 'write', 'jsonb', 'manual', 'exclude', 'file', 'vault', 'date_ceil', 'or', 'intersect', 'jobs', 'split', 'minus', 'is', 'engines', 'outer', 'resource', 'deferred', 'memo', 'temporary', 'both', 'extended', 'view', 'recycle', 'array_range', 'analyze', 'every', 'roles', 'refresh', 'call', 'distinct', 'nulls', 'rewritten', 'backup', 'preceding', 'current_timestamp', 'dual', 'tree', 'external', 'localtime', 'auto_increment', 'physical', 'constraints', 'asc', 'timestampdiff', 'parameter', 'column', 'distinctpcsa', 'ngram_bf', 'uncommitted', 'graph', 'hash', 'columns', 'password', 'ignore', 'maxvalue', 'sets', 'pause', 'leading', 'match_regexp', 'triggers', 'help', 'open', 'match_any', 'modify', 'histogram', 'kill', 'isolation', 'bigint', 'truncate', 'types', 'read', 'right', 'immediate', 'materialized', 'whitelist', 'no', 'mtmv', 'values', 'agg_state', 'function', 'account_unlock', 'having', 'procedure', 'trash', 'bitor', 'date_diff', 'events', 'tinyint', 'false', 'version', 'revoke', 'unique', 'left', 'sum', 'partition', 'property', 'negative', 'hll', 'timestamp', 'trailing', 'soname', 'array', 'dump', 'format', 'ipv6', 'cluster', 'double', 'never', 'workload', 'execute', 'then', 'partitions', 'smallint', 'identified', 'backends', 'infile', 'logical', 'feature', 'optimized', 'limit', 'last', 'quota', 'percent', 'sequence', 'commit', 'clusters', 'set', 'week', 'explain', 'delete', 'observer', 'transaction', 'random', 'month', 'describe', 'when', 'no_use_mv', 'in', 'builtin', 'stream', 'exists', 'join', 'encryptkey', 'current_user', 'ldap', 'collate', 'string', 'variables', 'password_reuse', 'shape', 'date_add', 'admin', 'dateadd', 'plugin', 'text', 'replica', 'belong', 'datev2', 'match_condition', 'is_not_null_pred', 'collect', 'hour', 'next', 'bitmap_union', 'quantile_union', 'trim', 'analyzer', 'type', 'databases', 'start', 'label', 'outfile', 'catalogs', 'try_cast', 'convert', 'current_catalog', 'datev1', 'primary', 'uninstall', 'unlock', 'stop', 'blob', 'use', 'password_history', 'frontend', 'token_filter', 'prepare', 'else', 'parsed', 'names', 'replace_if_not_null', 'case', 'only', 'xor', 'functions', 'match', 'buckets', 'not', 'role', 'tasks', 'constraint', 'sample', 'group', 'hdfs', 'grouping', 'anti', 'policy', 'if', 'charset', 'cron', 'current_time', 'fast', 'disk', 'table', 'interval', 'bitxor', 'second', 'sql_block_rule', 'over', 'force', 'resume', 'free', 'row', 'connection', 'bitand', 'aggregate', 'properties', 'drop', 'intermediate', 'add', 'switch', 'task', 'indexes', 'permissive', 'ends'}
def join_sql( self, expression: sqlglot.expressions.query.Join, join_op: str | None = None) -> str:
618    def join_sql(self, expression: exp.Join, join_op: str | None = None) -> str:
619        if expression.is_semi_or_anti_join and not expression.side:
620            expression.set("side", "LEFT")
621        return super().join_sql(expression, join_op=join_op)
def filter_sql(self, expression: sqlglot.expressions.core.Filter) -> str:
623    def filter_sql(self, expression: exp.Filter) -> str:
624        agg = expression.this
625        arg = agg.this
626        count_star = isinstance(agg, exp.Count) and (arg is None or arg == exp.Star())
627        if isinstance(arg, exp.Distinct) and len(arg.expressions) == 1:
628            arg = arg.expressions[0]
629        if isinstance(arg, exp.Paren):
630            arg = arg.unnest()
631
632        if (
633            not isinstance(agg, (exp.Count, exp.Sum, exp.Avg, exp.Min, exp.Max, exp.AnyValue))
634            or (isinstance(expression.parent, exp.Window) and expression.arg_key == "this")
635            or agg.expressions
636            or isinstance(arg, (exp.Distinct, exp.Order, exp.Limit, exp.HavingMax, exp.Tuple))
637            or (not count_star and find_in_scope(agg, exp.Star))
638        ):
639            self.unsupported("Cannot rewrite this aggregate FILTER for Doris")
640            return super().filter_sql(expression)
641
642        return no_filter_sql(self, expression.copy())
def countif_sql(self, expression: sqlglot.expressions.aggregate.CountIf) -> str:
644    def countif_sql(self, expression: exp.CountIf) -> str:
645        cond = expression.this
646        distinct = isinstance(cond, exp.Distinct)
647        arg = exp.If(this=cond.expressions[0] if distinct else cond, true=exp.Literal.number(1))
648        return self.func("COUNT", exp.Distinct(expressions=[arg]) if distinct else arg)
def jsonextractscalar_sql(self, expression: sqlglot.expressions.json.JSONExtractScalar) -> str:
650    def jsonextractscalar_sql(self, expression: exp.JSONExtractScalar) -> str:
651        value = self.func("GET_JSON_STRING", expression.this, expression.expression)
652        if expression.args.get("scalar_only"):
653            kind = exp.JSONType(this=expression.this, expression=expression.expression)
654            return self.func("IF", kind.isin("array", "object"), exp.null(), value)
655        return value
def datediff_sql(self, expression: sqlglot.expressions.temporal.DateDiff) -> str:
657    def datediff_sql(self, expression: exp.DateDiff) -> str:
658        unit = map_date_part(expression.unit)
659        boundary = expression.args.get("date_part_boundary")
660        if not unit or (boundary and unit.name == "DAY"):
661            return MySQLGenerator.TRANSFORMS[exp.DateDiff](self, expression)
662
663        start, end = expression.expression, expression.this
664        if dow := week_unit_to_dow(unit):
665            unit = exp.var("WEEK")
666            if boundary and dow != 1:
667                # Align the requested week start with the Monday used by DATE_TRUNC.
668                shift = exp.Interval(this=exp.Literal.number(8 - dow), unit=exp.var("DAY"))
669                start, end = start + shift, end + shift
670
671        if unit.name == "MILLISECOND":
672            if boundary:
673                # Doris DATE_TRUNC stops at seconds. Count milliseconds from the earliest date.
674                origin = exp.Literal.string("0000-01-01")
675                end_ms = exp.func("MILLISECONDS_DIFF", end, origin)
676                start_ms = exp.func("MILLISECONDS_DIFF", start, origin)
677                return self.sql(exp.paren(end_ms - start_ms))
678            return self.func("MILLISECONDS_DIFF", end, start)
679
680        if unit.name in ("YEAR", "QUARTER", "MONTH", "WEEK", "DAY", "HOUR", "MINUTE", "SECOND"):
681            if boundary:
682                # TIMESTAMPDIFF counts complete units. Truncating both operands counts boundaries.
683                start = exp.TimestampTrunc(this=start, unit=unit.copy())
684                end = exp.TimestampTrunc(this=end, unit=unit.copy())
685        elif unit.name != "MICROSECOND":
686            self.unsupported(f"Unsupported Doris date difference unit: {unit.name}")
687
688        return self.func("TIMESTAMPDIFF", unit, start, end)
def array_sql(self, expression: sqlglot.expressions.array.Array) -> str:
690    def array_sql(self, expression: exp.Array) -> str:
691        args = expression.expressions
692        has_single_query_arg = len(args) == 1 and isinstance(args[0], (exp.Query, exp.Values))
693        if has_single_query_arg and not expression.args.get("value_constructor"):
694            self.unsupported("Doris does not support ARRAY constructors from a query")
695        return self.func("ARRAY", *args)
def datatype_sql(self, expression: sqlglot.expressions.datatypes.DataType) -> str:
697    def datatype_sql(self, expression: exp.DataType) -> str:
698        if self.dialect.version < (4, 0, 3) and expression.is_type(exp.DType.TIMESTAMPTZ):
699            self.unsupported("TIMESTAMPTZ requires Doris 4.0.3 or later")
700            expression = expression.copy()
701            expression.set("this", exp.DType.DATETIME)
702        return super().datatype_sql(expression)
def columndef_sql( self, expression: sqlglot.expressions.query.ColumnDef, sep: str = ' ') -> str:
704    def columndef_sql(self, expression: exp.ColumnDef, sep: str = " ") -> str:
705        parent = expression.parent
706        if isinstance(parent, exp.DataType) and parent.is_type(exp.DType.STRUCT):
707            sep = ": "
708        return super().columndef_sql(expression, sep)
def struct_sql(self, expression: sqlglot.expressions.array.Struct) -> str:
710    def struct_sql(self, expression: exp.Struct) -> str:
711        fields = expression.expressions
712        if not any(isinstance(field, exp.PropertyEQ) for field in fields):
713            return self.func("STRUCT", *fields)
714
715        args: list[exp.Expr] = []
716        for i, field in enumerate(fields, 1):
717            if isinstance(field, exp.PropertyEQ):
718                key = field.this
719                if isinstance(key, exp.Identifier):
720                    key = exp.Literal.string(key.name)
721                elif not key.is_string:
722                    self.unsupported("Doris requires literal field names in NAMED_STRUCT")
723                args.extend((key, field.expression))
724            else:
725                args.extend((exp.Literal.string(f"col{i}"), field))
726
727        return self.func("NAMED_STRUCT", *args)
def arrayagg_sql(self, expression: sqlglot.expressions.aggregate.ArrayAgg) -> str:
729    def arrayagg_sql(self, expression: exp.ArrayAgg) -> str:
730        name = "COLLECT_LIST" if expression.args.get("nulls_excluded") else "ARRAY_AGG"
731        sql = self.func(name, expression.this)
732        if isinstance(expression.this, exp.Order) or isinstance(
733            expression.parent, (exp.Filter, exp.WithinGroup)
734        ):
735            self.unsupported(f"Doris does not support aggregate ORDER BY or FILTER on {name}")
736            return sql
737        if expression.args.get("null_on_empty") and not (
738            isinstance(expression.parent, exp.Window) and expression.arg_key == "this"
739        ):
740            return self.func("NULLIF", sql, exp.array())
741        return sql
def window_sql(self, expression: sqlglot.expressions.query.Window) -> str:
743    def window_sql(self, expression: exp.Window) -> str:
744        sql = super().window_sql(expression)
745        agg = expression.this
746        if isinstance(agg, exp.ArrayAgg) and agg.args.get("null_on_empty"):
747            return self.func("NULLIF", sql, exp.array())
748        return sql
def uniquekeyproperty_sql( self, expression: sqlglot.expressions.properties.UniqueKeyProperty, prefix: str = 'UNIQUE KEY') -> str:
750    def uniquekeyproperty_sql(
751        self, expression: exp.UniqueKeyProperty, prefix: str = "UNIQUE KEY"
752    ) -> str:
753        create_stmt = expression.find_ancestor(exp.Create)
754        if create_stmt and create_stmt.args["properties"].find(exp.MaterializedProperty):
755            return super().uniquekeyproperty_sql(expression, prefix="KEY")
756
757        return super().uniquekeyproperty_sql(expression)
def partitionrange_sql(self, expression: sqlglot.expressions.query.PartitionRange) -> str:
759    def partitionrange_sql(self, expression: exp.PartitionRange) -> str:
760        name = self.sql(expression, "this")
761        values = expression.expressions
762
763        if len(values) != 1:
764            # Multiple values: use VALUES [ ... )
765            if values and isinstance(values[0], list):
766                values_sql = ", ".join(
767                    f"({', '.join(self.sql(v) for v in inner)})" for inner in values
768                )
769            else:
770                values_sql = ", ".join(f"({self.sql(v)})" for v in values)
771
772            return f"PARTITION {name} VALUES [{values_sql})"
773
774        return f"PARTITION {name} VALUES LESS THAN ({self.sql(values[0])})"
def partitionbyrangepropertydynamic_sql( self, expression: sqlglot.expressions.properties.PartitionByRangePropertyDynamic) -> str:
776    def partitionbyrangepropertydynamic_sql(
777        self, expression: exp.PartitionByRangePropertyDynamic
778    ) -> str:
779        # Generates: FROM ("start") TO ("end") INTERVAL N UNIT
780        start = self.sql(expression, "start")
781        end = self.sql(expression, "end")
782        every = expression.args.get("every")
783
784        if every:
785            number = self.sql(every, "this")
786            interval = f"INTERVAL {number} {self.sql(every, 'unit')}"
787        else:
788            interval = ""
789
790        return f"FROM ({start}) TO ({end}) {interval}"
def partitionedbyproperty_sql( self, expression: sqlglot.expressions.properties.PartitionedByProperty) -> str:
792    def partitionedbyproperty_sql(self, expression: exp.PartitionedByProperty) -> str:
793        this = expression.this
794        if isinstance(this, exp.Schema):
795            return f"PARTITION BY ({self.expressions(this, flat=True)})"
796        return f"PARTITION BY ({self.sql(this)})"
def table_sql( self, expression: sqlglot.expressions.query.Table, sep: str = ' AS ') -> str:
798    def table_sql(self, expression: exp.Table, sep: str = " AS ") -> str:
799        """Override table_sql to avoid AS keyword in UPDATE and DELETE statements."""
800        ancestor = expression.find_ancestor(exp.Update, exp.Delete, exp.Select)
801        if not isinstance(ancestor, exp.Select):
802            sep = " "
803        return super().table_sql(expression, sep=sep)

Override table_sql to avoid AS keyword in UPDATE and DELETE statements.

def tsordstodatetime_sql(self, expression: sqlglot.expressions.temporal.TsOrDsToDatetime) -> str:
805    def tsordstodatetime_sql(self, expression: exp.TsOrDsToDatetime) -> str:
806        if expression.this.is_string:
807            # A TIMESTAMP literal infers fractional precision. A bare DATETIME cast uses zero.
808            return f"TIMESTAMP {self.sql(expression, 'this')}"
809        return super().tsordstodatetime_sql(expression)
Inherited Members
sqlglot.generator.Generator
Generator
WINDOW_FUNCS_WITH_NULL_ORDERING
WINDOW_FUNCS_REQUIRING_ORDER
IGNORE_NULLS_IN_FUNC
IGNORE_NULLS_BEFORE_ORDER
EXCEPT_INTERSECT_SUPPORT_ALL_CLAUSE
CREATE_FUNCTION_RETURN_AS
MATCHED_BY_SOURCE
SUPPORTS_MERGE_WHERE
MERGE_SCHEMA_EVOLUTION_MIN_VERSION
MERGE_ALL_BY_NAME
SINGLE_STRING_INTERVAL
AUTO_REFRESH_BARE_INTERVALS
GROUPINGS_SEP
SUPPORTS_GROUPING_SETS_AS_SUFFIX
INDEX_ON
INOUT_SEPARATOR
DIRECTED_JOINS
SUPPORTS_NEAREST_JOIN
SUPPORTS_MATCH_CONDITION
MATCH_CONDITION_IN_ON
QUERY_HINTS
IS_BOOL_ALLOWED
SAFE_INT_DIVISION
LIMIT_IS_TOP
RETURNING_END
EXTRACT_ALLOWS_QUOTES
TZ_TO_WITH_TIME_ZONE
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
DATA_TYPE_SPECIFIERS_ALLOWED
ENSURE_BOOLS
CTE_RECURSIVE_KEYWORD_REQUIRED
SUPPORTS_SINGLE_ARG_CONCAT
SUPPORTS_TABLE_ALIAS_COLUMNS
SUPPORTS_NAMED_CTE_COLUMNS
UNPIVOT_ALIASES_ARE_IDENTIFIERS
PIVOT_ALIAS_WITH_AS
INSERT_OVERWRITE
SUPPORTS_SELECT_INTO
SUPPORTS_OPTIMIZE
SUPPORTS_EXECUTE_IMMEDIATE
SUPPORTS_UNLOGGED_TABLES
SUPPORTS_CREATE_TABLE_LIKE
SUPPORTS_ALTER_COLUMN_IF_EXISTS
LIKE_PROPERTY_INSIDE_SCHEMA
MULTI_ARG_DISTINCT
SUPPORTS_NESTED_JSON_SELECT
JSON_PATH_SINGLE_QUOTE_ESCAPE
JSON_PATH_KEY_QUOTED_FORCES_BRACKETS
SUPPORTED_JSON_PATH_PARTS
CAN_IMPLEMENT_ARRAY_ANY
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
QUOTE_JSON_PATH
SUPPORTS_EXPLODING_PROJECTIONS
ARRAY_CONCAT_IS_VAR_LEN
SUPPORTS_CONVERT_TIMEZONE
SUPPORTS_UNIX_SECONDS
ALTER_SET_WRAPPED
NORMALIZE_EXTRACT_DATE_PARTS
DAYOFWEEK_ZERO_BASED
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
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
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
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
columnconstraint_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
per_sql
hint_sql
indexparameters_sql
index_sql
dynamicidentifier_sql
identifier_sql
hex_sql
lowerhex_sql
inputoutputformat_sql
national_sql
properties_sql
root_properties
properties
with_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
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
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
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
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
trim_sql
convert_concat_args
concat_sql
concatws_sql
check_sql
foreignkey_sql
primarykey_sql
timeserieskey_sql
if_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
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
strtotime_sql
strtodate_sql
parsedatetime_sql
currentdate_sql
collate_sql
command_sql
optimize_sql
comment_sql
mergetreettlaction_sql
mergetreettl_sql
transaction_sql
commit_sql
rollback_sql
modifycolumn_sql
alterindex_sql
alterdiststyle_sql
altersortkey_sql
renamecolumn_sql
alterset_sql
alter_sql
altersession_sql
add_column_sql
droppartition_sql
dropprimarykey_sql
addconstraint_sql
replacecolumns_sql
addpartition_sql
distinct_sql
respectnulls_sql
havingmax_sql
intdiv_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
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
use_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
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
tsordstodate_sql
unixdate_sql
lastday_sql
dateadd_sql
arrayinsert_sql
arrayany_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
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
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
datetrunc_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
sqlglot.generators.mysql.MySQLGenerator
DAYOFWEEK_NAME
BYTE_STRING_FUNCTION
VARIANCE_NAME
SELECT_KINDS
TRY_SUPPORTED
SUPPORTS_UESCAPE
SUPPORTS_DECODE_CASE
SUPPORTS_MODIFY_COLUMN
SUPPORTS_CHANGE_COLUMN
AFTER_HAVING_MODIFIER_TRANSFORMS
INTERVAL_ALLOWS_PLURAL_FORM
LOCKING_READS_SUPPORTED
CAST_TO_INT_ROUNDS
INT_DIV_OPERATOR
JOIN_HINTS
TABLE_HINTS
DUPLICATE_KEY_UPDATE_WITH_SET
QUERY_HINT_SEP
VALUES_AS_TABLE
NVL2_SUPPORTED
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
SUPPORTS_MEDIAN
ALTER_PARTITION_OPTIONS
UNSIGNED_TYPE_MAPPING
TIMESTAMP_TYPE_MAPPING
LIMIT_FETCH
LIMIT_ONLY_LITERALS
CHAR_CAST_MAPPING
SIGNED_CAST_MAPPING
SQL_SECURITY_VIEW_LOCATION
makeinterval_sql
locate_properties
computedcolumnconstraint_sql
arraycontainsall_sql
arraycontainedby_sql
dpipe_sql
extract_sql
jsonarraycontains_sql
cast_sql
show_sql
alterrename_sql
altercolumn_sql
timestamptrunc_sql
converttimezone_sql
attimezone_sql
isascii_sql
ignorenulls_sql
currentschema_sql
partition_sql
partitionbyrangeproperty_sql
partitionbylistproperty_sql
partitionlist_sql