Edit on GitHub

sqlglot.generators.postgres

  1from __future__ import annotations
  2
  3import typing as t
  4
  5from sqlglot import exp, generator, transforms
  6from sqlglot.dialects.dialect import (
  7    DATE_ADD_OR_SUB,
  8    JSON_EXTRACT_TYPE,
  9    any_value_to_max_sql,
 10    array_append_sql,
 11    array_concat_sql,
 12    bool_xor_sql,
 13    count_if_to_sum,
 14    datestrtodate_sql,
 15    filter_array_using_unnest,
 16    generate_series_sql,
 17    getbit_sql,
 18    groupconcat_sql,
 19    inline_array_sql,
 20    json_extract_segments,
 21    json_path_key_only_name,
 22    max_or_greatest,
 23    merge_without_target_sql,
 24    min_or_least,
 25    no_last_day_sql,
 26    no_map_from_entries_sql,
 27    no_paren_current_date_sql,
 28    no_pivot_sql,
 29    no_trycast_sql,
 30    regexp_replace_global_modifier,
 31    rename_func,
 32    sha256_sql,
 33    sha2_digest_sql,
 34    strposition_sql,
 35    struct_extract_sql,
 36    timestamptrunc_sql,
 37    timestrtotime_sql,
 38    trim_sql,
 39    ts_or_ds_add_cast,
 40)
 41from sqlglot.generator import unsupported_args
 42from sqlglot.helper import seq_get
 43
 44
 45DATE_DIFF_FACTOR = {
 46    "MICROSECOND": " * 1000000",
 47    "MILLISECOND": " * 1000",
 48    "SECOND": "",
 49    "MINUTE": " / 60",
 50    "HOUR": " / 3600",
 51    "DAY": " / 86400",
 52}
 53
 54
 55def _date_add_sql(kind: str) -> t.Callable[[PostgresGenerator, DATE_ADD_OR_SUB], str]:
 56    def func(self: PostgresGenerator, expression: DATE_ADD_OR_SUB) -> str:
 57        if isinstance(expression, exp.TsOrDsAdd):
 58            expression = ts_or_ds_add_cast(expression)
 59
 60        this = self.sql(expression, "this")
 61        unit = expression.args.get("unit")
 62
 63        e = self._simplify_unless_literal(expression.expression)
 64        if isinstance(e, exp.Interval):
 65            return f"{this} {kind} {self.sql(e)}"
 66        elif isinstance(e, exp.Literal):
 67            e.set("is_string", True)
 68        elif e.is_number:
 69            e = exp.Literal.string(e.to_py())
 70        else:
 71            one = exp.Literal.number(1)
 72            interval_times_value = exp.Interval(this=one, unit=unit) * e
 73            return f"{this} {kind} {self.sql(interval_times_value)}"
 74
 75        return f"{this} {kind} {self.sql(exp.Interval(this=e, unit=unit))}"
 76
 77    return func
 78
 79
 80def _date_diff_sql(self: PostgresGenerator, expression: exp.DateDiff | exp.TsOrDsDiff) -> str:
 81    unit = expression.text("unit").upper()
 82    factor = DATE_DIFF_FACTOR.get(unit)
 83
 84    end = f"CAST({self.sql(expression, 'this')} AS TIMESTAMP)"
 85    start = f"CAST({self.sql(expression, 'expression')} AS TIMESTAMP)"
 86
 87    if factor is not None:
 88        return f"CAST(EXTRACT(epoch FROM {end} - {start}){factor} AS BIGINT)"
 89
 90    age = f"AGE({end}, {start})"
 91
 92    if unit == "WEEK":
 93        unit = f"EXTRACT(days FROM ({end} - {start})) / 7"
 94    elif unit == "MONTH":
 95        unit = f"EXTRACT(year FROM {age}) * 12 + EXTRACT(month FROM {age})"
 96    elif unit == "QUARTER":
 97        unit = f"EXTRACT(year FROM {age}) * 4 + EXTRACT(month FROM {age}) / 3"
 98    elif unit == "YEAR":
 99        unit = f"EXTRACT(year FROM {age})"
