Edit on GitHub

sqlglot.generators.hive

  1from __future__ import annotations
  2
  3import re
  4from functools import partial
  5
  6from sqlglot import exp, generator, transforms
  7from sqlglot.dialects.dialect import (
  8    DATE_ADD_OR_SUB,
  9    approx_count_distinct_sql,
 10    arg_max_or_min_no_count,
 11    datestrtodate_sql,
 12    if_sql,
 13    is_parse_json,
 14    left_to_substring_sql,
 15    max_or_greatest,
 16    min_or_least,
 17    no_ilike_sql,
 18    no_recursive_cte_sql,
 19    no_trycast_sql,
 20    regexp_extract_sql,
 21    regexp_replace_sql,
 22    rename_func,
 23    right_to_substring_sql,
 24    strposition_sql,
 25    struct_extract_sql,
 26    time_format,
 27    timestrtotime_sql,
 28    trim_sql,
 29    unit_to_str,
 30    var_map_sql,
 31    sequence_sql,
 32    property_sql,
 33)
 34from sqlglot.transforms import (
 35    remove_unique_constraints,
 36    ctas_with_tmp_tables_to_create_tmp_view,
 37    preprocess,
 38    move_schema_columns_to_partitioned_by,
 39)
 40from sqlglot.generator import unsupported_args
 41
 42# These constants are duplicated from the Hive dialect class to avoid circular imports.
 43# They must be kept in sync with Hive.TIME_FORMAT, Hive.DATE_FORMAT, Hive.DATEINT_FORMAT.
 44HIVE_TIME_FORMAT = "'yyyy-MM-dd HH:mm:ss'"
 45HIVE_DATE_FORMAT = "'yyyy-MM-dd'"
 46HIVE_DATEINT_FORMAT = "'yyyyMMdd'"
 47
 48# (FuncType, Multiplier)
 49DATE_DELTA_INTERVAL = {
 50    "YEAR": ("ADD_MONTHS", 12),
 51    "MONTH": ("ADD_MONTHS", 1),
 52    "QUARTER": ("ADD_MONTHS", 3),
 53    "WEEK": ("DATE_ADD", 7),
 54    "DAY": ("DATE_ADD", 1),
 55}
 56
 57TIME_DIFF_FACTOR = {
 58    "MILLISECOND": " * 1000",
 59    "SECOND": "",
 60    "MINUTE": " / 60",
 61    "HOUR": " / 3600",
 62}
 63
 64DIFF_MONTH_SWITCH = ("YEAR", "QUARTER", "MONTH")
 65
 66HIVE_TS_OR_DS_EXPRESSIONS: tuple[type[exp.Expr], ...] = (
 67    exp.DateDiff,
 68    exp.Day,
 69    exp.Month,
 70    exp.Year,
 71)
 72
 73
 74def _add_date_sql(self: HiveGenerator, expression: DATE_ADD_OR_SUB) -> str:
 75    if isinstance(expression, exp.TsOrDsAdd) and not expression.unit:
 76        return self.func("DATE_ADD", expression.this, expression.expression)
 77
 78    unit = expression.text("unit").upper()
 79    func, multiplier = DATE_DELTA_INTERVAL.get(unit, ("DATE_ADD", 1))
 80
 81    if isinstance(expression, exp.DateSub):
 82        multiplier *= -1
 83
 84    increment = expression.expression
 85    if isinstance(increment, exp.Literal):
 86        value = increment.to_py() if increment.is_number else int(increment.name)
 87        increment = exp.Literal.number(value * multiplier)
 88    elif multiplier != 1:
 89        increment *= exp.Literal.number(multiplier)
 90
 91    return self.func(func, expression.this, increment)
 92
 93
 94def _date_diff_sql(self: HiveGenerator, expression: exp.DateDiff | exp.TsOrDsDiff) -> str:
 95    unit = expression.text("unit").upper()
 96
 97    factor = TIME_DIFF_FACTOR.get(unit)
 98    if factor is not None:
 99        left = self.sql(expression, "this")
100        right = self.sql(expression, "expression")
101        sec_diff = f"UNIX_TIMESTAMP({left}) - UNIX_TIMESTAMP({right})"
102        return f"({sec_diff}){factor}" if factor else sec_diff
103
104    months_between = unit in DIFF_MONTH_SWITCH
105    sql_func = "MONTHS_BETWEEN" if months_between else "DATEDIFF"
106    _, multiplier = DATE_DELTA_INTERVAL.get(unit, ("", 1))
107    multiplier_sql = f" / {multiplier}" if multiplier > 1 else ""
108    diff_sql = f"{sql_func}({self.format_args(expression.this, expression.expression)})"
109
110    if months_between or multiplier_sql:
111        # MONTHS_BETWEEN returns a float, so we need to truncate the fractional part.
112        # For the same reason, we want to truncate if there's a divisor present.
113        diff_sql = f"CAST({diff_sql}{multiplier_sql} AS INT)"
114
115    return diff_sql
116
117
118def _json_format_sql(self: HiveGenerator, expression: exp.JSONFormat) -> str:
119    this = expression.this
120
121    if is_parse_json(this):
122        if this.this.is_string:
123            # Since FROM_JSON requires a nested type, we always wrap the json string with
124            # an array to ensure that "naked" strings like "'a'" will be handled correctly
125            wrapped_json = exp.Literal.string(f"[{this.this.name}]")
126
127            from_json = self.func(
128                "FROM_JSON", wrapped_json, self.func("SCHEMA_OF_JSON", wrapped_json)
129            )
130            to_json = self.func("TO_JSON", from_json)
131
132            # This strips the [, ] delimiters of the dummy array printed by TO_JSON
133            return self.func("REGEXP_EXTRACT", to_json, "'^.(.*).$'", "1")
134        return self.sql(this)
135
136    return self.func("TO_JSON", this, expression.args.get("options"))
137
138
139@generator.unsupported_args(("expression", "Hive's SORT_ARRAY does not support a comparator."))
140def _array_sort_sql(self: HiveGenerator, expression: exp.ArraySort) -> str:
141    return self.func("SORT_ARRAY", expression.this)
142
143
144def _str_to_unix_sql(self: HiveGenerator, expression: exp.StrToUnix) -> str:
145    return self.func("UNIX_TIMESTAMP", expression.this, time_format("hive")(self, expression))
146
147
148def _unix_to_time_sql(self: HiveGenerator, expression: exp.UnixToTime) -> str:
149    timestamp = self.sql(expression, "this")
150    scale = expression.args.get("scale")
151    if scale in (None, exp.UnixToTime.SECONDS):
152        return rename_func("FROM_UNIXTIME")(self, expression)
153
154    return f"FROM_UNIXTIME({timestamp} / POW(10, {scale}))"
155
156
157def _str_to_date_sql(self: HiveGenerator, expression: exp.StrToDate) -> str:
158    this = self.sql(expression, "this")
159    time_format = self.format_time(expression)
160    if time_format not in (HIVE_TIME_FORMAT, HIVE_DATE_FORMAT):
161        this = f"FROM_UNIXTIME(UNIX_TIMESTAMP({this}, {time_format}))"
162    return f"CAST({this} AS DATE)"
163
164
165def _str_to_time_sql(self: HiveGenerator, expression: exp.StrToTime) -> str:
166    this = self.sql(expression, "this")
167    time_format = self.format_time(expression)
168    if time_format not in (HIVE_TIME_FORMAT, HIVE_DATE_FORMAT):
169        this = f"FROM_UNIXTIME(UNIX_TIMESTAMP({this}, {time_format}))"
170    return f"CAST({this} AS TIMESTAMP)"
171
172
173def _to_date_sql(self: HiveGenerator, expression: exp.TsOrDsToDate) -> str:
174    time_format = self.format_time(expression)
175    if time_format and time_format not in (HIVE_TIME_FORMAT, HIVE_DATE_FORMAT):
176        return self.func("TO_DATE", expression.this, time_format)
177
178    if isinstance(expression.parent, self.TS_OR_DS_EXPRESSIONS):
179        return self.sql(expression, "this")
180
181    return self.func("TO_DATE", expression.this)
182
183
184class HiveGenerator(generator.Generator):
185    SELECT_KINDS: tuple[str, ...] = ()
186    TRY_SUPPORTED = False
187    SUPPORTS_UESCAPE = False
188    SUPPORTS_DECODE_CASE = False
189    LIMIT_FETCH = "LIMIT"
190    TABLESAMPLE_WITH_METHOD = False
191    JOIN_HINTS = False
192    TABLE_HINTS = False
193    QUERY_HINTS = False
194    INDEX_ON = "ON TABLE"
195    EXTRACT_ALLOWS_QUOTES = False
196    NVL2_SUPPORTED = False
197    LAST_DAY_SUPPORTS_DATE_PART = False
198    JSON_PATH_SINGLE_QUOTE_ESCAPE = True
199    SAFE_JSON_PATH_KEY_RE = re.compile(r"^[_\-a-zA-Z][\-\w]*$")
200    SUPPORTS_TO_NUMBER = False
201    WITH_PROPERTIES_PREFIX = "TBLPROPERTIES"
202    PARSE_JSON_NAME: str | None = None
203    PAD_FILL_PATTERN_IS_REQUIRED = True
204    SUPPORTS_MEDIAN = False
205    ARRAY_SIZE_NAME = "SIZE"
206    ALTER_SET_TYPE = ""
207
208    EXPRESSIONS_WITHOUT_NESTED_CTES = {
209        exp.Insert,
210        exp.Select,
211        exp.Subquery,
212        exp.SetOperation,
213    }
214
215    SUPPORTED_JSON_PATH_PARTS = {
216        exp.JSONPathKey,
217        exp.JSONPathRoot,
218        exp.JSONPathSubscript,
219        exp.JSONPathWildcard,
220    }
221
222    TYPE_MAPPING = {
223        **generator.Generator.TYPE_MAPPING,
224        exp.DType.BIT: "BOOLEAN",
225        exp.DType.BLOB: "BINARY",
226        exp.DType.DATETIME: "TIMESTAMP",
227        exp.DType.ROWVERSION: "BINARY",
228        exp.DType.TEXT: "STRING",
229        exp.DType.TIME: "TIMESTAMP",
230        exp.DType.TIMESTAMPNTZ: "TIMESTAMP",
231        exp.DType.TIMESTAMPTZ: "TIMESTAMP",
232        exp.DType.UTINYINT: "SMALLINT",
233        exp.DType.VARBINARY: "BINARY",
234    }
235
236    TRANSFORMS = {
237        **generator.Generator.TRANSFORMS,
238        exp.Property: property_sql,
239        exp.AnyValue: rename_func("FIRST"),
240        exp.ApproxDistinct: approx_count_distinct_sql,
241        exp.ArgMax: arg_max_or_min_no_count("MAX_BY"),
242        exp.ArgMin: arg_max_or_min_no_count("MIN_BY"),
243        exp.Array: transforms.preprocess([transforms.inherit_struct_field_names]),
244        exp.ArrayConcat: rename_func("CONCAT"),
245        exp.ArrayToString: lambda self, e: self.func("CONCAT_WS", e.expression, e.this),
246        exp.ArraySort: _array_sort_sql,
247        exp.With: no_recursive_cte_sql,
248        exp.DateAdd: _add_date_sql,
249        exp.DateDiff: _date_diff_sql,
250        exp.DateStrToDate: datestrtodate_sql,
251        exp.DateSub: _add_date_sql,
252        exp.DateToDi: lambda self, e: (
253            f"CAST(DATE_FORMAT({self.sql(e, 'this')}, {HIVE_DATEINT_FORMAT}) AS INT)"
254        ),
255        exp.DiToDate: lambda self, e: (
256            f"TO_DATE(CAST({self.sql(e, 'this')} AS STRING), {HIVE_DATEINT_FORMAT})"
257        ),
258        exp.StorageHandlerProperty: lambda self, e: f"STORED BY {self.sql(e, 'this')}",
259        exp.FromBase64: rename_func("UNBASE64"),
260        exp.GenerateSeries: sequence_sql,
261        exp.GenerateDateArray: sequence_sql,
262        exp.If: if_sql(),
263        exp.ILike: no_ilike_sql,
264        exp.IntDiv: lambda self, e: self.binary(e, "DIV"),
265        exp.IsNan: rename_func("ISNAN"),
266        exp.JSONExtract: lambda self, e: self.func("GET_JSON_OBJECT", e.this, e.expression),
267        exp.JSONExtractScalar: lambda self, e: self.func("GET_JSON_OBJECT", e.this, e.expression),
268        exp.JSONFormat: _json_format_sql,
269        exp.Left: left_to_substring_sql,
270        exp.Map: var_map_sql,
271        exp.Max: max_or_greatest,
272        exp.MD5Digest: lambda self, e: self.func("UNHEX", self.func("MD5", e.this)),
273        exp.Min: min_or_least,
274        exp.MonthsBetween: lambda self, e: self.func("MONTHS_BETWEEN", e.this, e.expression),
275        exp.NotNullColumnConstraint: lambda _, e: "" if e.args.get("allow_null") else "NOT NULL",
276        exp.VarMap: var_map_sql,
277        exp.Create: preprocess(
278            [
279                remove_unique_constraints,
280                ctas_with_tmp_tables_to_create_tmp_view,
281                move_schema_columns_to_partitioned_by,
282            ]
283        ),
284        exp.Quantile: rename_func("PERCENTILE"),
285        exp.ApproxQuantile: rename_func("PERCENTILE_APPROX"),
286        exp.RegexpExtract: regexp_extract_sql,
287        exp.RegexpExtractAll: regexp_extract_sql,
288        exp.RegexpReplace: regexp_replace_sql,
289        exp.RegexpLike: lambda self, e: self.binary(e, "RLIKE"),
290        exp.RegexpSplit: rename_func("SPLIT"),
291        exp.Right: right_to_substring_sql,
292        exp.SchemaCommentProperty: lambda self, e: self.naked_property(e),
293        exp.ArrayUniqueAgg: rename_func("COLLECT_SET"),
294        exp.Split: lambda self, e: self.func(
295            "SPLIT", e.this, self.func("CONCAT", "'\\\\Q'", e.expression, "'\\\\E'")
296        ),
297        exp.Select: transforms.preprocess(
298            [
299                transforms.eliminate_qualify,
300                transforms.eliminate_distinct_on,
301                partial(transforms.unnest_to_explode, unnest_using_arrays_zip=False),
302                transforms.any_to_exists,
303            ]
304        ),
305        exp.StrPosition: lambda self, e: strposition_sql(
306            self, e, func_name="LOCATE", supports_position=True
307        ),
308        exp.StrToDate: _str_to_date_sql,
309        exp.StrToTime: _str_to_time_sql,
310        exp.StrToUnix: _str_to_unix_sql,
311        exp.StructExtract: struct_extract_sql,
312        exp.StarMap: rename_func("MAP"),
313        exp.Table: transforms.preprocess([transforms.unnest_generate_series]),
314        exp.TimeStrToDate: rename_func("TO_DATE"),
315        exp.TimeStrToTime: timestrtotime_sql,
316        exp.TimeStrToUnix: rename_func("UNIX_TIMESTAMP"),
317        exp.TimestampTrunc: lambda self, e: self.func("TRUNC", e.this, unit_to_str(e)),
318        exp.TimeToUnix: rename_func("UNIX_TIMESTAMP"),
319        exp.ToBase64: rename_func("BASE64"),
320        exp.TsOrDiToDi: lambda self, e: (
321            f"CAST(SUBSTR(REPLACE(CAST({self.sql(e, 'this')} AS STRING), '-', ''), 1, 8) AS INT)"
322        ),
323        exp.TsOrDsAdd: _add_date_sql,
324        exp.TsOrDsDiff: _date_diff_sql,
325        exp.TsOrDsToDate: _to_date_sql,
326        exp.TryCast: no_trycast_sql,
327        exp.Trim: trim_sql,
328        exp.Unicode: rename_func("ASCII"),
329        exp.UnixToStr: lambda self, e: self.func(
330            "FROM_UNIXTIME", e.this, time_format("hive")(self, e)
331        ),
332        exp.UnixToTime: _unix_to_time_sql,
333        exp.UnixToTimeStr: rename_func("FROM_UNIXTIME"),
334        exp.Unnest: rename_func("EXPLODE"),
335        exp.PartitionedByProperty: lambda self, e: f"PARTITIONED BY {self.sql(e, 'this')}",
336        exp.NumberToStr: rename_func("FORMAT_NUMBER"),
337        exp.National: lambda self, e: self.national_sql(e, prefix=""),
338        exp.ClusteredColumnConstraint: lambda self, e: (
339            f"({self.expressions(e, 'this', indent=False)})"
340        ),
341        exp.NonClusteredColumnConstraint: lambda self, e: (
342            f"({self.expressions(e, 'this', indent=False)})"
343        ),
344        exp.NotForReplicationColumnConstraint: lambda *_: "",
345        exp.OnProperty: lambda *_: "",
346        exp.PartitionedByBucket: lambda self, e: self.func("BUCKET", e.expression, e.this),
347        exp.PartitionByTruncate: lambda self, e: self.func("TRUNCATE", e.expression, e.this),
348        exp.PrimaryKeyColumnConstraint: lambda *_: "PRIMARY KEY",
349        exp.WeekOfYear: rename_func("WEEKOFYEAR"),
350        exp.DayOfMonth: rename_func("DAYOFMONTH"),
351        exp.DayOfWeek: rename_func("DAYOFWEEK"),
352        exp.Levenshtein: unsupported_args("ins_cost", "del_cost", "sub_cost", "max_dist")(
353            rename_func("LEVENSHTEIN")
354        ),
355    }
356
357    PROPERTIES_LOCATION = {
358        **generator.Generator.PROPERTIES_LOCATION,
359        exp.FileFormatProperty: exp.Properties.Location.POST_SCHEMA,
360        exp.PartitionedByProperty: exp.Properties.Location.POST_SCHEMA,
361        exp.VolatileProperty: exp.Properties.Location.UNSUPPORTED,
362        exp.WithDataProperty: exp.Properties.Location.UNSUPPORTED,
363    }
364
365    TS_OR_DS_EXPRESSIONS = HIVE_TS_OR_DS_EXPRESSIONS
366
367    IGNORE_NULLS_FUNCS = (exp.First, exp.Last, exp.FirstValue, exp.LastValue)
368
369    def ignorenulls_sql(self, expression: exp.IgnoreNulls) -> str:
370        this = expression.this
371        if isinstance(this, self.IGNORE_NULLS_FUNCS):
372            return self.func(this.sql_name(), this.this, exp.true())
373
374        return super().ignorenulls_sql(expression)
375
376    def unnest_sql(self, expression: exp.Unnest) -> str:
377        return rename_func("EXPLODE")(self, expression)
378
379    def _jsonpathkey_sql(self, expression: exp.JSONPathKey) -> str:
380        if isinstance(expression.this, exp.JSONPathWildcard):
381            self.unsupported("Unsupported wildcard in JSONPathKey expression")
382            return ""
383
384        return super()._jsonpathkey_sql(expression)
385
386    def parameter_sql(self, expression: exp.Parameter) -> str:
387        this = self.sql(expression, "this")
388        expression_sql = self.sql(expression, "expression")
389
390        parent = expression.parent
391        this = f"{this}:{expression_sql}" if expression_sql else this
392
393        if isinstance(parent, exp.EQ) and isinstance(parent.parent, exp.SetItem):
394            # We need to produce SET key = value instead of SET ${key} = value
395            return this
396
397        return f"${{{this}}}"
398
399    def schema_sql(self, expression: exp.Schema) -> str:
400        for ordered in expression.find_all(exp.Ordered):
401            if ordered.args.get("desc") is False:
402                ordered.set("desc", None)
403
404        return super().schema_sql(expression)
405
406    def constraint_sql(self, expression: exp.Constraint) -> str:
407        for prop in list(expression.find_all(exp.Properties)):
408            prop.pop()
409
410        this = self.sql(expression, "this")
411        expressions = self.expressions(expression, sep=" ", flat=True)
412        return f"CONSTRAINT {this} {expressions}"
413
414    def rowformatserdeproperty_sql(self, expression: exp.RowFormatSerdeProperty) -> str:
415        serde_props = self.sql(expression, "serde_properties")
416        serde_props = f" {serde_props}" if serde_props else ""
417        return f"ROW FORMAT SERDE {self.sql(expression, 'this')}{serde_props}"
418
419    def arrayagg_sql(self, expression: exp.ArrayAgg) -> str:
420        return self.func(
421            "COLLECT_LIST",
422            expression.this.this if isinstance(expression.this, exp.Order) else expression.this,
423        )
424
425    # Hive/Spark lack native numeric TRUNC. CAST to BIGINT truncates toward zero (not rounds).
426    # Potential enhancement: a TRUNC_TEMPLATE using FLOOR/CEIL with scale (Spark 3.3+)
427    # could preserve decimals: CASE WHEN x >= 0 THEN FLOOR(x, d) ELSE CEIL(x, d) END
428    @unsupported_args("decimals")
429    def trunc_sql(self, expression: exp.Trunc) -> str:
430        return self.sql(exp.cast(expression.this, exp.DType.BIGINT))
431
432    def datatype_sql(self, expression: exp.DataType) -> str:
433        if expression.this in self.PARAMETERIZABLE_TEXT_TYPES and (
434            not expression.expressions or expression.expressions[0].name == "MAX"
435        ):
436            expression = exp.DType.TEXT.into_expr()
437        elif expression.is_type(exp.DType.TEXT) and expression.expressions:
438            expression.set("this", exp.DType.VARCHAR)
439        elif expression.this in exp.DataType.TEMPORAL_TYPES:
440            expression = exp.DataType.build(expression.this)
441        elif expression.is_type("float"):
442            size_expression = expression.find(exp.DataTypeParam)
443            if size_expression:
444                size = int(size_expression.name)
445                builder = exp.DType.FLOAT if size <= 32 else exp.DType.DOUBLE
446                expression = builder.into_expr()
447        return super().datatype_sql(expression)
448
449    def version_sql(self, expression: exp.Version) -> str:
450        sql = super().version_sql(expression)
451        return sql.replace("FOR ", "", 1)
452
453    def struct_sql(self, expression: exp.Struct) -> str:
454        values = []
455
456        for i, e in enumerate(expression.expressions):
457            if isinstance(e, exp.PropertyEQ):
458                self.unsupported("Hive does not support named structs.")
459                values.append(e.expression)
460            else:
461                values.append(e)
462
463        return self.func("STRUCT", *values)
464
465    def columndef_sql(self, expression: exp.ColumnDef, sep: str = " ") -> str:
466        return super().columndef_sql(
467            expression,
468            sep=(
469                ": "
470                if isinstance(expression.parent, exp.DataType)
471                and expression.parent.is_type("struct")
472                else sep
473            ),
474        )
475
476    def altercolumn_sql(self, expression: exp.AlterColumn) -> str:
477        this = self.sql(expression, "this")
478        new_name = self.sql(expression, "rename_to") or this
479        dtype = self.sql(expression, "dtype")
480        comment = (
481            f" COMMENT {self.sql(expression, 'comment')}" if self.sql(expression, "comment") else ""
482        )
483        default = self.sql(expression, "default")
484        visible = expression.args.get("visible")
485        allow_null = expression.args.get("allow_null")
486        drop = expression.args.get("drop")
487
488        if any([default, drop, visible, allow_null, drop]):
489            self.unsupported("Unsupported CHANGE COLUMN syntax")
490
491        if not dtype:
492            self.unsupported("CHANGE COLUMN without a type is not supported")
493
494        return f"CHANGE COLUMN {this} {new_name} {dtype}{comment}"
495
496    def renamecolumn_sql(self, expression: exp.RenameColumn) -> str:
497        self.unsupported("Cannot rename columns without data type defined in Hive")
498        return ""
499
500    def alterset_sql(self, expression: exp.AlterSet) -> str:
501        exprs = self.expressions(expression, flat=True)
502        exprs = f" {exprs}" if exprs else ""
503        location = self.sql(expression, "location")
504        location = f" LOCATION {location}" if location else ""
505        file_format = self.expressions(expression, key="file_format", flat=True, sep=" ")
506        file_format = f" FILEFORMAT {file_format}" if file_format else ""
507        serde = self.sql(expression, "serde")
508        serde = f" SERDE {serde}" if serde else ""
509        tags = self.expressions(expression, key="tag", flat=True, sep="")
510        tags = f" TAGS {tags}" if tags else ""
511
512        return f"SET{serde}{exprs}{location}{file_format}{tags}"
513
514    def serdeproperties_sql(self, expression: exp.SerdeProperties) -> str:
515        prefix = "WITH " if expression.args.get("with_") else ""
516        exprs = self.expressions(expression, flat=True)
517
518        return f"{prefix}SERDEPROPERTIES ({exprs})"
519
520    def exists_sql(self, expression: exp.Exists) -> str:
521        if expression.expression:
522            return self.function_fallback_sql(expression)
523
524        return super().exists_sql(expression)
525
526    def timetostr_sql(self, expression: exp.TimeToStr) -> str:
527        this = expression.this
528        if isinstance(this, exp.TimeStrToTime):
529            this = this.this
530
531        return self.func("DATE_FORMAT", this, self.format_time(expression))
532
533    def usingproperty_sql(self, expression: exp.UsingProperty) -> str:
534        kind = expression.args.get("kind")
535        return f"USING {kind} {self.sql(expression, 'this')}"
536
537    def fileformatproperty_sql(self, expression: exp.FileFormatProperty) -> str:
538        if isinstance(expression.this, exp.InputOutputFormat):
539            this = self.sql(expression, "this")
540        else:
541            this = expression.name.upper()
542
543        return f"STORED AS {this}"
HIVE_TIME_FORMAT = "'yyyy-MM-dd HH:mm:ss'"
HIVE_DATE_FORMAT = "'yyyy-MM-dd'"
HIVE_DATEINT_FORMAT = "'yyyyMMdd'"
DATE_DELTA_INTERVAL = {'YEAR': ('ADD_MONTHS', 12), 'MONTH': ('ADD_MONTHS', 1), 'QUARTER': ('ADD_MONTHS', 3), 'WEEK': ('DATE_ADD', 7), 'DAY': ('DATE_ADD', 1)}
TIME_DIFF_FACTOR = {'MILLISECOND': ' * 1000', 'SECOND': '', 'MINUTE': ' / 60', 'HOUR': ' / 3600'}
DIFF_MONTH_SWITCH = ('YEAR', 'QUARTER', 'MONTH')
class HiveGenerator(sqlglot.generator.Generator):
185class HiveGenerator(generator.Generator):
186    SELECT_KINDS: tuple[str, ...] = ()
187    TRY_SUPPORTED = False
188    SUPPORTS_UESCAPE = False
189    SUPPORTS_DECODE_CASE = False
190    LIMIT_FETCH = "LIMIT"
191    TABLESAMPLE_WITH_METHOD = False
192    JOIN_HINTS = False
193    TABLE_HINTS = False
194    QUERY_HINTS = False
195    INDEX_ON = "ON TABLE"
196    EXTRACT_ALLOWS_QUOTES = False
197    NVL2_SUPPORTED = False
198    LAST_DAY_SUPPORTS_DATE_PART = False
199    JSON_PATH_SINGLE_QUOTE_ESCAPE = True
200    SAFE_JSON_PATH_KEY_RE = re.compile(r"^[_\-a-zA-Z][\-\w]*$")
201    SUPPORTS_TO_NUMBER = False
202    WITH_PROPERTIES_PREFIX = "TBLPROPERTIES"
203    PARSE_JSON_NAME: str | None = None
204    PAD_FILL_PATTERN_IS_REQUIRED = True
205    SUPPORTS_MEDIAN = False
206    ARRAY_SIZE_NAME = "SIZE"
207    ALTER_SET_TYPE = ""
208
209    EXPRESSIONS_WITHOUT_NESTED_CTES = {
210        exp.Insert,
211        exp.Select,
212        exp.Subquery,
213        exp.SetOperation,
214    }
215
216    SUPPORTED_JSON_PATH_PARTS = {
217        exp.JSONPathKey,
218        exp.JSONPathRoot,
219        exp.JSONPathSubscript,
220        exp.JSONPathWildcard,
221    }
222
223    TYPE_MAPPING = {
224        **generator.Generator.TYPE_MAPPING,
225        exp.DType.BIT: "BOOLEAN",
226        exp.DType.BLOB: "BINARY",
227        exp.DType.DATETIME: "TIMESTAMP",
228        exp.DType.ROWVERSION: "BINARY",
229        exp.DType.TEXT: "STRING",
230        exp.DType.TIME: "TIMESTAMP",
231        exp.DType.TIMESTAMPNTZ: "TIMESTAMP",
232        exp.DType.TIMESTAMPTZ: "TIMESTAMP",
233        exp.DType.UTINYINT: "SMALLINT",
234        exp.DType.VARBINARY: "BINARY",
235    }
236
237    TRANSFORMS = {
238        **generator.Generator.TRANSFORMS,
239        exp.Property: property_sql,
240        exp.AnyValue: rename_func("FIRST"),
241        exp.ApproxDistinct: approx_count_distinct_sql,
242        exp.ArgMax: arg_max_or_min_no_count("MAX_BY"),
243        exp.ArgMin: arg_max_or_min_no_count("MIN_BY"),
244        exp.Array: transforms.preprocess([transforms.inherit_struct_field_names]),
245        exp.ArrayConcat: rename_func("CONCAT"),
246        exp.ArrayToString: lambda self, e: self.func("CONCAT_WS", e.expression, e.this),
247        exp.ArraySort: _array_sort_sql,
248        exp.With: no_recursive_cte_sql,
249        exp.DateAdd: _add_date_sql,
250        exp.DateDiff: _date_diff_sql,
251        exp.DateStrToDate: datestrtodate_sql,
252        exp.DateSub: _add_date_sql,
253        exp.DateToDi: lambda self, e: (
254            f"CAST(DATE_FORMAT({self.sql(e, 'this')}, {HIVE_DATEINT_FORMAT}) AS INT)"
255        ),
256        exp.DiToDate: lambda self, e: (
257            f"TO_DATE(CAST({self.sql(e, 'this')} AS STRING), {HIVE_DATEINT_FORMAT})"
258        ),
259        exp.StorageHandlerProperty: lambda self, e: f"STORED BY {self.sql(e, 'this')}",
260        exp.FromBase64: rename_func("UNBASE64"),
261        exp.GenerateSeries: sequence_sql,
262        exp.GenerateDateArray: sequence_sql,
263        exp.If: if_sql(),
264        exp.ILike: no_ilike_sql,
265        exp.IntDiv: lambda self, e: self.binary(e, "DIV"),
266        exp.IsNan: rename_func("ISNAN"),
267        exp.JSONExtract: lambda self, e: self.func("GET_JSON_OBJECT", e.this, e.expression),
268        exp.JSONExtractScalar: lambda self, e: self.func("GET_JSON_OBJECT", e.this, e.expression),
269        exp.JSONFormat: _json_format_sql,
270        exp.Left: left_to_substring_sql,
271        exp.Map: var_map_sql,
272        exp.Max: max_or_greatest,
273        exp.MD5Digest: lambda self, e: self.func("UNHEX", self.func("MD5", e.this)),
274        exp.Min: min_or_least,
275        exp.MonthsBetween: lambda self, e: self.func("MONTHS_BETWEEN", e.this, e.expression),
276        exp.NotNullColumnConstraint: lambda _, e: "" if e.args.get("allow_null") else "NOT NULL",
277        exp.VarMap: var_map_sql,
278        exp.Create: preprocess(
279            [
280                remove_unique_constraints,
281                ctas_with_tmp_tables_to_create_tmp_view,
282                move_schema_columns_to_partitioned_by,
283            ]
284        ),
285        exp.Quantile: rename_func("PERCENTILE"),
286        exp.ApproxQuantile: rename_func("PERCENTILE_APPROX"),
287        exp.RegexpExtract: regexp_extract_sql,
288        exp.RegexpExtractAll: regexp_extract_sql,
289        exp.RegexpReplace: regexp_replace_sql,
290        exp.RegexpLike: lambda self, e: self.binary(e, "RLIKE"),
291        exp.RegexpSplit: rename_func("SPLIT"),
292        exp.Right: right_to_substring_sql,
293        exp.SchemaCommentProperty: lambda self, e: self.naked_property(e),
294        exp.ArrayUniqueAgg: rename_func("COLLECT_SET"),
295        exp.Split: lambda self, e: self.func(
296            "SPLIT", e.this, self.func("CONCAT", "'\\\\Q'", e.expression, "'\\\\E'")
297        ),
298        exp.Select: transforms.preprocess(
299            [
300                transforms.eliminate_qualify,
301                transforms.eliminate_distinct_on,
302                partial(transforms.unnest_to_explode, unnest_using_arrays_zip=False),
303                transforms.any_to_exists,
304            ]
305        ),
306        exp.StrPosition: lambda self, e: strposition_sql(
307            self, e, func_name="LOCATE", supports_position=True
308        ),
309        exp.StrToDate: _str_to_date_sql,
310        exp.StrToTime: _str_to_time_sql,
311        exp.StrToUnix: _str_to_unix_sql,
312        exp.StructExtract: struct_extract_sql,
313        exp.StarMap: rename_func("MAP"),
314        exp.Table: transforms.preprocess([transforms.unnest_generate_series]),
315        exp.TimeStrToDate: rename_func("TO_DATE"),
316        exp.TimeStrToTime: timestrtotime_sql,
317        exp.TimeStrToUnix: rename_func("UNIX_TIMESTAMP"),
318        exp.TimestampTrunc: lambda self, e: self.func("TRUNC", e.this, unit_to_str(e)),
319        exp.TimeToUnix: rename_func("UNIX_TIMESTAMP"),
320        exp.ToBase64: rename_func("BASE64"),
321        exp.TsOrDiToDi: lambda self, e: (
322            f"CAST(SUBSTR(REPLACE(CAST({self.sql(e, 'this')} AS STRING), '-', ''), 1, 8) AS INT)"
323        ),
324        exp.TsOrDsAdd: _add_date_sql,
325        exp.TsOrDsDiff: _date_diff_sql,
326        exp.TsOrDsToDate: _to_date_sql,
327        exp.TryCast: no_trycast_sql,
328        exp.Trim: trim_sql,
329        exp.Unicode: rename_func("ASCII"),
330        exp.UnixToStr: lambda self, e: self.func(
331            "FROM_UNIXTIME", e.this, time_format("hive")(self, e)
332        ),
333        exp.UnixToTime: _unix_to_time_sql,
334        exp.UnixToTimeStr: rename_func("FROM_UNIXTIME"),
335        exp.Unnest: rename_func("EXPLODE"),
336        exp.PartitionedByProperty: lambda self, e: f"PARTITIONED BY {self.sql(e, 'this')}",
337        exp.NumberToStr: rename_func("FORMAT_NUMBER"),
338        exp.National: lambda self, e: self.national_sql(e, prefix=""),
339        exp.ClusteredColumnConstraint: lambda self, e: (
340            f"({self.expressions(e, 'this', indent=False)})"
341        ),
342        exp.NonClusteredColumnConstraint: lambda self, e: (
343            f"({self.expressions(e, 'this', indent=False)})"
344        ),
345        exp.NotForReplicationColumnConstraint: lambda *_: "",
346        exp.OnProperty: lambda *_: "",
347        exp.PartitionedByBucket: lambda self, e: self.func("BUCKET", e.expression, e.this),
348        exp.PartitionByTruncate: lambda self, e: self.func("TRUNCATE", e.expression, e.this),
349        exp.PrimaryKeyColumnConstraint: lambda *_: "PRIMARY KEY",
350        exp.WeekOfYear: rename_func("WEEKOFYEAR"),
351        exp.DayOfMonth: rename_func("DAYOFMONTH"),
352        exp.DayOfWeek: rename_func("DAYOFWEEK"),
353        exp.Levenshtein: unsupported_args("ins_cost", "del_cost", "sub_cost", "max_dist")(
354            rename_func("LEVENSHTEIN")
355        ),
356    }
357
358    PROPERTIES_LOCATION = {
359        **generator.Generator.PROPERTIES_LOCATION,
360        exp.FileFormatProperty: exp.Properties.Location.POST_SCHEMA,
361        exp.PartitionedByProperty: exp.Properties.Location.POST_SCHEMA,
362        exp.VolatileProperty: exp.Properties.Location.UNSUPPORTED,
363        exp.WithDataProperty: exp.Properties.Location.UNSUPPORTED,
364    }
365
366    TS_OR_DS_EXPRESSIONS = HIVE_TS_OR_DS_EXPRESSIONS
367
368    IGNORE_NULLS_FUNCS = (exp.First, exp.Last, exp.FirstValue, exp.LastValue)
369
370    def ignorenulls_sql(self, expression: exp.IgnoreNulls) -> str:
371        this = expression.this
372        if isinstance(this, self.IGNORE_NULLS_FUNCS):
373            return self.func(this.sql_name(), this.this, exp.true())
374
375        return super().ignorenulls_sql(expression)
376
377    def unnest_sql(self, expression: exp.Unnest) -> str:
378        return rename_func("EXPLODE")(self, expression)
379
380    def _jsonpathkey_sql(self, expression: exp.JSONPathKey) -> str:
381        if isinstance(expression.this, exp.JSONPathWildcard):
382            self.unsupported("Unsupported wildcard in JSONPathKey expression")
383            return ""
384
385        return super()._jsonpathkey_sql(expression)
386
387    def parameter_sql(self, expression: exp.Parameter) -> str:
388        this = self.sql(expression, "this")
389        expression_sql = self.sql(expression, "expression")
390
391        parent = expression.parent
392        this = f"{this}:{expression_sql}" if expression_sql else this
393
394        if isinstance(parent, exp.EQ) and isinstance(parent.parent, exp.SetItem):
395            # We need to produce SET key = value instead of SET ${key} = value
396            return this
397
398        return f"${{{this}}}"
399
400    def schema_sql(self, expression: exp.Schema) -> str:
401        for ordered in expression.find_all(exp.Ordered):
402            if ordered.args.get("desc") is False:
403                ordered.set("desc", None)
404
405        return super().schema_sql(expression)
406
407    def constraint_sql(self, expression: exp.Constraint) -> str:
408        for prop in list(expression.find_all(exp.Properties)):
409            prop.pop()
410
411        this = self.sql(expression, "this")
412        expressions = self.expressions(expression, sep=" ", flat=True)
413        return f"CONSTRAINT {this} {expressions}"
414
415    def rowformatserdeproperty_sql(self, expression: exp.RowFormatSerdeProperty) -> str:
416        serde_props = self.sql(expression, "serde_properties")
417        serde_props = f" {serde_props}" if serde_props else ""
418        return f"ROW FORMAT SERDE {self.sql(expression, 'this')}{serde_props}"
419
420    def arrayagg_sql(self, expression: exp.ArrayAgg) -> str:
421        return self.func(
422            "COLLECT_LIST",
423            expression.this.this if isinstance(expression.this, exp.Order) else expression.this,
424        )
425
426    # Hive/Spark lack native numeric TRUNC. CAST to BIGINT truncates toward zero (not rounds).
427    # Potential enhancement: a TRUNC_TEMPLATE using FLOOR/CEIL with scale (Spark 3.3+)
428    # could preserve decimals: CASE WHEN x >= 0 THEN FLOOR(x, d) ELSE CEIL(x, d) END
429    @unsupported_args("decimals")
430    def trunc_sql(self, expression: exp.Trunc) -> str:
431        return self.sql(exp.cast(expression.this, exp.DType.BIGINT))
432
433    def datatype_sql(self, expression: exp.DataType) -> str:
434        if expression.this in self.PARAMETERIZABLE_TEXT_TYPES and (
435            not expression.expressions or expression.expressions[0].name == "MAX"
436        ):
437            expression = exp.DType.TEXT.into_expr()
438        elif expression.is_type(exp.DType.TEXT) and expression.expressions:
439            expression.set("this", exp.DType.VARCHAR)
440        elif expression.this in exp.DataType.TEMPORAL_TYPES:
441            expression = exp.DataType.build(expression.this)
442        elif expression.is_type("float"):
443            size_expression = expression.find(exp.DataTypeParam)
444            if size_expression:
445                size = int(size_expression.name)
446                builder = exp.DType.FLOAT if size <= 32 else exp.DType.DOUBLE
447                expression = builder.into_expr()
448        return super().datatype_sql(expression)
449
450    def version_sql(self, expression: exp.Version) -> str:
451        sql = super().version_sql(expression)
452        return sql.replace("FOR ", "", 1)
453
454    def struct_sql(self, expression: exp.Struct) -> str:
455        values = []
456
457        for i, e in enumerate(expression.expressions):
458            if isinstance(e, exp.PropertyEQ):
459                self.unsupported("Hive does not support named structs.")
460                values.append(e.expression)
461            else:
462                values.append(e)
463
464        return self.func("STRUCT", *values)
465
466    def columndef_sql(self, expression: exp.ColumnDef, sep: str = " ") -> str:
467        return super().columndef_sql(
468            expression,
469            sep=(
470                ": "
471                if isinstance(expression.parent, exp.DataType)
472                and expression.parent.is_type("struct")
473                else sep
474            ),
475        )
476
477    def altercolumn_sql(self, expression: exp.AlterColumn) -> str:
478        this = self.sql(expression, "this")
479        new_name = self.sql(expression, "rename_to") or this
480        dtype = self.sql(expression, "dtype")
481        comment = (
482            f" COMMENT {self.sql(expression, 'comment')}" if self.sql(expression, "comment") else ""
483        )
484        default = self.sql(expression, "default")
485        visible = expression.args.get("visible")
486        allow_null = expression.args.get("allow_null")
487        drop = expression.args.get("drop")
488
489        if any([default, drop, visible, allow_null, drop]):
490            self.unsupported("Unsupported CHANGE COLUMN syntax")
491
492        if not dtype:
493            self.unsupported("CHANGE COLUMN without a type is not supported")
494
495        return f"CHANGE COLUMN {this} {new_name} {dtype}{comment}"
496
497    def renamecolumn_sql(self, expression: exp.RenameColumn) -> str:
498        self.unsupported("Cannot rename columns without data type defined in Hive")
499        return ""
500
501    def alterset_sql(self, expression: exp.AlterSet) -> str:
502        exprs = self.expressions(expression, flat=True)
503        exprs = f" {exprs}" if exprs else ""
504        location = self.sql(expression, "location")
505        location = f" LOCATION {location}" if location else ""
506        file_format = self.expressions(expression, key="file_format", flat=True, sep=" ")
507        file_format = f" FILEFORMAT {file_format}" if file_format else ""
508        serde = self.sql(expression, "serde")
509        serde = f" SERDE {serde}" if serde else ""
510        tags = self.expressions(expression, key="tag", flat=True, sep="")
511        tags = f" TAGS {tags}" if tags else ""
512
513        return f"SET{serde}{exprs}{location}{file_format}{tags}"
514
515    def serdeproperties_sql(self, expression: exp.SerdeProperties) -> str:
516        prefix = "WITH " if expression.args.get("with_") else ""
517        exprs = self.expressions(expression, flat=True)
518
519        return f"{prefix}SERDEPROPERTIES ({exprs})"
520
521    def exists_sql(self, expression: exp.Exists) -> str:
522        if expression.expression:
523            return self.function_fallback_sql(expression)
524
525        return super().exists_sql(expression)
526
527    def timetostr_sql(self, expression: exp.TimeToStr) -> str:
528        this = expression.this
529        if isinstance(this, exp.TimeStrToTime):
530            this = this.this
531
532        return self.func("DATE_FORMAT", this, self.format_time(expression))
533
534    def usingproperty_sql(self, expression: exp.UsingProperty) -> str:
535        kind = expression.args.get("kind")
536        return f"USING {kind} {self.sql(expression, 'this')}"
537
538    def fileformatproperty_sql(self, expression: exp.FileFormatProperty) -> str:
539        if isinstance(expression.this, exp.InputOutputFormat):
540            this = self.sql(expression, "this")
541        else:
542            this = expression.name.upper()
543
544        return f"STORED AS {this}"

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
LIMIT_FETCH = 'LIMIT'
TABLESAMPLE_WITH_METHOD = False
JOIN_HINTS = False
TABLE_HINTS = False
QUERY_HINTS = False
INDEX_ON = 'ON TABLE'
EXTRACT_ALLOWS_QUOTES = False
NVL2_SUPPORTED = False
LAST_DAY_SUPPORTS_DATE_PART = False
JSON_PATH_SINGLE_QUOTE_ESCAPE = True
SAFE_JSON_PATH_KEY_RE = re.compile('^[_\\-a-zA-Z][\\-\\w]*$')
SUPPORTS_TO_NUMBER = False
WITH_PROPERTIES_PREFIX = 'TBLPROPERTIES'
PARSE_JSON_NAME: str | None = None
PAD_FILL_PATTERN_IS_REQUIRED = True
SUPPORTS_MEDIAN = False
ARRAY_SIZE_NAME = 'SIZE'
ALTER_SET_TYPE = ''
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'>: 'BINARY', <DType.MEDIUMBLOB: 'MEDIUMBLOB'>: 'BLOB', <DType.LONGBLOB: 'LONGBLOB'>: 'BLOB', <DType.TINYBLOB: 'TINYBLOB'>: 'BLOB', <DType.INET: 'INET'>: 'INET', <DType.ROWVERSION: 'ROWVERSION'>: 'BINARY', <DType.SMALLDATETIME: 'SMALLDATETIME'>: 'TIMESTAMP', <DType.BIT: 'BIT'>: 'BOOLEAN', <DType.DATETIME: 'DATETIME'>: 'TIMESTAMP', <DType.TEXT: 'TEXT'>: 'STRING', <DType.TIME: 'TIME'>: 'TIMESTAMP', <DType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>: 'TIMESTAMP', <DType.TIMESTAMPTZ: 'TIMESTAMPTZ'>: 'TIMESTAMP', <DType.UTINYINT: 'UTINYINT'>: 'SMALLINT', <DType.VARBINARY: 'VARBINARY'>: 'BINARY'}
TRANSFORMS = {<class 'sqlglot.expressions.query.JSONPathKey'>: <function <lambda>>, <class 'sqlglot.expressions.query.JSONPathRoot'>: <function <lambda>>, <class 'sqlglot.expressions.query.JSONPathSubscript'>: <function <lambda>>, <class 'sqlglot.expressions.query.JSONPathWildcard'>: <function <lambda>>, <class 'sqlglot.expressions.core.Adjacent'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.AllowedValuesProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.AnalyzeColumns'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.AnalyzeWith'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.array.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 HiveGenerator.<lambda>>, <class 'sqlglot.expressions.constraints.CollateColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.CommentColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.functions.ConnectByRoot'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.string.ConvertToCharset'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.CopyGrantsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.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 Generator.<lambda>>, <class 'sqlglot.expressions.properties.LanguageProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.LocationProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.LogProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.MaskingProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.MaterializedProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.functions.NetFunc'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.NetworkProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.NonClusteredColumnConstraint'>: <function HiveGenerator.<lambda>>, <class 'sqlglot.expressions.properties.NoPrimaryIndexProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.NotForReplicationColumnConstraint'>: <function HiveGenerator.<lambda>>, <class 'sqlglot.expressions.properties.OnCommitProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.OnProperty'>: <function HiveGenerator.<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 HiveGenerator.<lambda>>, <class 'sqlglot.expressions.properties.PartitionByTruncate'>: <function HiveGenerator.<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 var_map_sql>, <class 'sqlglot.expressions.properties.ViewAttributeProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.VolatileProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.WithJournalTableProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.WithProcedureOptions'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.WithSchemaBindingProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.WithOperator'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ForceProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.Property'>: <function property_sql>, <class 'sqlglot.expressions.aggregate.AnyValue'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.core.ApproxDistinct'>: <function approx_count_distinct_sql>, <class 'sqlglot.expressions.aggregate.ArgMax'>: <function arg_max_or_min_no_count.<locals>._arg_max_or_min_sql>, <class 'sqlglot.expressions.aggregate.ArgMin'>: <function arg_max_or_min_no_count.<locals>._arg_max_or_min_sql>, <class 'sqlglot.expressions.array.Array'>: <function preprocess.<locals>._to_sql>, <class 'sqlglot.expressions.array.ArrayConcat'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.array.ArrayToString'>: <function HiveGenerator.<lambda>>, <class 'sqlglot.expressions.array.ArraySort'>: <function _array_sort_sql>, <class 'sqlglot.expressions.query.With'>: <function no_recursive_cte_sql>, <class 'sqlglot.expressions.temporal.DateAdd'>: <function _add_date_sql>, <class 'sqlglot.expressions.temporal.DateDiff'>: <function _date_diff_sql>, <class 'sqlglot.expressions.temporal.DateStrToDate'>: <function datestrtodate_sql>, <class 'sqlglot.expressions.temporal.DateSub'>: <function _add_date_sql>, <class 'sqlglot.expressions.temporal.DateToDi'>: <function HiveGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.DiToDate'>: <function HiveGenerator.<lambda>>, <class 'sqlglot.expressions.properties.StorageHandlerProperty'>: <function HiveGenerator.<lambda>>, <class 'sqlglot.expressions.string.FromBase64'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.array.GenerateSeries'>: <function sequence_sql>, <class 'sqlglot.expressions.temporal.GenerateDateArray'>: <function sequence_sql>, <class 'sqlglot.expressions.functions.If'>: <function if_sql.<locals>._if_sql>, <class 'sqlglot.expressions.core.ILike'>: <function no_ilike_sql>, <class 'sqlglot.expressions.core.IntDiv'>: <function HiveGenerator.<lambda>>, <class 'sqlglot.expressions.math.IsNan'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.json.JSONExtract'>: <function HiveGenerator.<lambda>>, <class 'sqlglot.expressions.json.JSONExtractScalar'>: <function HiveGenerator.<lambda>>, <class 'sqlglot.expressions.json.JSONFormat'>: <function _json_format_sql>, <class 'sqlglot.expressions.string.Left'>: <function left_to_substring_sql>, <class 'sqlglot.expressions.array.Map'>: <function var_map_sql>, <class 'sqlglot.expressions.aggregate.Max'>: <function max_or_greatest>, <class 'sqlglot.expressions.string.MD5Digest'>: <function HiveGenerator.<lambda>>, <class 'sqlglot.expressions.aggregate.Min'>: <function min_or_least>, <class 'sqlglot.expressions.temporal.MonthsBetween'>: <function HiveGenerator.<lambda>>, <class 'sqlglot.expressions.constraints.NotNullColumnConstraint'>: <function HiveGenerator.<lambda>>, <class 'sqlglot.expressions.ddl.Create'>: <function preprocess.<locals>._to_sql>, <class 'sqlglot.expressions.aggregate.Quantile'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.aggregate.ApproxQuantile'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.string.RegexpExtract'>: <function regexp_extract_sql>, <class 'sqlglot.expressions.string.RegexpExtractAll'>: <function regexp_extract_sql>, <class 'sqlglot.expressions.string.RegexpReplace'>: <function regexp_replace_sql>, <class 'sqlglot.expressions.core.RegexpLike'>: <function HiveGenerator.<lambda>>, <class 'sqlglot.expressions.string.RegexpSplit'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.string.Right'>: <function right_to_substring_sql>, <class 'sqlglot.expressions.properties.SchemaCommentProperty'>: <function HiveGenerator.<lambda>>, <class 'sqlglot.expressions.aggregate.ArrayUniqueAgg'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.string.Split'>: <function HiveGenerator.<lambda>>, <class 'sqlglot.expressions.query.Select'>: <function preprocess.<locals>._to_sql>, <class 'sqlglot.expressions.string.StrPosition'>: <function HiveGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.StrToDate'>: <function _str_to_date_sql>, <class 'sqlglot.expressions.temporal.StrToTime'>: <function _str_to_time_sql>, <class 'sqlglot.expressions.temporal.StrToUnix'>: <function _str_to_unix_sql>, <class 'sqlglot.expressions.array.StructExtract'>: <function struct_extract_sql>, <class 'sqlglot.expressions.array.StarMap'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.query.Table'>: <function preprocess.<locals>._to_sql>, <class 'sqlglot.expressions.temporal.TimeStrToDate'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.TimeStrToTime'>: <function timestrtotime_sql>, <class 'sqlglot.expressions.temporal.TimeStrToUnix'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.TimestampTrunc'>: <function HiveGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.TimeToUnix'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.string.ToBase64'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.TsOrDiToDi'>: <function HiveGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.TsOrDsAdd'>: <function _add_date_sql>, <class 'sqlglot.expressions.temporal.TsOrDsDiff'>: <function _date_diff_sql>, <class 'sqlglot.expressions.temporal.TsOrDsToDate'>: <function _to_date_sql>, <class 'sqlglot.expressions.functions.TryCast'>: <function no_trycast_sql>, <class 'sqlglot.expressions.string.Trim'>: <function trim_sql>, <class 'sqlglot.expressions.string.Unicode'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.UnixToStr'>: <function HiveGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.UnixToTime'>: <function _unix_to_time_sql>, <class 'sqlglot.expressions.temporal.UnixToTimeStr'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.array.Unnest'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.properties.PartitionedByProperty'>: <function HiveGenerator.<lambda>>, <class 'sqlglot.expressions.string.NumberToStr'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.query.National'>: <function HiveGenerator.<lambda>>, <class 'sqlglot.expressions.constraints.PrimaryKeyColumnConstraint'>: <function HiveGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.WeekOfYear'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.DayOfMonth'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.DayOfWeek'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.string.Levenshtein'>: <function rename_func.<locals>.<lambda>>}
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_SCHEMA: 'POST_SCHEMA'>, <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.POST_CREATE: 'POST_CREATE'>, <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.UNSUPPORTED: 'UNSUPPORTED'>, <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 ignorenulls_sql(self, expression: sqlglot.expressions.core.IgnoreNulls) -> str:
370    def ignorenulls_sql(self, expression: exp.IgnoreNulls) -> str:
371        this = expression.this
372        if isinstance(this, self.IGNORE_NULLS_FUNCS):
373            return self.func(this.sql_name(), this.this, exp.true())
374
375        return super().ignorenulls_sql(expression)
def unnest_sql(self, expression: sqlglot.expressions.array.Unnest) -> str:
377    def unnest_sql(self, expression: exp.Unnest) -> str:
378        return rename_func("EXPLODE")(self, expression)
def parameter_sql(self, expression: sqlglot.expressions.core.Parameter) -> str:
387    def parameter_sql(self, expression: exp.Parameter) -> str:
388        this = self.sql(expression, "this")
389        expression_sql = self.sql(expression, "expression")
390
391        parent = expression.parent
392        this = f"{this}:{expression_sql}" if expression_sql else this
393
394        if isinstance(parent, exp.EQ) and isinstance(parent.parent, exp.SetItem):
395            # We need to produce SET key = value instead of SET ${key} = value
396            return this
397
398        return f"${{{this}}}"
def schema_sql(self, expression: sqlglot.expressions.query.Schema) -> str:
400    def schema_sql(self, expression: exp.Schema) -> str:
401        for ordered in expression.find_all(exp.Ordered):
402            if ordered.args.get("desc") is False:
403                ordered.set("desc", None)
404
405        return super().schema_sql(expression)
def constraint_sql(self, expression: sqlglot.expressions.constraints.Constraint) -> str:
407    def constraint_sql(self, expression: exp.Constraint) -> str:
408        for prop in list(expression.find_all(exp.Properties)):
409            prop.pop()
410
411        this = self.sql(expression, "this")
412        expressions = self.expressions(expression, sep=" ", flat=True)
413        return f"CONSTRAINT {this} {expressions}"
def rowformatserdeproperty_sql( self, expression: sqlglot.expressions.properties.RowFormatSerdeProperty) -> str:
415    def rowformatserdeproperty_sql(self, expression: exp.RowFormatSerdeProperty) -> str:
416        serde_props = self.sql(expression, "serde_properties")
417        serde_props = f" {serde_props}" if serde_props else ""
418        return f"ROW FORMAT SERDE {self.sql(expression, 'this')}{serde_props}"
def arrayagg_sql(self, expression: sqlglot.expressions.aggregate.ArrayAgg) -> str:
420    def arrayagg_sql(self, expression: exp.ArrayAgg) -> str:
421        return self.func(
422            "COLLECT_LIST",
423            expression.this.this if isinstance(expression.this, exp.Order) else expression.this,
424        )
@unsupported_args('decimals')
def trunc_sql(self, expression: sqlglot.expressions.math.Trunc) -> str:
429    @unsupported_args("decimals")
430    def trunc_sql(self, expression: exp.Trunc) -> str:
431        return self.sql(exp.cast(expression.this, exp.DType.BIGINT))
def datatype_sql(self, expression: sqlglot.expressions.datatypes.DataType) -> str:
433    def datatype_sql(self, expression: exp.DataType) -> str:
434        if expression.this in self.PARAMETERIZABLE_TEXT_TYPES and (
435            not expression.expressions or expression.expressions[0].name == "MAX"
436        ):
437            expression = exp.DType.TEXT.into_expr()
438        elif expression.is_type(exp.DType.TEXT) and expression.expressions:
439            expression.set("this", exp.DType.VARCHAR)
440        elif expression.this in exp.DataType.TEMPORAL_TYPES:
441            expression = exp.DataType.build(expression.this)
442        elif expression.is_type("float"):
443            size_expression = expression.find(exp.DataTypeParam)
444            if size_expression:
445                size = int(size_expression.name)
446                builder = exp.DType.FLOAT if size <= 32 else exp.DType.DOUBLE
447                expression = builder.into_expr()
448        return super().datatype_sql(expression)
def version_sql(self, expression: sqlglot.expressions.query.Version) -> str:
450    def version_sql(self, expression: exp.Version) -> str:
451        sql = super().version_sql(expression)
452        return sql.replace("FOR ", "", 1)
def struct_sql(self, expression: sqlglot.expressions.array.Struct) -> str:
454    def struct_sql(self, expression: exp.Struct) -> str:
455        values = []
456
457        for i, e in enumerate(expression.expressions):
458            if isinstance(e, exp.PropertyEQ):
459                self.unsupported("Hive does not support named structs.")
460                values.append(e.expression)
461            else:
462                values.append(e)
463
464        return self.func("STRUCT", *values)
def columndef_sql( self, expression: sqlglot.expressions.query.ColumnDef, sep: str = ' ') -> str:
466    def columndef_sql(self, expression: exp.ColumnDef, sep: str = " ") -> str:
467        return super().columndef_sql(
468            expression,
469            sep=(
470                ": "
471                if isinstance(expression.parent, exp.DataType)
472                and expression.parent.is_type("struct")
473                else sep
474            ),
475        )
def altercolumn_sql(self, expression: sqlglot.expressions.ddl.AlterColumn) -> str:
477    def altercolumn_sql(self, expression: exp.AlterColumn) -> str:
478        this = self.sql(expression, "this")
479        new_name = self.sql(expression, "rename_to") or this
480        dtype = self.sql(expression, "dtype")
481        comment = (
482            f" COMMENT {self.sql(expression, 'comment')}" if self.sql(expression, "comment") else ""
483        )
484        default = self.sql(expression, "default")
485        visible = expression.args.get("visible")
486        allow_null = expression.args.get("allow_null")
487        drop = expression.args.get("drop")
488
489        if any([default, drop, visible, allow_null, drop]):
490            self.unsupported("Unsupported CHANGE COLUMN syntax")
491
492        if not dtype:
493            self.unsupported("CHANGE COLUMN without a type is not supported")
494
495        return f"CHANGE COLUMN {this} {new_name} {dtype}{comment}"
def renamecolumn_sql(self, expression: sqlglot.expressions.ddl.RenameColumn) -> str:
497    def renamecolumn_sql(self, expression: exp.RenameColumn) -> str:
498        self.unsupported("Cannot rename columns without data type defined in Hive")
499        return ""
def alterset_sql(self, expression: sqlglot.expressions.ddl.AlterSet) -> str:
501    def alterset_sql(self, expression: exp.AlterSet) -> str:
502        exprs = self.expressions(expression, flat=True)
503        exprs = f" {exprs}" if exprs else ""
504        location = self.sql(expression, "location")
505        location = f" LOCATION {location}" if location else ""
506        file_format = self.expressions(expression, key="file_format", flat=True, sep=" ")
507        file_format = f" FILEFORMAT {file_format}" if file_format else ""
508        serde = self.sql(expression, "serde")
509        serde = f" SERDE {serde}" if serde else ""
510        tags = self.expressions(expression, key="tag", flat=True, sep="")
511        tags = f" TAGS {tags}" if tags else ""
512
513        return f"SET{serde}{exprs}{location}{file_format}{tags}"
def serdeproperties_sql(self, expression: sqlglot.expressions.properties.SerdeProperties) -> str:
515    def serdeproperties_sql(self, expression: exp.SerdeProperties) -> str:
516        prefix = "WITH " if expression.args.get("with_") else ""
517        exprs = self.expressions(expression, flat=True)
518
519        return f"{prefix}SERDEPROPERTIES ({exprs})"
def exists_sql(self, expression: sqlglot.expressions.functions.Exists) -> str:
521    def exists_sql(self, expression: exp.Exists) -> str:
522        if expression.expression:
523            return self.function_fallback_sql(expression)
524
525        return super().exists_sql(expression)
def timetostr_sql(self, expression: sqlglot.expressions.temporal.TimeToStr) -> str:
527    def timetostr_sql(self, expression: exp.TimeToStr) -> str:
528        this = expression.this
529        if isinstance(this, exp.TimeStrToTime):
530            this = this.this
531
532        return self.func("DATE_FORMAT", this, self.format_time(expression))
def usingproperty_sql(self, expression: sqlglot.expressions.properties.UsingProperty) -> str:
534    def usingproperty_sql(self, expression: exp.UsingProperty) -> str:
535        kind = expression.args.get("kind")
536        return f"USING {kind} {self.sql(expression, 'this')}"
def fileformatproperty_sql( self, expression: sqlglot.expressions.properties.FileFormatProperty) -> str:
538    def fileformatproperty_sql(self, expression: exp.FileFormatProperty) -> str:
539        if isinstance(expression.this, exp.InputOutputFormat):
540            this = self.sql(expression, "this")
541        else:
542            this = expression.name.upper()
543
544        return f"STORED AS {this}"
Inherited Members
sqlglot.generator.Generator
Generator
NULL_ORDERING_SUPPORTED
WINDOW_FUNCS_WITH_NULL_ORDERING
IGNORE_NULLS_IN_FUNC
IGNORE_NULLS_BEFORE_ORDER
LOCKING_READS_SUPPORTED
EXCEPT_INTERSECT_SUPPORT_ALL_CLAUSE
WRAP_DERIVED_VALUES
CREATE_FUNCTION_RETURN_AS
MATCHED_BY_SOURCE
SUPPORTS_MERGE_WHERE
SINGLE_STRING_INTERVAL
INTERVAL_ALLOWS_PLURAL_FORM
LIMIT_ONLY_LITERALS
RENAME_TABLE_WITH_DB
GROUPINGS_SEP
INOUT_SEPARATOR
DIRECTED_JOINS
QUERY_HINT_SEP
IS_BOOL_ALLOWED
DUPLICATE_KEY_UPDATE_WITH_SET
LIMIT_IS_TOP
RETURNING_END
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_SIZE_IS_ROWS
TABLESAMPLE_KEYWORDS
TABLESAMPLE_SEED_KEYWORD
COLLATE_IS_FUNC
DATA_TYPE_SPECIFIERS_ALLOWED
ENSURE_BOOLS
CTE_RECURSIVE_KEYWORD_REQUIRED
SUPPORTS_SINGLE_ARG_CONCAT
SUPPORTS_TABLE_ALIAS_COLUMNS
UNPIVOT_ALIASES_ARE_IDENTIFIERS
JSON_KEY_VALUE_PAIR_SEP
INSERT_OVERWRITE
SUPPORTS_SELECT_INTO
SUPPORTS_UNLOGGED_TABLES
SUPPORTS_CREATE_TABLE_LIKE
LIKE_PROPERTY_INSIDE_SCHEMA
MULTI_ARG_DISTINCT
JSON_TYPE_REQUIRED_FOR_EXTRACTION
JSON_PATH_BRACKETED_KEY_SUPPORTED
CAN_IMPLEMENT_ARRAY_ANY
SUPPORTS_WINDOW_EXCLUDE
SET_OP_MODIFIERS
COPY_PARAMS_ARE_WRAPPED
COPY_PARAMS_EQ_REQUIRED
COPY_HAS_INTO_KEYWORD
UNICODE_SUBSTITUTE
STAR_EXCEPT
HEX_FUNC
QUOTE_JSON_PATH
SUPPORTS_EXPLODING_PROJECTIONS
ARRAY_CONCAT_IS_VAR_LEN
SUPPORTS_CONVERT_TIMEZONE
SUPPORTS_UNIX_SECONDS
ALTER_SET_WRAPPED
NORMALIZE_EXTRACT_DATE_PARTS
ARRAY_SIZE_DIM_REQUIRED
SUPPORTS_BETWEEN_FLAGS
SUPPORTS_LIKE_QUANTIFIERS
MATCH_AGAINST_TABLE_PREFIX
SET_ASSIGNMENT_REQUIRES_VARIABLE_KEYWORD
DECLARE_DEFAULT_ASSIGNMENT
UPDATE_STATEMENT_SUPPORTS_FROM
STAR_EXCLUDE_REQUIRES_DERIVED_TABLE
SUPPORTS_DROP_ALTER_ICEBERG_PROPERTY
UNSUPPORTED_TYPES
TIME_PART_SINGULARS
AFTER_HAVING_MODIFIER_TRANSFORMS
TOKEN_MAPPING
STRUCT_DELIMITER
PARAMETER_TOKEN
NAMED_PLACEHOLDER_TOKEN
EXPRESSION_PRECEDES_PROPERTIES_CREATABLES
RESERVED_KEYWORDS
WITH_SEPARATED_COMMENTS
EXCLUDE_COMMENTS
UNWRAPPED_INTERVAL_VALUES
PARAMETERIZABLE_TEXT_TYPES
RESPECT_IGNORE_NULLS_UNSUPPORTED_EXPRESSIONS
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
computedcolumnconstraint_sql
autoincrementcolumnconstraint_sql
compresscolumnconstraint_sql
generatedasidentitycolumnconstraint_sql
generatedasrowcolumnconstraint_sql
periodforsystemtimeconstraint_sql
notnullcolumnconstraint_sql
primarykeycolumnconstraint_sql
uniquecolumnconstraint_sql
inoutcolumnconstraint_sql
createable_sql
create_sql
sequenceproperties_sql
triggerproperties_sql
triggerreferencing_sql
triggerevent_sql
clone_sql
describe_sql
heredoc_sql
prepend_ctes
with_sql
cte_sql
tablealias_sql
bitstring_sql
hexstring_sql
bytestring_sql
unicodestring_sql
rawstring_sql
datatypeparam_sql
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
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
lateral_sql
limit_sql
offset_sql
setitem_sql
set_sql
queryband_sql
pragma_sql
lock_sql
literal_sql
escape_str
loaddata_sql
null_sql
boolean_sql
booland_sql
boolor_sql
order_sql
withfill_sql
cluster_sql
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_columns_sql
star_sql
sessionparameter_sql
placeholder_sql
subquery_sql
qualify_sql
prewhere_sql
where_sql
window_sql
partition_by_sql
windowspec_sql
withingroup_sql
between_sql
bracket_offset_expressions
bracket_sql
all_sql
any_sql
case_sql
nextvaluefor_sql
extract_sql
trim_sql
convert_concat_args
concat_sql
concatws_sql
check_sql
foreignkey_sql
primarykey_sql
if_sql
matchagainst_sql
jsonkeyvalue_sql
jsonpath_sql
json_path_part
formatjson_sql
formatphrase_sql
jsonarray_sql
jsonarrayagg_sql
jsoncolumndef_sql
jsonschema_sql
jsontable_sql
openjsoncolumndef_sql
openjson_sql
in_sql
in_unnest_op
interval_sql
return_sql
reference_sql
anonymous_sql
paren_sql
neg_sql
not_sql
alias_sql
pivotalias_sql
aliases_sql
atindex_sql
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
cast_sql
strtotime_sql
currentdate_sql
collate_sql
command_sql
comment_sql
mergetreettlaction_sql
mergetreettl_sql
transaction_sql
commit_sql
rollback_sql
alterindex_sql
alterdiststyle_sql
altersortkey_sql
alterrename_sql
alter_sql
altersession_sql
add_column_sql
droppartition_sql
addconstraint_sql
addpartition_sql
distinct_sql
respectnulls_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
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
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
renameindex_sql