100    else:
101        unit = age
102
103    return f"CAST({unit} AS BIGINT)"
104
105
106def _substring_sql(self: PostgresGenerator, expression: exp.Substring) -> str:
107    this = self.sql(expression, "this")
108    start = self.sql(expression, "start")
109    length = self.sql(expression, "length")
110
111    from_part = f" FROM {start}" if start else ""
112    for_part = f" FOR {length}" if length else ""
113
114    return f"SUBSTRING({this}{from_part}{for_part})"
115
116
117def _auto_increment_to_serial(expression: exp.Expr) -> exp.Expr:
118    auto = expression.find(exp.AutoIncrementColumnConstraint)
119
120    if auto:
121        expression.args["constraints"].remove(auto.parent)
122        kind = expression.args["kind"]
123
124        if kind.this == exp.DType.INT:
125            kind.replace(exp.DataType(this=exp.DType.SERIAL))
126        elif kind.this == exp.DType.SMALLINT:
127            kind.replace(exp.DataType(this=exp.DType.SMALLSERIAL))
128        elif kind.this == exp.DType.BIGINT:
129            kind.replace(exp.DataType(this=exp.DType.BIGSERIAL))
130
131    return expression
132
133
134def _serial_to_generated(expression: exp.Expr) -> exp.Expr:
135    if not isinstance(expression, exp.ColumnDef):
136        return expression
137    kind = expression.kind
138    if not kind:
139        return expression
140
141    if kind.this == exp.DType.SERIAL:
142        data_type = exp.DataType(this=exp.DType.INT)
143    elif kind.this == exp.DType.SMALLSERIAL:
144        data_type = exp.DataType(this=exp.DType.SMALLINT)
145    elif kind.this == exp.DType.BIGSERIAL:
146        data_type = exp.DataType(this=exp.DType.BIGINT)
147    else:
148        data_type = None
149
150    if data_type:
151        expression.args["kind"].replace(data_type)
152        constraints = expression.args["constraints"]
153        generated = exp.ColumnConstraint(kind=exp.GeneratedAsIdentityColumnConstraint(this=False))
154        notnull = exp.ColumnConstraint(kind=exp.NotNullColumnConstraint())
155
156        if notnull not in constraints:
157            constraints.insert(0, notnull)
158        if generated not in constraints:
159            constraints.insert(0, generated)
160
161    return expression
162
163
164def _json_extract_sql(
165    name: str, op: str
166) -> t.Callable[[PostgresGenerator, JSON_EXTRACT_TYPE], str]:
167    def _generate(self: PostgresGenerator, expression: JSON_EXTRACT_TYPE) -> str:
168        if expression.args.get("only_json_types"):
169            return json_extract_segments(name, quoted_index=False, op=op)(self, expression)
170        return json_extract_segments(name)(self, expression)
171
172    return _generate
173
174
175def _unix_to_time_sql(self: PostgresGenerator, expression: exp.UnixToTime) -> str:
176    scale = expression.args.get("scale")
177    timestamp = expression.this
178
179    if scale in (None, exp.UnixToTime.SECONDS):
180        return self.func("TO_TIMESTAMP", timestamp, self.format_time(expression))
181
182    return self.func(
183        "TO_TIMESTAMP",
184        exp.Div(this=timestamp, expression=exp.func("POW", 10, scale)),
185        self.format_time(expression),
186    )
187
188
189def _levenshtein_sql(self: PostgresGenerator, expression: exp.Levenshtein) -> str:
190    name = "LEVENSHTEIN_LESS_EQUAL" if expression.args.get("max_dist") else "LEVENSHTEIN"
191
192    return rename_func(name)(self, expression)
193
194
195def _versioned_anyvalue_sql(self: PostgresGenerator, expression: exp.AnyValue) -> str:
196    # https://www.postgresql.org/docs/16/functions-aggregate.html
197    # https://www.postgresql.org/about/featurematrix/
198    if self.dialect.version < (16,):
199        return any_value_to_max_sql(self, expression)
200
201    return rename_func("ANY_VALUE")(self, expression)
202
203
204def _round_sql(self: PostgresGenerator, expression: exp.Round) -> str:
205    this = self.sql(expression, "this")
206    decimals = self.sql(expression, "decimals")
207
208    if not decimals:
209        return self.func("ROUND", this)
210
211    if not expression.type:
212        from sqlglot.optimizer.annotate_types import annotate_types
213
214        expression = annotate_types(expression, dialect=self.dialect)
215
216    # ROUND(double precision, integer) is not permitted in Postgres
217    # so it's necessary to cast to decimal before rounding.
218    if expression.this.is_type(exp.DType.DOUBLE):
219        decimal_type = exp.DType.DECIMAL.into_expr(expressions=expression.expressions)
220        this = self.sql(exp.Cast(this=this, to=decimal_type))
221
222    return self.func("ROUND", this, decimals)
223
224
225class PostgresGenerator(generator.Generator):
226    SELECT_KINDS: tuple[str, ...] = ()
227    TRY_SUPPORTED = False
228    SUPPORTS_UESCAPE = False
229    SUPPORTS_DECODE_CASE = False
230
231    AFTER_HAVING_MODIFIER_TRANSFORMS = generator.AFTER_HAVING_MODIFIER_TRANSFORMS
232
233    SINGLE_STRING_INTERVAL = True
234    RENAME_TABLE_WITH_DB = False
235    LOCKING_READS_SUPPORTED = True
236    JOIN_HINTS = False
237    TABLE_HINTS = False
238    QUERY_HINTS = False
239    NVL2_SUPPORTED = False
240    PARAMETER_TOKEN = "$"
241    NAMED_PLACEHOLDER_TOKEN = "%"
242    TABLESAMPLE_SIZE_IS_ROWS = False
243    TABLESAMPLE_SEED_KEYWORD = "REPEATABLE"
244    SUPPORTS_SELECT_INTO = True
245    JSON_TYPE_REQUIRED_FOR_EXTRACTION = True
246    SUPPORTS_UNLOGGED_TABLES = True
247    LIKE_PROPERTY_INSIDE_SCHEMA = True
248    MULTI_ARG_DISTINCT = False
249    CAN_IMPLEMENT_ARRAY_ANY = True
250    SUPPORTS_WINDOW_EXCLUDE = True
251    COPY_HAS_INTO_KEYWORD = False
252    ARRAY_CONCAT_IS_VAR_LEN = False
253    SUPPORTS_MEDIAN = False
254    ARRAY_SIZE_DIM_REQUIRED: bool | None = True
255    SUPPORTS_BETWEEN_FLAGS = True
256    INOUT_SEPARATOR = ""  # PostgreSQL uses "INOUT" (no space)
257
258    SUPPORTED_JSON_PATH_PARTS = {
259        exp.JSONPathKey,
260        exp.JSONPathRoot,
261        exp.JSONPathSubscript,
262    }
263
264    def lateral_sql(self, expression: exp.Lateral) -> str:
265        sql = super().lateral_sql(expression)
266
267        if expression.args.get("cross_apply") is not None:
268            sql = f"{sql} ON TRUE"
269
270        return sql
271
272    TYPE_MAPPING = {
273        **generator.Generator.TYPE_MAPPING,
274        exp.DType.TINYINT: "SMALLINT",
275        exp.DType.FLOAT: "REAL",
276        exp.DType.DOUBLE: "DOUBLE PRECISION",
277        exp.DType.BINARY: "BYTEA",
278        exp.DType.VARBINARY: "BYTEA",
279        exp.DType.ROWVERSION: "BYTEA",
280        exp.DType.DATETIME: "TIMESTAMP",
281        exp.DType.TIMESTAMPNTZ: "TIMESTAMP",
282        exp.DType.BLOB: "BYTEA",
283    }
284
285    TRANSFORMS = {
286        **{
287            k: v
288            for k, v in generator.Generator.TRANSFORMS.items()
289            if k != exp.CommentColumnConstraint
290        },
291        exp.AnyValue: _versioned_anyvalue_sql,
292        exp.ArrayConcat: array_concat_sql("ARRAY_CAT"),
293        exp.ArrayFilter: filter_array_using_unnest,
294        exp.ArrayAppend: array_append_sql("ARRAY_APPEND"),
295        exp.ArrayPrepend: array_append_sql("ARRAY_PREPEND", swap_params=True),
296        exp.BitwiseAndAgg: rename_func("BIT_AND"),
297        exp.BitwiseOrAgg: rename_func("BIT_OR"),
298        exp.BitwiseXor: lambda self, e: self.binary(e, "#"),
299        exp.BitwiseXorAgg: rename_func("BIT_XOR"),
300        exp.ColumnDef: transforms.preprocess([_auto_increment_to_serial, _serial_to_generated]),
301        exp.CurrentDate: no_paren_current_date_sql,
302        exp.CurrentTimestamp: lambda *_: "CURRENT_TIMESTAMP",
303        exp.CurrentUser: lambda *_: "CURRENT_USER",
304        exp.CurrentVersion: rename_func("VERSION"),
305        exp.DateAdd: _date_add_sql("+"),
306        exp.DateDiff: _date_diff_sql,
307        exp.DateStrToDate: datestrtodate_sql,
308        exp.DateSub: _date_add_sql("-"),
309        exp.Explode: rename_func("UNNEST"),
310        exp.ExplodingGenerateSeries: rename_func("GENERATE_SERIES"),
311        exp.GenerateSeries: generate_series_sql("GENERATE_SERIES"),
312        exp.Getbit: getbit_sql,
313        exp.GroupConcat: lambda self, e: groupconcat_sql(
314            self, e, func_name="STRING_AGG", within_group=False
315        ),
316        exp.IntDiv: rename_func("DIV"),
317        exp.JSONArrayAgg: lambda self, e: self.func(
318            "JSON_AGG",
319            self.sql(e, "this"),
320            suffix=f"{self.sql(e, 'order')})",
321        ),
322        exp.JSONExtract: _json_extract_sql("JSON_EXTRACT_PATH", "->"),
323        exp.JSONExtractScalar: _json_extract_sql("JSON_EXTRACT_PATH_TEXT", "->>"),
324        exp.JSONBExtract: lambda self, e: self.binary(e, "#>"),
325        exp.JSONBExtractScalar: lambda self, e: self.binary(e, "#>>"),
326        exp.JSONBContains: lambda self, e: self.binary(e, "?"),
327        exp.ParseJSON: lambda self, e: self.sql(exp.cast(e.this, exp.DType.JSON)),
328        exp.JSONPathKey: json_path_key_only_name,
329        exp.JSONPathRoot: lambda *_: "",
330        exp.JSONPathSubscript: lambda self, e: self.json_path_part(e.this),
331        exp.LastDay: no_last_day_sql,
332        exp.LogicalOr: rename_func("BOOL_OR"),
333        exp.LogicalAnd: rename_func("BOOL_AND"),
334        exp.Max: max_or_greatest,
335        exp.MapFromEntries: no_map_from_entries_sql,
336        exp.Min: min_or_least,
337        exp.Merge: merge_without_target_sql,
338        exp.PartitionedByProperty: lambda self, e: f"PARTITION BY {self.sql(e, 'this')}",
339        exp.PercentileCont: transforms.preprocess([transforms.add_within_group_for_percentiles]),
340        exp.PercentileDisc: transforms.preprocess([transforms.add_within_group_for_percentiles]),
341        exp.Pivot: no_pivot_sql,
342        exp.Rand: rename_func("RANDOM"),
343        exp.RegexpLike: lambda self, e: self.binary(e, "~"),
344        exp.RegexpILike: lambda self, e: self.binary(e, "~*"),
345        exp.RegexpReplace: lambda self, e: self.func(
346            "REGEXP_REPLACE",
347            e.this,
348            e.expression,
349            e.args.get("replacement"),
350            e.args.get("position"),
351            e.args.get("occurrence"),
352            regexp_replace_global_modifier(e),
353        ),
354        exp.Round: _round_sql,
355        exp.Select: transforms.preprocess(
356            [
357                transforms.eliminate_semi_and_anti_joins,
358                transforms.eliminate_qualify,
359            ]
360        ),
361        exp.SHA2: sha256_sql,
362        exp.SHA2Digest: sha2_digest_sql,
363        exp.StrPosition: lambda self, e: strposition_sql(self, e, func_name="POSITION"),
364        exp.StrToDate: lambda self, e: self.func("TO_DATE", e.this, self.format_time(e)),
365        exp.StrToTime: lambda self, e: self.func("TO_TIMESTAMP", e.this, self.format_time(e)),
366        exp.StructExtract: struct_extract_sql,
367        exp.Substring: _substring_sql,
368        exp.TimeFromParts: rename_func("MAKE_TIME"),
369        exp.TimestampFromParts: rename_func("MAKE_TIMESTAMP"),
370        exp.TimestampTrunc: timestamptrunc_sql(zone=True),
371        exp.TimeStrToTime: timestrtotime_sql,
372        exp.TimeToStr: lambda self, e: self.func("TO_CHAR", e.this, self.format_time(e)),
373        exp.ToChar: lambda self, e: (
374            self.function_fallback_sql(e) if e.args.get("format") else self.tochar_sql(e)
375        ),
376        exp.Trim: trim_sql,
377        exp.TryCast: no_trycast_sql,
378        exp.TsOrDsAdd: _date_add_sql("+"),
379        exp.TsOrDsDiff: _date_diff_sql,
380        exp.UnixToTime: lambda self, e: self.func("TO_TIMESTAMP", e.this),
381        exp.Uuid: lambda *_: "GEN_RANDOM_UUID()",
382        exp.TimeToUnix: lambda self, e: self.func("DATE_PART", exp.Literal.string("epoch"), e.this),
383        exp.VariancePop: rename_func("VAR_POP"),
384        exp.Variance: rename_func("VAR_SAMP"),
385        exp.Xor: bool_xor_sql,
386        exp.Unicode: rename_func("ASCII"),
387        exp.UnixToTime: _unix_to_time_sql,
388        exp.Levenshtein: _levenshtein_sql,
389        exp.JSONObjectAgg: rename_func("JSON_OBJECT_AGG"),
390        exp.JSONBObjectAgg: rename_func("JSONB_OBJECT_AGG"),
391        exp.CountIf: count_if_to_sum,
392    }
393
394    PROPERTIES_LOCATION = {
395        **generator.Generator.PROPERTIES_LOCATION,
396        exp.PartitionedByProperty: exp.Properties.Location.POST_SCHEMA,
397        exp.TransientProperty: exp.Properties.Location.UNSUPPORTED,
398        exp.VolatileProperty: exp.Properties.Location.UNSUPPORTED,
399    }
400
401    def schemacommentproperty_sql(self, expression: exp.SchemaCommentProperty) -> str:
402        self.unsupported("Table comments are not supported in the CREATE statement")
403        return ""
404
405    def commentcolumnconstraint_sql(self, expression: exp.CommentColumnConstraint) -> str:
406        self.unsupported("Column comments are not supported in the CREATE statement")
407        return ""
408
409    def columndef_sql(self, expression: exp.ColumnDef, sep: str = " ") -> str:
410        # PostgreSQL places parameter modes BEFORE parameter name
411        param_constraint = expression.find(exp.InOutColumnConstraint)
412
413        if param_constraint:
414            mode_sql = self.sql(param_constraint)
415            param_constraint.pop()  # Remove to prevent double-rendering
416            base_sql = super().columndef_sql(expression, sep)
417            return f"{mode_sql} {base_sql}"
418
419        return super().columndef_sql(expression, sep)
420
421    def unnest_sql(self, expression: exp.Unnest) -> str:
422        if len(expression.expressions) == 1:
423            arg = expression.expressions[0]
424            if isinstance(arg, exp.GenerateDateArray):
425                generate_series: exp.Expr = exp.GenerateSeries(**arg.args)
426                if isinstance(expression.parent, (exp.From, exp.Join)):
427                    generate_series = (
428                        exp.select("value::date")
429                        .from_(exp.Table(this=generate_series).as_("_t", table=["value"]))
430                        .subquery(expression.args.get("alias") or "_unnested_generate_series")
431                    )
432                return self.sql(generate_series)
433
434            from sqlglot.optimizer.annotate_types import annotate_types
435
436            this = annotate_types(arg, dialect=self.dialect)
437            if this.is_type("array<json>"):
438                while isinstance(this, exp.Cast):
439                    this = this.this
440
441                arg_as_json = self.sql(exp.cast(this, exp.DType.JSON))
442                alias = self.sql(expression, "alias")
443                alias = f" AS {alias}" if alias else ""
444
445                if expression.args.get("offset"):
446                    self.unsupported("Unsupported JSON_ARRAY_ELEMENTS with offset")
447
448                return f"JSON_ARRAY_ELEMENTS({arg_as_json}){alias}"
449
450        return super().unnest_sql(expression)
451
452    def bracket_sql(self, expression: exp.Bracket) -> str:
453        """Forms like ARRAY[1, 2, 3][3] aren't allowed; we need to wrap the ARRAY."""
454        if isinstance(expression.this, exp.Array):
455            expression.set("this", exp.paren(expression.this, copy=False))
456
457        return super().bracket_sql(expression)
458
459    def matchagainst_sql(self, expression: exp.MatchAgainst) -> str:
460        this = self.sql(expression, "this")
461        expressions = [f"{self.sql(e)} @@ {this}" for e in expression.expressions]
462        sql = " OR ".join(expressions)
463        return f"({sql})" if len(expressions) > 1 else sql
464
465    def alterset_sql(self, expression: exp.AlterSet) -> str:
466        exprs = self.expressions(expression, flat=True)
467        exprs = f"({exprs})" if exprs else ""
468
469        access_method = self.sql(expression, "access_method")
470        access_method = f"ACCESS METHOD {access_method}" if access_method else ""
471        tablespace = self.sql(expression, "tablespace")
472        tablespace = f"TABLESPACE {tablespace}" if tablespace else ""
473        option = self.sql(expression, "option")
474
475        return f"SET {exprs}{access_method}{tablespace}{option}"
476
477    def datatype_sql(self, expression: exp.DataType) -> str:
478        if expression.is_type(exp.DType.ARRAY):
479            if expression.expressions:
480                values = self.expressions(expression, key="values", flat=True)
481                return f"{self.expressions(expression, flat=True)}[{values}]"
482            return "ARRAY"
483
484        if expression.is_type(exp.DType.DOUBLE, exp.DType.FLOAT) and expression.expressions:
485            # Postgres doesn't support precision for REAL and DOUBLE PRECISION types
486            return f"FLOAT({self.expressions(expression, flat=True)})"
487
488        return super().datatype_sql(expression)
489
490    def cast_sql(self, expression: exp.Cast, safe_prefix: str | None = None) -> str:
491        this = expression.this
492
493        # Postgres casts DIV() to decimal for transpilation but when roundtripping it's superfluous
494        if isinstance(this, exp.IntDiv) and expression.to == exp.DType.DECIMAL.into_expr():
495            return self.sql(this)
496
497        return super().cast_sql(expression, safe_prefix=safe_prefix)
498
499    def array_sql(self, expression: exp.Array) -> str:
500        exprs = expression.expressions
501        func_name = self.normalize_func("ARRAY")
502
503        if isinstance(seq_get(exprs, 0), exp.Select):
504            return f"{func_name}({self.sql(exprs[0])})"
505
506        return f"{func_name}{inline_array_sql(self, expression)}"
507
508    def computedcolumnconstraint_sql(self, expression: exp.ComputedColumnConstraint) -> str:
509        return f"GENERATED ALWAYS AS ({self.sql(expression, 'this')}) STORED"
510
511    def isascii_sql(self, expression: exp.IsAscii) -> str:
512        return f"({self.sql(expression.this)} ~ '^[[:ascii:]]*$')"
513
514    def ignorenulls_sql(self, expression: exp.IgnoreNulls) -> str:
515        # https://www.postgresql.org/docs/current/functions-window.html
516        self.unsupported("PostgreSQL does not support IGNORE NULLS.")
517        return self.sql(expression.this)
518
519    def respectnulls_sql(self, expression: exp.RespectNulls) -> str:
520        # https://www.postgresql.org/docs/current/functions-window.html
521        self.unsupported("PostgreSQL does not support RESPECT NULLS.")
522        return self.sql(expression.this)
523
524    @unsupported_args("this")
525    def currentschema_sql(self, expression: exp.CurrentSchema) -> str:
526        return "CURRENT_SCHEMA"
527
528    def interval_sql(self, expression: exp.Interval) -> str:
529        unit = expression.text("unit").lower()
530
531        this = expression.this
532        if unit.startswith("quarter") and isinstance(this, exp.Literal):
533            this.replace(exp.Literal.string(int(this.to_py()) * 3))
534            expression.args["unit"].replace(exp.var("MONTH"))
535
536        return super().interval_sql(expression)
537
538    def placeholder_sql(self, expression: exp.Placeholder) -> str:
539        if expression.args.get("jdbc"):
540            return "?"
541
542        this = f"({expression.name})" if expression.this else ""
543        return f"{self.NAMED_PLACEHOLDER_TOKEN}{this}s"
544
545    def arraycontains_sql(self, expression: exp.ArrayContains) -> str:
546        # Convert DuckDB's LIST_CONTAINS(array, value) to PostgreSQL
547        # DuckDB behavior:
548        #   - LIST_CONTAINS([1,2,3], 2) -> true
549        #   - LIST_CONTAINS([1,2,3], 4) -> false
550        #   - LIST_CONTAINS([1,2,NULL], 4) -> false (not NULL)
551        #   - LIST_CONTAINS([1,2,3], NULL) -> NULL
552        #
553        # PostgreSQL equivalent: CASE WHEN value IS NULL THEN NULL
554        #                            ELSE COALESCE(value = ANY(array), FALSE) END
555        value = expression.expression
556        array = expression.this
557
558        coalesce_expr = exp.Coalesce(
559            this=value.eq(exp.Any(this=exp.paren(expression=array, copy=False))),
560            expressions=[exp.false()],
561        )
562
563        case_expr = (
564            exp.Case()
565            .when(exp.Is(this=value, expression=exp.null()), exp.null(), copy=False)
566            .else_(coalesce_expr, copy=False)
567        )
568
569        return self.sql(case_expr)
DATE_DIFF_FACTOR = {'MICROSECOND': ' * 1000000', 'MILLISECOND': ' * 1000', 'SECOND': '', 'MINUTE': ' / 60', 'HOUR': ' / 3600', 'DAY': ' / 86400'}
class PostgresGenerator(sqlglot.generator.Generator):
226class PostgresGenerator(generator.Generator):
227    SELECT_KINDS: tuple[str, ...] = ()
228    TRY_SUPPORTED = False
229    SUPPORTS_UESCAPE = False
230    SUPPORTS_DECODE_CASE = False
231
232    AFTER_HAVING_MODIFIER_TRANSFORMS = generator.AFTER_HAVING_MODIFIER_TRANSFORMS
233
234    SINGLE_STRING_INTERVAL = True
235    RENAME_TABLE_WITH_DB = False
236    LOCKING_READS_SUPPORTED = True
237    JOIN_HINTS = False
238    TABLE_HINTS = False
239    QUERY_HINTS = False
240    NVL2_SUPPORTED = False
241    PARAMETER_TOKEN = "$"
242    NAMED_PLACEHOLDER_TOKEN = "%"
243    TABLESAMPLE_SIZE_IS_ROWS = False
244    TABLESAMPLE_SEED_KEYWORD = "REPEATABLE"
245    SUPPORTS_SELECT_INTO = True
246    JSON_TYPE_REQUIRED_FOR_EXTRACTION = True
247    SUPPORTS_UNLOGGED_TABLES = True
248    LIKE_PROPERTY_INSIDE_SCHEMA = True
249    MULTI_ARG_DISTINCT = False
250    CAN_IMPLEMENT_ARRAY_ANY = True
251    SUPPORTS_WINDOW_EXCLUDE = True
252    COPY_HAS_INTO_KEYWORD = False
253    ARRAY_CONCAT_IS_VAR_LEN = False
254    SUPPORTS_MEDIAN = False
255    ARRAY_SIZE_DIM_REQUIRED: bool | None = True
256    SUPPORTS_BETWEEN_FLAGS = True
257    INOUT_SEPARATOR = ""  # PostgreSQL uses "INOUT" (no space)
258
259    SUPPORTED_JSON_PATH_PARTS = {
260        exp.JSONPathKey,
261        exp.JSONPathRoot,
262        exp.JSONPathSubscript,
263    }
264
265    def lateral_sql(self, expression: exp.Lateral) -> str:
266        sql = super().lateral_sql(expression)
267
268        if expression.args.get("cross_apply") is not None:
269            sql = f"{sql} ON TRUE"
270
271        return sql
272
273    TYPE_MAPPING = {
274        **generator.Generator.TYPE_MAPPING,
275        exp.DType.TINYINT: "SMALLINT",
276        exp.DType.FLOAT: "REAL",
277        exp.DType.DOUBLE: "DOUBLE PRECISION",
278        exp.DType.BINARY: "BYTEA",
279        exp.DType.VARBINARY: "BYTEA",
280        exp.DType.ROWVERSION: "BYTEA",
281        exp.DType.DATETIME: "TIMESTAMP",
282        exp.DType.TIMESTAMPNTZ: "TIMESTAMP",
283        exp.DType.BLOB: "BYTEA",
284    }
285
286    TRANSFORMS = {
287        **{
288            k: v
289            for k, v in generator.Generator.TRANSFORMS.items()
290            if k != exp.CommentColumnConstraint
291        },
292        exp.AnyValue: _versioned_anyvalue_sql,
293        exp.ArrayConcat: array_concat_sql("ARRAY_CAT"),
294        exp.ArrayFilter: filter_array_using_unnest,
295        exp.ArrayAppend: array_append_sql("ARRAY_APPEND"),
296        exp.ArrayPrepend: array_append_sql("ARRAY_PREPEND", swap_params=True),
297        exp.BitwiseAndAgg: rename_func("BIT_AND"),
298        exp.BitwiseOrAgg: rename_func("BIT_OR"),
299        exp.BitwiseXor: lambda self, e: self.binary(e, "#"),
300        exp.BitwiseXorAgg: rename_func("BIT_XOR"),
301        exp.ColumnDef: transforms.preprocess([_auto_increment_to_serial, _serial_to_generated]),
302        exp.CurrentDate: no_paren_current_date_sql,
303        exp.CurrentTimestamp: lambda *_: "CURRENT_TIMESTAMP",
304        exp.CurrentUser: lambda *_: "CURRENT_USER",
305        exp.CurrentVersion: rename_func("VERSION"),
306        exp.DateAdd: _date_add_sql("+"),
307        exp.DateDiff: _date_diff_sql,
308        exp.DateStrToDate: datestrtodate_sql,
309        exp.DateSub: _date_add_sql("-"),
310        exp.Explode: rename_func("UNNEST"),
311        exp.ExplodingGenerateSeries: rename_func("GENERATE_SERIES"),
312        exp.GenerateSeries: generate_series_sql("GENERATE_SERIES"),
313        exp.Getbit: getbit_sql,
314        exp.GroupConcat: lambda self, e: groupconcat_sql(
315            self, e, func_name="STRING_AGG", within_group=False
316        ),
317        exp.IntDiv: rename_func("DIV"),
318        exp.JSONArrayAgg: lambda self, e: self.func(
319            "JSON_AGG",
320            self.sql(e, "this"),
321            suffix=f"{self.sql(e, 'order')})",
322        ),
323        exp.JSONExtract: _json_extract_sql("JSON_EXTRACT_PATH", "->"),
324        exp.JSONExtractScalar: _json_extract_sql("JSON_EXTRACT_PATH_TEXT", "->>"),
325        exp.JSONBExtract: lambda self, e: self.binary(e, "#>"),
326        exp.JSONBExtractScalar: lambda self, e: self.binary(e, "#>>"),
327        exp.JSONBContains: lambda self, e: self.binary(e, "?"),
328        exp.ParseJSON: lambda self, e: self.sql(exp.cast(e.this, exp.DType.JSON)),
329        exp.JSONPathKey: json_path_key_only_name,
330        exp.JSONPathRoot: lambda *_: "",
331        exp.JSONPathSubscript: lambda self, e: self.json_path_part(e.this),
332        exp.LastDay: no_last_day_sql,
333        exp.LogicalOr: rename_func("BOOL_OR"),
334        exp.LogicalAnd: rename_func("BOOL_AND"),
335        exp.Max: max_or_greatest,
336        exp.MapFromEntries: no_map_from_entries_sql,
337        exp.Min: min_or_least,
338        exp.Merge: merge_without_target_sql,
339        exp.PartitionedByProperty: lambda self, e: f"PARTITION BY {self.sql(e, 'this')}",
340        exp.PercentileCont: transforms.preprocess([transforms.add_within_group_for_percentiles]),
341        exp.PercentileDisc: transforms.preprocess([transforms.add_within_group_for_percentiles]),
342        exp.Pivot: no_pivot_sql,
343        exp.Rand: rename_func("RANDOM"),
344        exp.RegexpLike: lambda self, e: self.binary(e, "~"),
345        exp.RegexpILike: lambda self, e: self.binary(e, "~*"),
346        exp.RegexpReplace: lambda self, e: self.func(
347            "REGEXP_REPLACE",
348            e.this,
349            e.expression,
350            e.args.get("replacement"),
351            e.args.get("position"),
352            e.args.get("occurrence"),
353            regexp_replace_global_modifier(e),
354        ),
355        exp.Round: _round_sql,
356        exp.Select: transforms.preprocess(
357            [
358                transforms.eliminate_semi_and_anti_joins,
359                transforms.eliminate_qualify,
360            ]
361        ),
362        exp.SHA2: sha256_sql,
363        exp.SHA2Digest: sha2_digest_sql,
364        exp.StrPosition: lambda self, e: strposition_sql(self, e, func_name="POSITION"),
365        exp.StrToDate: lambda self, e: self.func("TO_DATE", e.this, self.format_time(e)),
366        exp.StrToTime: lambda self, e: self.func("TO_TIMESTAMP", e.this, self.format_time(e)),
367        exp.StructExtract: struct_extract_sql,
368        exp.Substring: _substring_sql,
369        exp.TimeFromParts: rename_func("MAKE_TIME"),
370        exp.TimestampFromParts: rename_func("MAKE_TIMESTAMP"),
371        exp.TimestampTrunc: timestamptrunc_sql(zone=True),
372        exp.TimeStrToTime: timestrtotime_sql,
373        exp.TimeToStr: lambda self, e: self.func("TO_CHAR", e.this, self.format_time(e)),
374        exp.ToChar: lambda self, e: (
375            self.function_fallback_sql(e) if e.args.get("format") else self.tochar_sql(e)
376        ),
377        exp.Trim: trim_sql,
378        exp.TryCast: no_trycast_sql,
379        exp.TsOrDsAdd: _date_add_sql("+"),
380        exp.TsOrDsDiff: _date_diff_sql,
381        exp.UnixToTime: lambda self, e: self.func("TO_TIMESTAMP", e.this),
382        exp.Uuid: lambda *_: "GEN_RANDOM_UUID()",
383        exp.TimeToUnix: lambda self, e: self.func("DATE_PART", exp.Literal.string("epoch"), e.this),
384        exp.VariancePop: rename_func("VAR_POP"),
385        exp.Variance: rename_func("VAR_SAMP"),
386        exp.Xor: bool_xor_sql,
387        exp.Unicode: rename_func("ASCII"),
388        exp.UnixToTime: _unix_to_time_sql,
389        exp.Levenshtein: _levenshtein_sql,
390        exp.JSONObjectAgg: rename_func("JSON_OBJECT_AGG"),
391        exp.JSONBObjectAgg: rename_func("JSONB_OBJECT_AGG"),
392        exp.CountIf: count_if_to_sum,
393    }
394
395    PROPERTIES_LOCATION = {
396        **generator.Generator.PROPERTIES_LOCATION,
397        exp.PartitionedByProperty: exp.Properties.Location.POST_SCHEMA,
398        exp.TransientProperty: exp.Properties.Location.UNSUPPORTED,
399        exp.VolatileProperty: exp.Properties.Location.UNSUPPORTED,
400    }
401
402    def schemacommentproperty_sql(self, expression: exp.SchemaCommentProperty) -> str:
403        self.unsupported("Table comments are not supported in the CREATE statement")
404        return ""
405
406    def commentcolumnconstraint_sql(self, expression: exp.CommentColumnConstraint) -> str:
407        self.unsupported("Column comments are not supported in the CREATE statement")
408        return ""
409
410    def columndef_sql(self, expression: exp.ColumnDef, sep: str = " ") -> str:
411        # PostgreSQL places parameter modes BEFORE parameter name
412        param_constraint = expression.find(exp.InOutColumnConstraint)
413
414        if param_constraint:
415            mode_sql = self.sql(param_constraint)
416            param_constraint.pop()  # Remove to prevent double-rendering
417            base_sql = super().columndef_sql(expression, sep)
418            return f"{mode_sql} {base_sql}"
419
420        return super().columndef_sql(expression, sep)
421
422    def unnest_sql(self, expression: exp.Unnest) -> str:
423        if len(expression.expressions) == 1:
424            arg = expression.expressions[0]
425            if isinstance(arg, exp.GenerateDateArray):
426                generate_series: exp.Expr = exp.GenerateSeries(**arg.args)
427                if isinstance(expression.parent, (exp.From, exp.Join)):
428                    generate_series = (
429                        exp.select("value::date")
430                        .from_(exp.Table(this=generate_series).as_("_t", table=["value"]))
431                        .subquery(expression.args.get("alias") or "_unnested_generate_series")
432                    )
433                return self.sql(generate_series)
434
435            from sqlglot.optimizer.annotate_types import annotate_types
436
437            this = annotate_types(arg, dialect=self.dialect)
438            if this.is_type("array<json>"):
439                while isinstance(this, exp.Cast):
440                    this = this.this
441
442                arg_as_json = self.sql(exp.cast(this, exp.DType.JSON))
443                alias = self.sql(expression, "alias")
444                alias = f" AS {alias}" if alias else ""
445
446                if expression.args.get("offset"):
447                    self.unsupported("Unsupported JSON_ARRAY_ELEMENTS with offset")
448
449                return f"JSON_ARRAY_ELEMENTS({arg_as_json}){alias}"
450
451        return super().unnest_sql(expression)
452
453    def bracket_sql(self, expression: exp.Bracket) -> str:
454        """Forms like ARRAY[1, 2, 3][3] aren't allowed; we need to wrap the ARRAY."""
455        if isinstance(expression.this, exp.Array):
456            expression.set("this", exp.paren(expression.this, copy=False))
457
458        return super().bracket_sql(expression)
459
460    def matchagainst_sql(self, expression: exp.MatchAgainst) -> str:
461        this = self.sql(expression, "this")
462        expressions = [f"{self.sql(e)} @@ {this}" for e in expression.expressions]
463        sql = " OR ".join(expressions)
464        return f"({sql})" if len(expressions) > 1 else sql
465
466    def alterset_sql(self, expression: exp.AlterSet) -> str:
467        exprs = self.expressions(expression, flat=True)
468        exprs = f"({exprs})" if exprs else ""
469
470        access_method = self.sql(expression, "access_method")
471        access_method = f"ACCESS METHOD {access_method}" if access_method else ""
472        tablespace = self.sql(expression, "tablespace")
473        tablespace = f"TABLESPACE {tablespace}" if tablespace else ""
474        option = self.sql(expression, "option")
475
476        return f"SET {exprs}{access_method}{tablespace}{option}"
477
478    def datatype_sql(self, expression: exp.DataType) -> str:
479        if expression.is_type(exp.DType.ARRAY):
480            if expression.expressions:
481                values = self.expressions(expression, key="values", flat=True)
482                return f"{self.expressions(expression, flat=True)}[{values}]"
483            return "ARRAY"
484
485        if expression.is_type(exp.DType.DOUBLE, exp.DType.FLOAT) and expression.expressions:
486            # Postgres doesn't support precision for REAL and DOUBLE PRECISION types
487            return f"FLOAT({self.expressions(expression, flat=True)})"
488
489        return super().datatype_sql(expression)
490
491    def cast_sql(self, expression: exp.Cast, safe_prefix: str | None = None) -> str:
492        this = expression.this
493
494        # Postgres casts DIV() to decimal for transpilation but when roundtripping it's superfluous
495        if isinstance(this, exp.IntDiv) and expression.to == exp.DType.DECIMAL.into_expr():
496            return self.sql(this)
497
498        return super().cast_sql(expression, safe_prefix=safe_prefix)
499
500    def array_sql(self, expression: exp.Array) -> str:
501        exprs = expression.expressions
502        func_name = self.normalize_func("ARRAY")
503
504        if isinstance(seq_get(exprs, 0), exp.Select):
505            return f"{func_name}({self.sql(exprs[0])})"
506
507        return f"{func_name}{inline_array_sql(self, expression)}"
508
509    def computedcolumnconstraint_sql(self, expression: exp.ComputedColumnConstraint) -> str:
510        return f"GENERATED ALWAYS AS ({self.sql(expression, 'this')}) STORED"
511
512    def isascii_sql(self, expression: exp.IsAscii) -> str:
513        return f"({self.sql(expression.this)} ~ '^[[:ascii:]]*$')"
514
515    def ignorenulls_sql(self, expression: exp.IgnoreNulls) -> str:
516        # https://www.postgresql.org/docs/current/functions-window.html
517        self.unsupported("PostgreSQL does not support IGNORE NULLS.")
518        return self.sql(expression.this)
519
520    def respectnulls_sql(self, expression: exp.RespectNulls) -> str:
521        # https://www.postgresql.org/docs/current/functions-window.html
522        self.unsupported("PostgreSQL does not support RESPECT NULLS.")
523        return self.sql(expression.this)
524
525    @unsupported_args("this")
526    def currentschema_sql(self, expression: exp.CurrentSchema) -> str:
527        return "CURRENT_SCHEMA"
528
529    def interval_sql(self, expression: exp.Interval) -> str:
530        unit = expression.text("unit").lower()
531
532        this = expression.this
533        if unit.startswith("quarter") and isinstance(this, exp.Literal):
534            this.replace(exp.Literal.string(int(this.to_py()) * 3))
535            expression.args["unit"].replace(exp.var("MONTH"))
536
537        return super().interval_sql(expression)
538
539    def placeholder_sql(self, expression: exp.Placeholder) -> str:
540        if expression.args.get("jdbc"):
541            return "?"
542
543        this = f"({expression.name})" if expression.this else ""
544        return f"{self.NAMED_PLACEHOLDER_TOKEN}{this}s"
545
546    def arraycontains_sql(self, expression: exp.ArrayContains) -> str:
547        # Convert DuckDB's LIST_CONTAINS(array, value) to PostgreSQL
548        # DuckDB behavior:
549        #   - LIST_CONTAINS([1,2,3], 2) -> true
550        #   - LIST_CONTAINS([1,2,3], 4) -> false
551        #   - LIST_CONTAINS([1,2,NULL], 4) -> false (not NULL)
552        #   - LIST_CONTAINS([1,2,3], NULL) -> NULL
553        #
554        # PostgreSQL equivalent: CASE WHEN value IS NULL THEN NULL
555        #                            ELSE COALESCE(value = ANY(array), FALSE) END
556        value = expression.expression
557        array = expression.this
558
559        coalesce_expr = exp.Coalesce(
560            this=value.eq(exp.Any(this=exp.paren(expression=array, copy=False))),
561            expressions=[exp.false()],
562        )
563
564        case_expr = (
565            exp.Case()
566            .when(exp.Is(this=value, expression=exp.null()), exp.null(), copy=False)
567            .else_(coalesce_expr, copy=False)
568        )
569
570        return self.sql(case_expr)

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
SELECT_KINDS: tuple[str, ...] = ()
TRY_SUPPORTED = False
SUPPORTS_UESCAPE = False
SUPPORTS_DECODE_CASE = False
AFTER_HAVING_MODIFIER_TRANSFORMS = {'windows': <function <lambda>>, 'qualify': <function <lambda>>}
SINGLE_STRING_INTERVAL = True
RENAME_TABLE_WITH_DB = False
LOCKING_READS_SUPPORTED = True
JOIN_HINTS = False
TABLE_HINTS = False
QUERY_HINTS = False
NVL2_SUPPORTED = False
PARAMETER_TOKEN = '$'
NAMED_PLACEHOLDER_TOKEN = '%'
TABLESAMPLE_SIZE_IS_ROWS = False
TABLESAMPLE_SEED_KEYWORD = 'REPEATABLE'
SUPPORTS_SELECT_INTO = True
JSON_TYPE_REQUIRED_FOR_EXTRACTION = True
SUPPORTS_UNLOGGED_TABLES = True
LIKE_PROPERTY_INSIDE_SCHEMA = True
MULTI_ARG_DISTINCT = False
CAN_IMPLEMENT_ARRAY_ANY = True
SUPPORTS_WINDOW_EXCLUDE = True
COPY_HAS_INTO_KEYWORD = False
ARRAY_CONCAT_IS_VAR_LEN = False
SUPPORTS_MEDIAN = False
ARRAY_SIZE_DIM_REQUIRED: bool | None = True
SUPPORTS_BETWEEN_FLAGS = True
INOUT_SEPARATOR = ''
def lateral_sql(self, expression: sqlglot.expressions.query.Lateral) -> str:
265    def lateral_sql(self, expression: exp.Lateral) -> str:
266        sql = super().lateral_sql(expression)
267
268        if expression.args.get("cross_apply") is not None:
269            sql = f"{sql} ON TRUE"
270
271        return sql
TYPE_MAPPING = {<DType.DATETIME2: 'DATETIME2'>: 'TIMESTAMP', <DType.NCHAR: 'NCHAR'>: 'CHAR', <DType.NVARCHAR: 'NVARCHAR'>: 'VARCHAR', <DType.MEDIUMTEXT: 'MEDIUMTEXT'>: 'TEXT', <DType.LONGTEXT: 'LONGTEXT'>: 'TEXT', <DType.TINYTEXT: 'TINYTEXT'>: 'TEXT', <DType.BLOB: 'BLOB'>: 'BYTEA', <DType.MEDIUMBLOB: 'MEDIUMBLOB'>: 'BLOB', <DType.LONGBLOB: 'LONGBLOB'>: 'BLOB', <DType.TINYBLOB: 'TINYBLOB'>: 'BLOB', <DType.INET: 'INET'>: 'INET', <DType.ROWVERSION: 'ROWVERSION'>: 'BYTEA', <DType.SMALLDATETIME: 'SMALLDATETIME'>: 'TIMESTAMP', <DType.TINYINT: 'TINYINT'>: 'SMALLINT', <DType.FLOAT: 'FLOAT'>: 'REAL', <DType.DOUBLE: 'DOUBLE'>: 'DOUBLE PRECISION', <DType.BINARY: 'BINARY'>: 'BYTEA', <DType.VARBINARY: 'VARBINARY'>: 'BYTEA', <DType.DATETIME: 'DATETIME'>: 'TIMESTAMP', <DType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>: 'TIMESTAMP'}
TRANSFORMS = {<class 'sqlglot.expressions.query.JSONPathKey'>: <function json_path_key_only_name>, <class 'sqlglot.expressions.query.JSONPathRoot'>: <function PostgresGenerator.<lambda>>, <class 'sqlglot.expressions.query.JSONPathSubscript'>: <function PostgresGenerator.<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.ArrayContainsAll'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.array.ArrayOverlaps'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.AssumeColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.AutoRefreshProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.BackupProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.CaseSpecificColumnConstraint'>: <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.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.CredentialsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.functions.CurrentCatalog'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.functions.SessionUser'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.DateFormatColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.DefaultColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ApiProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ApplicationProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.CatalogProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ComputeProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.DatabaseProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.DynamicProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.EmptyProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.EncodeColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.EndStatement'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.EnviromentProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.HandlerProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ParameterStyleProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.EphemeralColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.ExcludeColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ExecuteAsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.Except'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ExternalProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.math.Floor'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.Get'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.GlobalProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.HeapProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.HybridProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.IcebergProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.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.JSONBDeleteAtPath'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.json.JSONObject'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.json.JSONObjectAgg'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.properties.LanguageProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.LocationProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.LogProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.MaskingProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.MaterializedProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.functions.NetFunc'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.NetworkProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.NonClusteredColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.NoPrimaryIndexProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.NotForReplicationColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.OnCommitProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.OnProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.OnUpdateColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.core.Operator'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.OutputModelProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.core.ExtendsLeft'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.core.ExtendsRight'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.PathColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.PartitionedByBucket'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.PartitionByTruncate'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.core.PivotAny'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.array.PositionalColumn'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.ProjectionPolicyColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.InvisibleColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.ZeroFillColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.Put'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.RemoteWithConnectionModelProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ReturnsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.RowAccessProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.core.SafeFunc'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SampleProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SecureProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SecurityIntegrationProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SetConfigProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SetProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SettingsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SharingProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SqlReadWriteProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SqlSecurityProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.StabilityProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.Stream'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.StreamingTableProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.StrictProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ddl.SwapTable'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.TableColumn'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.Tags'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.TemporaryProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.TitleColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.array.ToMap'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ToTableProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.TransformModelProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.TransientProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.VirtualProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ddl.TriggerExecute'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.Union'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.UnloggedProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.UsingTemplateProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.UsingData'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.UppercaseColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.temporal.UtcDate'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.temporal.UtcTime'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.temporal.UtcTimestamp'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.Variadic'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.array.VarMap'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ViewAttributeProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.VolatileProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.WithJournalTableProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.WithProcedureOptions'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.WithSchemaBindingProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.WithOperator'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ForceProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.aggregate.AnyValue'>: <function _versioned_anyvalue_sql>, <class 'sqlglot.expressions.array.ArrayConcat'>: <function array_concat_sql.<locals>._array_concat_sql>, <class 'sqlglot.expressions.array.ArrayFilter'>: <function filter_array_using_unnest>, <class 'sqlglot.expressions.array.ArrayAppend'>: <function array_append_sql.<locals>._array_append_sql>, <class 'sqlglot.expressions.array.ArrayPrepend'>: <function array_append_sql.<locals>._array_append_sql>, <class 'sqlglot.expressions.math.BitwiseAndAgg'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.math.BitwiseOrAgg'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.core.BitwiseXor'>: <function PostgresGenerator.<lambda>>, <class 'sqlglot.expressions.math.BitwiseXorAgg'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.query.ColumnDef'>: <function preprocess.<locals>._to_sql>, <class 'sqlglot.expressions.temporal.CurrentDate'>: <function no_paren_current_date_sql>, <class 'sqlglot.expressions.temporal.CurrentTimestamp'>: <function PostgresGenerator.<lambda>>, <class 'sqlglot.expressions.functions.CurrentUser'>: <function PostgresGenerator.<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.DateDiff'>: <function _date_diff_sql>, <class 'sqlglot.expressions.temporal.DateStrToDate'>: <function datestrtodate_sql>, <class 'sqlglot.expressions.temporal.DateSub'>: <function _date_add_sql.<locals>.func>, <class 'sqlglot.expressions.array.Explode'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.array.ExplodingGenerateSeries'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.array.GenerateSeries'>: <function generate_series_sql.<locals>._generate_series_sql>, <class 'sqlglot.expressions.math.Getbit'>: <function getbit_sql>, <class 'sqlglot.expressions.aggregate.GroupConcat'>: <function PostgresGenerator.<lambda>>, <class 'sqlglot.expressions.core.IntDiv'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.json.JSONArrayAgg'>: <function PostgresGenerator.<lambda>>, <class 'sqlglot.expressions.json.JSONExtract'>: <function _json_extract_sql.<locals>._generate>, <class 'sqlglot.expressions.json.JSONExtractScalar'>: <function _json_extract_sql.<locals>._generate>, <class 'sqlglot.expressions.json.JSONBExtract'>: <function PostgresGenerator.<lambda>>, <class 'sqlglot.expressions.json.JSONBExtractScalar'>: <function PostgresGenerator.<lambda>>, <class 'sqlglot.expressions.json.JSONBContains'>: <function PostgresGenerator.<lambda>>, <class 'sqlglot.expressions.json.ParseJSON'>: <function PostgresGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.LastDay'>: <function no_last_day_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.array.MapFromEntries'>: <function no_map_from_entries_sql>, <class 'sqlglot.expressions.aggregate.Min'>: <function min_or_least>, <class 'sqlglot.expressions.dml.Merge'>: <function merge_without_target_sql>, <class 'sqlglot.expressions.properties.PartitionedByProperty'>: <function PostgresGenerator.<lambda>>, <class 'sqlglot.expressions.aggregate.PercentileCont'>: <function preprocess.<locals>._to_sql>, <class 'sqlglot.expressions.aggregate.PercentileDisc'>: <function preprocess.<locals>._to_sql>, <class 'sqlglot.expressions.query.Pivot'>: <function no_pivot_sql>, <class 'sqlglot.expressions.functions.Rand'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.core.RegexpLike'>: <function PostgresGenerator.<lambda>>, <class 'sqlglot.expressions.string.RegexpILike'>: <function PostgresGenerator.<lambda>>, <class 'sqlglot.expressions.string.RegexpReplace'>: <function PostgresGenerator.<lambda>>, <class 'sqlglot.expressions.math.Round'>: <function _round_sql>, <class 'sqlglot.expressions.query.Select'>: <function preprocess.<locals>._to_sql>, <class 'sqlglot.expressions.string.SHA2'>: <function sha256_sql>, <class 'sqlglot.expressions.string.SHA2Digest'>: <function sha2_digest_sql>, <class 'sqlglot.expressions.string.StrPosition'>: <function PostgresGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.StrToDate'>: <function PostgresGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.StrToTime'>: <function PostgresGenerator.<lambda>>, <class 'sqlglot.expressions.array.StructExtract'>: <function struct_extract_sql>, <class 'sqlglot.expressions.string.Substring'>: <function _substring_sql>, <class 'sqlglot.expressions.temporal.TimeFromParts'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.TimestampFromParts'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.TimestampTrunc'>: <function timestamptrunc_sql.<locals>._timestamptrunc_sql>, <class 'sqlglot.expressions.temporal.TimeStrToTime'>: <function timestrtotime_sql>, <class 'sqlglot.expressions.temporal.TimeToStr'>: <function PostgresGenerator.<lambda>>, <class 'sqlglot.expressions.string.ToChar'>: <function PostgresGenerator.<lambda>>, <class 'sqlglot.expressions.string.Trim'>: <function trim_sql>, <class 'sqlglot.expressions.functions.TryCast'>: <function no_trycast_sql>, <class 'sqlglot.expressions.temporal.TsOrDsAdd'>: <function _date_add_sql.<locals>.func>, <class 'sqlglot.expressions.temporal.TsOrDsDiff'>: <function _date_diff_sql>, <class 'sqlglot.expressions.temporal.UnixToTime'>: <function _unix_to_time_sql>, <class 'sqlglot.expressions.functions.Uuid'>: <function PostgresGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.TimeToUnix'>: <function PostgresGenerator.<lambda>>, <class 'sqlglot.expressions.aggregate.VariancePop'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.aggregate.Variance'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.core.Xor'>: <function bool_xor_sql>, <class 'sqlglot.expressions.string.Unicode'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.string.Levenshtein'>: <function _levenshtein_sql>, <class 'sqlglot.expressions.json.JSONBObjectAgg'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.aggregate.CountIf'>: <function count_if_to_sum>}
PROPERTIES_LOCATION = {<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.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.query.Cluster'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.ClusteredByProperty'>: <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.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.DistStyleProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <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.IncludeProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.InputModelProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <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.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.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.POST_SCHEMA: 'POST_SCHEMA'>, <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.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.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.ForceProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>}
def schemacommentproperty_sql( self, expression: sqlglot.expressions.properties.SchemaCommentProperty) -> str:
402    def schemacommentproperty_sql(self, expression: exp.SchemaCommentProperty) -> str:
403        self.unsupported("Table comments are not supported in the CREATE statement")
404        return ""
def commentcolumnconstraint_sql( self, expression: sqlglot.expressions.constraints.CommentColumnConstraint) -> str:
406    def commentcolumnconstraint_sql(self, expression: exp.CommentColumnConstraint) -> str:
407        self.unsupported("Column comments are not supported in the CREATE statement")
408        return ""
def columndef_sql( self, expression: sqlglot.expressions.query.ColumnDef, sep: str = ' ') -> str:
410    def columndef_sql(self, expression: exp.ColumnDef, sep: str = " ") -> str:
411        # PostgreSQL places parameter modes BEFORE parameter name
412        param_constraint = expression.find(exp.InOutColumnConstraint)
413
414        if param_constraint:
415            mode_sql = self.sql(param_constraint)
416            param_constraint.pop()  # Remove to prevent double-rendering
417            base_sql = super().columndef_sql(expression, sep)
418            return f"{mode_sql} {base_sql}"
419
420        return super().columndef_sql(expression, sep)
def unnest_sql(self, expression: sqlglot.expressions.array.Unnest) -> str:
422    def unnest_sql(self, expression: exp.Unnest) -> str:
423        if len(expression.expressions) == 1:
424            arg = expression.expressions[0]
425            if isinstance(arg, exp.GenerateDateArray):
426                generate_series: exp.Expr = exp.GenerateSeries(**arg.args)
427                if isinstance(expression.parent, (exp.From, exp.Join)):
428                    generate_series = (
429                        exp.select("value::date")
430                        .from_(exp.Table(this=generate_series).as_("_t", table=["value"]))
431                        .subquery(expression.args.get("alias") or "_unnested_generate_series")
432                    )
433                return self.sql(generate_series)
434
435            from sqlglot.optimizer.annotate_types import annotate_types
436
437            this = annotate_types(arg, dialect=self.dialect)
438            if this.is_type("array<json>"):
439                while isinstance(this, exp.Cast):
440                    this = this.this
441
442                arg_as_json = self.sql(exp.cast(this, exp.DType.JSON))
443                alias = self.sql(expression, "alias")
444                alias = f" AS {alias}" if alias else ""
445
446                if expression.args.get("offset"):
447                    self.unsupported("Unsupported JSON_ARRAY_ELEMENTS with offset")
448
449                return f"JSON_ARRAY_ELEMENTS({arg_as_json}){alias}"
450
451        return super().unnest_sql(expression)
def bracket_sql(self, expression: sqlglot.expressions.core.Bracket) -> str:
453    def bracket_sql(self, expression: exp.Bracket) -> str:
454        """Forms like ARRAY[1, 2, 3][3] aren't allowed; we need to wrap the ARRAY."""
455        if isinstance(expression.this, exp.Array):
456            expression.set("this", exp.paren(expression.this, copy=False))
457
458        return super().bracket_sql(expression)

Forms like ARRAY[1, 2, 3][3] aren't allowed; we need to wrap the ARRAY.

def matchagainst_sql(self, expression: sqlglot.expressions.string.MatchAgainst) -> str:
460    def matchagainst_sql(self, expression: exp.MatchAgainst) -> str:
461        this = self.sql(expression, "this")
462        expressions = [f"{self.sql(e)} @@ {this}" for e in expression.expressions]
463        sql = " OR ".join(expressions)
464        return f"({sql})" if len(expressions) > 1 else sql
def alterset_sql(self, expression: sqlglot.expressions.ddl.AlterSet) -> str:
466    def alterset_sql(self, expression: exp.AlterSet) -> str:
467        exprs = self.expressions(expression, flat=True)
468        exprs = f"({exprs})" if exprs else ""
469
470        access_method = self.sql(expression, "access_method")
471        access_method = f"ACCESS METHOD {access_method}" if access_method else ""
472        tablespace = self.sql(expression, "tablespace")
473        tablespace = f"TABLESPACE {tablespace}" if tablespace else ""
474        option = self.sql(expression, "option")
475
476        return f"SET {exprs}{access_method}{tablespace}{option}"
def datatype_sql(self, expression: sqlglot.expressions.datatypes.DataType) -> str:
478    def datatype_sql(self, expression: exp.DataType) -> str:
479        if expression.is_type(exp.DType.ARRAY):
480            if expression.expressions:
481                values = self.expressions(expression, key="values", flat=True)
482                return f"{self.expressions(expression, flat=True)}[{values}]"
483            return "ARRAY"
484
485        if expression.is_type(exp.DType.DOUBLE, exp.DType.FLOAT) and expression.expressions:
486            # Postgres doesn't support precision for REAL and DOUBLE PRECISION types
487            return f"FLOAT({self.expressions(expression, flat=True)})"
488
489        return super().datatype_sql(expression)
def cast_sql( self, expression: sqlglot.expressions.functions.Cast, safe_prefix: str | None = None) -> str:
491    def cast_sql(self, expression: exp.Cast, safe_prefix: str | None = None) -> str:
492        this = expression.this
493
494        # Postgres casts DIV() to decimal for transpilation but when roundtripping it's superfluous
495        if isinstance(this, exp.IntDiv) and expression.to == exp.DType.DECIMAL.into_expr():
496            return self.sql(this)
497
498        return super().cast_sql(expression, safe_prefix=safe_prefix)
def array_sql(self, expression: sqlglot.expressions.array.Array) -> str:
500    def array_sql(self, expression: exp.Array) -> str:
501        exprs = expression.expressions
502        func_name = self.normalize_func("ARRAY")
503
504        if isinstance(seq_get(exprs, 0), exp.Select):
505            return f"{func_name}({self.sql(exprs[0])})"
506
507        return f"{func_name}{inline_array_sql(self, expression)}"
def computedcolumnconstraint_sql( self, expression: sqlglot.expressions.constraints.ComputedColumnConstraint) -> str:
509    def computedcolumnconstraint_sql(self, expression: exp.ComputedColumnConstraint) -> str:
510        return f"GENERATED ALWAYS AS ({self.sql(expression, 'this')}) STORED"
def isascii_sql(self, expression: sqlglot.expressions.string.IsAscii) -> str:
512    def isascii_sql(self, expression: exp.IsAscii) -> str:
513        return f"({self.sql(expression.this)} ~ '^[[:ascii:]]*$')"
def ignorenulls_sql(self, expression: sqlglot.expressions.core.IgnoreNulls) -> str:
515    def ignorenulls_sql(self, expression: exp.IgnoreNulls) -> str:
516        # https://www.postgresql.org/docs/current/functions-window.html
517        self.unsupported("PostgreSQL does not support IGNORE NULLS.")
518        return self.sql(expression.this)
def respectnulls_sql(self, expression: sqlglot.expressions.core.RespectNulls) -> str:
520    def respectnulls_sql(self, expression: exp.RespectNulls) -> str:
521        # https://www.postgresql.org/docs/current/functions-window.html
522        self.unsupported("PostgreSQL does not support RESPECT NULLS.")
523        return self.sql(expression.this)
@unsupported_args('this')
def currentschema_sql(self, expression: sqlglot.expressions.functions.CurrentSchema) -> str:
525    @unsupported_args("this")
526    def currentschema_sql(self, expression: exp.CurrentSchema) -> str:
527        return "CURRENT_SCHEMA"
def interval_sql(self, expression: sqlglot.expressions.datatypes.Interval) -> str:
529    def interval_sql(self, expression: exp.Interval) -> str:
530        unit = expression.text("unit").lower()
531
532        this = expression.this
533        if unit.startswith("quarter") and isinstance(this, exp.Literal):
534            this.replace(exp.Literal.string(int(this.to_py()) * 3))
535            expression.args["unit"].replace(exp.var("MONTH"))
536
537        return super().interval_sql(expression)
def placeholder_sql(self, expression: sqlglot.expressions.core.Placeholder) -> str:
539    def placeholder_sql(self, expression: exp.Placeholder) -> str:
540        if expression.args.get("jdbc"):
541            return "?"
542
543        this = f"({expression.name})" if expression.this else ""
544        return f"{self.NAMED_PLACEHOLDER_TOKEN}{this}s"
def arraycontains_sql(self, expression: sqlglot.expressions.array.ArrayContains) -> str:
546    def arraycontains_sql(self, expression: exp.ArrayContains) -> str:
547        # Convert DuckDB's LIST_CONTAINS(array, value) to PostgreSQL
548        # DuckDB behavior:
549        #   - LIST_CONTAINS([1,2,3], 2) -> true
550        #   - LIST_CONTAINS([1,2,3], 4) -> false
551        #   - LIST_CONTAINS([1,2,NULL], 4) -> false (not NULL)
552        #   - LIST_CONTAINS([1,2,3], NULL) -> NULL
553        #
554        # PostgreSQL equivalent: CASE WHEN value IS NULL THEN NULL
555        #                            ELSE COALESCE(value = ANY(array), FALSE) END
556        value = expression.expression
557        array = expression.this
558
559        coalesce_expr = exp.Coalesce(
560            this=value.eq(exp.Any(this=exp.paren(expression=array, copy=False))),
561            expressions=[exp.false()],
562        )
563
564        case_expr = (
565            exp.Case()
566            .when(exp.Is(this=value, expression=exp.null()), exp.null(), copy=False)
567            .else_(coalesce_expr, copy=False)
568        )
569
570        return self.sql(case_expr)
Inherited Members
sqlglot.generator.Generator
Generator
NULL_ORDERING_SUPPORTED
WINDOW_FUNCS_WITH_NULL_ORDERING
IGNORE_NULLS_IN_FUNC
IGNORE_NULLS_BEFORE_ORDER
EXCEPT_INTERSECT_SUPPORT_ALL_CLAUSE
WRAP_DERIVED_VALUES
CREATE_FUNCTION_RETURN_AS
MATCHED_BY_SOURCE
SUPPORTS_MERGE_WHERE
INTERVAL_ALLOWS_PLURAL_FORM
LIMIT_FETCH
LIMIT_ONLY_LITERALS
GROUPINGS_SEP
INDEX_ON
DIRECTED_JOINS
QUERY_HINT_SEP
IS_BOOL_ALLOWED
DUPLICATE_KEY_UPDATE_WITH_SET
LIMIT_IS_TOP
RETURNING_END
EXTRACT_ALLOWS_QUOTES
TZ_TO_WITH_TIME_ZONE
VALUES_AS_TABLE
ALTER_TABLE_INCLUDE_COLUMN_KEYWORD
UNNEST_WITH_ORDINALITY
AGGREGATE_FILTER_SUPPORTED
SEMI_ANTI_JOIN_WITH_SIDE
COMPUTED_COLUMN_WITH_TYPE
SUPPORTS_TABLE_COPY
TABLESAMPLE_REQUIRES_PARENS
TABLESAMPLE_KEYWORDS
TABLESAMPLE_WITH_METHOD
COLLATE_IS_FUNC
DATA_TYPE_SPECIFIERS_ALLOWED
ENSURE_BOOLS
CTE_RECURSIVE_KEYWORD_REQUIRED
SUPPORTS_SINGLE_ARG_CONCAT
LAST_DAY_SUPPORTS_DATE_PART
SUPPORTS_TABLE_ALIAS_COLUMNS
UNPIVOT_ALIASES_ARE_IDENTIFIERS
JSON_KEY_VALUE_PAIR_SEP
INSERT_OVERWRITE
SUPPORTS_CREATE_TABLE_LIKE
JSON_PATH_BRACKETED_KEY_SUPPORTED
JSON_PATH_SINGLE_QUOTE_ESCAPE
SUPPORTS_TO_NUMBER
SET_OP_MODIFIERS
COPY_PARAMS_ARE_WRAPPED
COPY_PARAMS_EQ_REQUIRED
UNICODE_SUBSTITUTE
STAR_EXCEPT
HEX_FUNC
WITH_PROPERTIES_PREFIX
QUOTE_JSON_PATH
PAD_FILL_PATTERN_IS_REQUIRED
SUPPORTS_EXPLODING_PROJECTIONS
SUPPORTS_CONVERT_TIMEZONE
SUPPORTS_UNIX_SECONDS
ALTER_SET_WRAPPED
NORMALIZE_EXTRACT_DATE_PARTS
PARSE_JSON_NAME
ARRAY_SIZE_NAME
ALTER_SET_TYPE
SUPPORTS_LIKE_QUANTIFIERS
MATCH_AGAINST_TABLE_PREFIX
SET_ASSIGNMENT_REQUIRES_VARIABLE_KEYWORD
DECLARE_DEFAULT_ASSIGNMENT
UPDATE_STATEMENT_SUPPORTS_FROM
STAR_EXCLUDE_REQUIRES_DERIVED_TABLE
SUPPORTS_DROP_ALTER_ICEBERG_PROPERTY
UNSUPPORTED_TYPES
TIME_PART_SINGULARS
TOKEN_MAPPING
STRUCT_DELIMITER
EXPRESSION_PRECEDES_PROPERTIES_CREATABLES
RESERVED_KEYWORDS
WITH_SEPARATED_COMMENTS
EXCLUDE_COMMENTS
UNWRAPPED_INTERVAL_VALUES
PARAMETERIZABLE_TEXT_TYPES
EXPRESSIONS_WITHOUT_NESTED_CTES
RESPECT_IGNORE_NULLS_UNSUPPORTED_EXPRESSIONS
SAFE_JSON_PATH_KEY_RE
SENTINEL_LINE_BREAK
pretty
identify
normalize
pad
unsupported_level
max_unsupported
leading_comma
max_text_width
comments
dialect
normalize_functions
unsupported_messages
generate
preprocess
unsupported
sep
seg
sanitize_comment
maybe_comment
wrap
no_identify
normalize_func
indent
sql
uncache_sql
cache_sql
characterset_sql
column_parts
column_sql
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
directory_sql
delete_sql
drop_sql
set_operation
set_operations
fetch_sql
limitoptions_sql
filter_sql
hint_sql
indexparameters_sql
index_sql
identifier_sql
hex_sql
lowerhex_sql
inputoutputformat_sql
national_sql
partition_sql
properties_sql
root_properties
properties
with_properties
locate_properties
property_name
property_sql
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
withdataproperty_sql
withsystemversioningproperty_sql
insert_sql
introducer_sql
kill_sql
pseudotype_sql
objectidentifier_sql
onconflict_sql
returning_sql
rowformatdelimitedproperty_sql
withtablehint_sql
indextablehint_sql
historicaldata_sql
table_parts
table_sql
tablefromrows_sql
tablesample_sql
pivot_sql
version_sql
tuple_sql
update_sql
values_sql
var_sql
into_sql
from_sql
groupingsets_sql
rollup_sql
rollupindex_sql
rollupproperty_sql
cube_sql
group_sql
having_sql
connect_sql
prior_sql
join_sql
lambda_sql
lateral_op
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
distribute_sql
sort_sql
ordered_sql
matchrecognizemeasure_sql
matchrecognize_sql
query_modifiers
options_modifier
for_modifiers
queryoption_sql
offset_limit_modifiers
after_limit_modifiers
select_sql
schema_sql
schema_columns_sql
star_sql
parameter_sql
sessionparameter_sql
subquery_sql
qualify_sql
prewhere_sql
where_sql
window_sql
partition_by_sql
windowspec_sql
withingroup_sql
between_sql
bracket_offset_expressions
all_sql
any_sql
exists_sql
case_sql
constraint_sql
nextvaluefor_sql
extract_sql
trim_sql
convert_concat_args
concat_sql
concatws_sql
check_sql
foreignkey_sql
primarykey_sql
if_sql
jsonkeyvalue_sql
jsonpath_sql
json_path_part
formatjson_sql
formatphrase_sql
jsonarray_sql
jsonarrayagg_sql
jsoncolumndef_sql
jsonschema_sql
jsontable_sql
openjsoncolumndef_sql
openjson_sql
in_sql
in_unnest_op
return_sql
reference_sql
anonymous_sql
paren_sql
neg_sql
not_sql
alias_sql
pivotalias_sql
aliases_sql
atindex_sql
attimezone_sql
fromtimezone_sql
add_sql
and_sql
or_sql
xor_sql
connector_sql
bitwiseand_sql
bitwiseleftshift_sql
bitwisenot_sql
bitwiseor_sql
bitwiserightshift_sql
bitwisexor_sql
strtotime_sql
currentdate_sql
collate_sql
command_sql
comment_sql
mergetreettlaction_sql
mergetreettl_sql
transaction_sql
commit_sql
rollback_sql
altercolumn_sql
alterindex_sql
alterdiststyle_sql
altersortkey_sql
alterrename_sql
renamecolumn_sql
alter_sql
altersession_sql
add_column_sql
droppartition_sql
addconstraint_sql
addpartition_sql
distinct_sql
havingmax_sql
intdiv_sql
dpipe_sql
div_sql
safedivide_sql
overlaps_sql
distance_sql
dot_sql
eq_sql
propertyeq_sql
escape_sql
glob_sql
gt_sql
gte_sql
is_sql
like_sql
ilike_sql
match_sql
similarto_sql
lt_sql
lte_sql
mod_sql
mul_sql
neq_sql
nullsafeeq_sql
nullsafeneq_sql
sub_sql
trycast_sql
jsoncast_sql
try_sql
log_sql
use_sql
binary
ceil_floor
function_fallback_sql
func
format_args
too_wide
format_time
expressions
op_expressions
naked_property
tag_sql
token_sql
userdefinedfunction_sql
joinhint_sql
kwarg_sql
when_sql
whens_sql
merge_sql
tochar_sql
tonumber_sql
dictproperty_sql
dictrange_sql
dictsubproperty_sql
duplicatekeyproperty_sql
uniquekeyproperty_sql
distributedbyproperty_sql
oncluster_sql
clusteredbyproperty_sql
anyvalue_sql
querytransform_sql
indexconstraintoption_sql
checkcolumnconstraint_sql
indexcolumnconstraint_sql
nvl2_sql
comprehension_sql
columnprefix_sql
opclass_sql
predict_sql
generateembedding_sql
generatetext_sql
generatetable_sql
generatebool_sql
generateint_sql
generatedouble_sql
mltranslate_sql
mlforecast_sql
aiforecast_sql
featuresattime_sql
vectorsearch_sql
forin_sql
refresh_sql
toarray_sql
tsordstotime_sql
tsordstotimestamp_sql
tsordstodatetime_sql
tsordstodate_sql
unixdate_sql
lastday_sql
dateadd_sql
arrayany_sql
struct_sql
partitionrange_sql
truncatetable_sql
convert_sql
copyparameter_sql
credentials_sql
copy_sql
semicolon_sql
datadeletionproperty_sql
maskingpolicycolumnconstraint_sql
gapfill_sql
scope_resolution
scoperesolution_sql
parsejson_sql
rand_sql
changes_sql
pad_sql
summarize_sql
explodinggenerateseries_sql
converttimezone_sql
json_sql
jsonvalue_sql
skipjsoncolumn_sql
conditionalinsert_sql
multitableinserts_sql
oncondition_sql
jsonextractquote_sql
jsonexists_sql
arrayagg_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
arraysize_sql
attach_sql
detach_sql
attachoption_sql
watermarkcolumnconstraint_sql
encodeproperty_sql
includeproperty_sql
xmlelement_sql
xmlkeyvalueoption_sql
partitionbyrangeproperty_sql
partitionbyrangepropertydynamic_sql
unpivotcolumns_sql
analyzesample_sql
analyzestatistics_sql
analyzehistogram_sql
analyzedelete_sql
analyzelistchainedrows_sql
analyzevalidate_sql
analyze_sql
xmltable_sql
xmlnamespace_sql
export_sql
declare_sql
declareitem_sql
recursivewithsearch_sql
parameterizedagg_sql
anonymousaggfunc_sql
combinedaggfunc_sql
combinedparameterizedagg_sql
show_sql
install_sql
get_put_sql
translatecharacters_sql
decodecase_sql
semanticview_sql
getextract_sql
datefromunixdate_sql
space_sql
buildproperty_sql
refreshtriggerproperty_sql
modelattribute_sql
directorystage_sql
uuid_sql
initcap_sql
localtime_sql
localtimestamp_sql
weekstart_sql
chr_sql
block_sql
storedprocedure_sql
ifblock_sql
whileblock_sql
execute_sql
executesql_sql
altermodifysqlsecurity_sql
usingproperty_sql
renameindex_sql