Edit on GitHub

sqlglot.generators.fabric

  1from __future__ import annotations
  2
  3from sqlglot import exp, transforms
  4from sqlglot.generators.tsql import TSQLGenerator
  5
  6
  7def _cap_data_type_precision(expression: exp.DataType, max_precision: int = 6) -> exp.DataType:
  8    """
  9    Cap the precision of to a maximum of `max_precision` digits.
 10    If no precision is specified, default to `max_precision`.
 11    """
 12
 13    precision_param = expression.find(exp.DataTypeParam)
 14
 15    if precision_param and precision_param.this.is_int:
 16        current_precision = precision_param.this.to_py()
 17        target_precision = min(current_precision, max_precision)
 18    else:
 19        target_precision = max_precision
 20
 21    return exp.DataType(
 22        this=expression.this,
 23        expressions=[exp.DataTypeParam(this=exp.Literal.number(target_precision))],
 24    )
 25
 26
 27def _add_default_precision_to_varchar(expression: exp.Expr) -> exp.Expr:
 28    """Transform function to add VARCHAR(MAX) or CHAR(MAX) for cross-dialect conversion."""
 29    if (
 30        isinstance(expression, exp.Create)
 31        and expression.kind == "TABLE"
 32        and isinstance(expression.this, exp.Schema)
 33    ):
 34        for column in expression.this.expressions:
 35            if isinstance(column, exp.ColumnDef):
 36                column_type = column.kind
 37                if (
 38                    isinstance(column_type, exp.DataType)
 39                    and column_type.this in (exp.DType.VARCHAR, exp.DType.CHAR)
 40                    and not column_type.expressions
 41                ):
 42                    # For transpilation, VARCHAR/CHAR without precision becomes VARCHAR(MAX)/CHAR(MAX)
 43                    column_type.set("expressions", [exp.var("MAX")])
 44
 45    return expression
 46
 47
 48class FabricGenerator(TSQLGenerator):
 49    # Fabric-specific type mappings - override T-SQL types that aren't supported
 50    # Reference: https://learn.microsoft.com/en-us/fabric/data-warehouse/data-types
 51    TYPE_MAPPING = {
 52        **TSQLGenerator.TYPE_MAPPING,
 53        exp.DType.DATETIME: "DATETIME2",
 54        exp.DType.DECIMAL: "DECIMAL",
 55        exp.DType.IMAGE: "VARBINARY",
 56        exp.DType.INT: "INT",
 57        exp.DType.JSON: "VARCHAR",
 58        exp.DType.MONEY: "DECIMAL",
 59        exp.DType.NCHAR: "CHAR",
 60        exp.DType.NVARCHAR: "VARCHAR",
 61        exp.DType.ROWVERSION: "ROWVERSION",
 62        exp.DType.SMALLDATETIME: "DATETIME2",
 63        exp.DType.SMALLMONEY: "DECIMAL",
 64        exp.DType.TIMESTAMP: "DATETIME2",
 65        exp.DType.TIMESTAMPNTZ: "DATETIME2",
 66        exp.DType.TIMESTAMPTZ: "DATETIME2",
 67        exp.DType.TINYINT: "SMALLINT",
 68        exp.DType.UTINYINT: "SMALLINT",
 69        exp.DType.UUID: "UNIQUEIDENTIFIER",
 70        exp.DType.XML: "VARCHAR",
 71    }
 72
 73    TRANSFORMS = {
 74        **TSQLGenerator.TRANSFORMS,
 75        exp.Create: transforms.preprocess([_add_default_precision_to_varchar]),
 76    }
 77
 78    def datatype_sql(self, expression: exp.DataType) -> str:
 79        # Check if this is a temporal type that needs precision handling. Fabric limits temporal
 80        # types to max 6 digits precision. When no precision is specified, we default to 6 digits.
 81        if expression.is_type(*exp.DataType.TEMPORAL_TYPES) and expression.this != exp.DType.DATE:
 82            # Create a new expression with the capped precision
 83            expression = _cap_data_type_precision(expression)
 84
 85        return super().datatype_sql(expression)
 86
 87    def cast_sql(self, expression: exp.Cast, safe_prefix: str | None = None) -> str:
 88        # Cast to DATETIMEOFFSET if inside an AT TIME ZONE expression
 89        # https://learn.microsoft.com/en-us/sql/t-sql/data-types/datetimeoffset-transact-sql#microsoft-fabric-support
 90        if expression.is_type(exp.DType.TIMESTAMPTZ):
 91            at_time_zone = expression.find_ancestor(exp.AtTimeZone, exp.Select)
 92
 93            # Return normal cast, if the expression is not in an AT TIME ZONE context
 94            if not isinstance(at_time_zone, exp.AtTimeZone):
 95                return super().cast_sql(expression, safe_prefix)
 96
 97            # Get the precision from the original TIMESTAMPTZ cast and cap it to 6
 98            capped_data_type = _cap_data_type_precision(expression.to, max_precision=6)
 99            precision = capped_data_type.find(exp.DataTypeParam)
100            precision_value = precision.this.to_py() if precision and precision.this.is_int else 6
101
102            # Do the cast explicitly to bypass sqlglot's default handling
103            datetimeoffset = f"CAST({expression.this} AS DATETIMEOFFSET({precision_value}))"
104
105            return self.sql(datetimeoffset)
106
107        return super().cast_sql(expression, safe_prefix)
108
109    def attimezone_sql(self, expression: exp.AtTimeZone) -> str:
110        # Wrap the AT TIME ZONE expression in a cast to DATETIME2 if it contains a TIMESTAMPTZ
111        ## https://learn.microsoft.com/en-us/sql/t-sql/data-types/datetimeoffset-transact-sql#microsoft-fabric-support
112        timestamptz_cast = expression.find(exp.Cast)
113        if timestamptz_cast and timestamptz_cast.to.is_type(exp.DType.TIMESTAMPTZ):
114            # Get the precision from the original TIMESTAMPTZ cast and cap it to 6
115            data_type = timestamptz_cast.to
116            capped_data_type = _cap_data_type_precision(data_type, max_precision=6)
117            precision_param = capped_data_type.find(exp.DataTypeParam)
118            precision = precision_param.this.to_py() if precision_param else 6
119
120            # Generate the AT TIME ZONE expression (which will handle the inner cast conversion)
121            at_time_zone_sql = super().attimezone_sql(expression)
122
123            # Wrap it in an outer cast to DATETIME2
124            return f"CAST({at_time_zone_sql} AS DATETIME2({precision}))"
125
126        return super().attimezone_sql(expression)
127
128    def unixtotime_sql(self, expression: exp.UnixToTime) -> str:
129        scale = expression.args.get("scale")
130        timestamp = expression.this
131
132        if scale not in (None, exp.UnixToTime.SECONDS):
133            self.unsupported(f"UnixToTime scale {scale} is not supported by Fabric")
134            return ""
135
136        # Convert unix timestamp (seconds) to microseconds and round to avoid decimals
137        microseconds = timestamp * exp.Literal.number("1e6")
138        rounded = exp.func("round", microseconds, 0)
139        rounded_ms_as_bigint = exp.cast(rounded, exp.DType.BIGINT)
140
141        # Create the base datetime as '1970-01-01' cast to DATETIME2(6)
142        epoch_start = exp.cast("'1970-01-01'", "datetime2(6)", dialect="fabric")
143
144        dateadd = exp.DateAdd(
145            this=epoch_start,
146            expression=rounded_ms_as_bigint,
147            unit=exp.Literal.string("MICROSECONDS"),
148        )
149        return self.sql(dateadd)
class FabricGenerator(sqlglot.generators.tsql.TSQLGenerator):
 49class FabricGenerator(TSQLGenerator):
 50    # Fabric-specific type mappings - override T-SQL types that aren't supported
 51    # Reference: https://learn.microsoft.com/en-us/fabric/data-warehouse/data-types
 52    TYPE_MAPPING = {
 53        **TSQLGenerator.TYPE_MAPPING,
 54        exp.DType.DATETIME: "DATETIME2",
 55        exp.DType.DECIMAL: "DECIMAL",
 56        exp.DType.IMAGE: "VARBINARY",
 57        exp.DType.INT: "INT",
 58        exp.DType.JSON: "VARCHAR",
 59        exp.DType.MONEY: "DECIMAL",
 60        exp.DType.NCHAR: "CHAR",
 61        exp.DType.NVARCHAR: "VARCHAR",
 62        exp.DType.ROWVERSION: "ROWVERSION",
 63        exp.DType.SMALLDATETIME: "DATETIME2",
 64        exp.DType.SMALLMONEY: "DECIMAL",
 65        exp.DType.TIMESTAMP: "DATETIME2",
 66        exp.DType.TIMESTAMPNTZ: "DATETIME2",
 67        exp.DType.TIMESTAMPTZ: "DATETIME2",
 68        exp.DType.TINYINT: "SMALLINT",
 69        exp.DType.UTINYINT: "SMALLINT",
 70        exp.DType.UUID: "UNIQUEIDENTIFIER",
 71        exp.DType.XML: "VARCHAR",
 72    }
 73
 74    TRANSFORMS = {
 75        **TSQLGenerator.TRANSFORMS,
 76        exp.Create: transforms.preprocess([_add_default_precision_to_varchar]),
 77    }
 78
 79    def datatype_sql(self, expression: exp.DataType) -> str:
 80        # Check if this is a temporal type that needs precision handling. Fabric limits temporal
 81        # types to max 6 digits precision. When no precision is specified, we default to 6 digits.
 82        if expression.is_type(*exp.DataType.TEMPORAL_TYPES) and expression.this != exp.DType.DATE:
 83            # Create a new expression with the capped precision
 84            expression = _cap_data_type_precision(expression)
 85
 86        return super().datatype_sql(expression)
 87
 88    def cast_sql(self, expression: exp.Cast, safe_prefix: str | None = None) -> str:
 89        # Cast to DATETIMEOFFSET if inside an AT TIME ZONE expression
 90        # https://learn.microsoft.com/en-us/sql/t-sql/data-types/datetimeoffset-transact-sql#microsoft-fabric-support
 91        if expression.is_type(exp.DType.TIMESTAMPTZ):
 92            at_time_zone = expression.find_ancestor(exp.AtTimeZone, exp.Select)
 93
 94            # Return normal cast, if the expression is not in an AT TIME ZONE context
 95            if not isinstance(at_time_zone, exp.AtTimeZone):
 96                return super().cast_sql(expression, safe_prefix)
 97
 98            # Get the precision from the original TIMESTAMPTZ cast and cap it to 6
 99            capped_data_type = _cap_data_type_precision(expression.to, max_precision=6)
100            precision = capped_data_type.find(exp.DataTypeParam)
101            precision_value = precision.this.to_py() if precision and precision.this.is_int else 6
102
103            # Do the cast explicitly to bypass sqlglot's default handling
104            datetimeoffset = f"CAST({expression.this} AS DATETIMEOFFSET({precision_value}))"
105
106            return self.sql(datetimeoffset)
107
108        return super().cast_sql(expression, safe_prefix)
109
110    def attimezone_sql(self, expression: exp.AtTimeZone) -> str:
111        # Wrap the AT TIME ZONE expression in a cast to DATETIME2 if it contains a TIMESTAMPTZ
112        ## https://learn.microsoft.com/en-us/sql/t-sql/data-types/datetimeoffset-transact-sql#microsoft-fabric-support
113        timestamptz_cast = expression.find(exp.Cast)
114        if timestamptz_cast and timestamptz_cast.to.is_type(exp.DType.TIMESTAMPTZ):
115            # Get the precision from the original TIMESTAMPTZ cast and cap it to 6
116            data_type = timestamptz_cast.to
117            capped_data_type = _cap_data_type_precision(data_type, max_precision=6)
118            precision_param = capped_data_type.find(exp.DataTypeParam)
119            precision = precision_param.this.to_py() if precision_param else 6
120
121            # Generate the AT TIME ZONE expression (which will handle the inner cast conversion)
122            at_time_zone_sql = super().attimezone_sql(expression)
123
124            # Wrap it in an outer cast to DATETIME2
125            return f"CAST({at_time_zone_sql} AS DATETIME2({precision}))"
126
127        return super().attimezone_sql(expression)
128
129    def unixtotime_sql(self, expression: exp.UnixToTime) -> str:
130        scale = expression.args.get("scale")
131        timestamp = expression.this
132
133        if scale not in (None, exp.UnixToTime.SECONDS):
134            self.unsupported(f"UnixToTime scale {scale} is not supported by Fabric")
135            return ""
136
137        # Convert unix timestamp (seconds) to microseconds and round to avoid decimals
138        microseconds = timestamp * exp.Literal.number("1e6")
139        rounded = exp.func("round", microseconds, 0)
140        rounded_ms_as_bigint = exp.cast(rounded, exp.DType.BIGINT)
141
142        # Create the base datetime as '1970-01-01' cast to DATETIME2(6)
143        epoch_start = exp.cast("'1970-01-01'", "datetime2(6)", dialect="fabric")
144
145        dateadd = exp.DateAdd(
146            this=epoch_start,
147            expression=rounded_ms_as_bigint,
148            unit=exp.Literal.string("MICROSECONDS"),
149        )
150        return self.sql(dateadd)

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
TYPE_MAPPING = {<DType.DATETIME2: 'DATETIME2'>: 'DATETIME2', <DType.MEDIUMTEXT: 'MEDIUMTEXT'>: 'TEXT', <DType.LONGTEXT: 'LONGTEXT'>: 'TEXT', <DType.TINYTEXT: 'TINYTEXT'>: 'TEXT', <DType.BLOB: 'BLOB'>: 'VARBINARY', <DType.MEDIUMBLOB: 'MEDIUMBLOB'>: 'BLOB', <DType.LONGBLOB: 'LONGBLOB'>: 'BLOB', <DType.TINYBLOB: 'TINYBLOB'>: 'BLOB', <DType.INET: 'INET'>: 'INET', <DType.ROWVERSION: 'ROWVERSION'>: 'ROWVERSION', <DType.SMALLDATETIME: 'SMALLDATETIME'>: 'DATETIME2', <DType.BOOLEAN: 'BOOLEAN'>: 'BIT', <DType.DECIMAL: 'DECIMAL'>: 'DECIMAL', <DType.DOUBLE: 'DOUBLE'>: 'FLOAT', <DType.INT: 'INT'>: 'INT', <DType.TEXT: 'TEXT'>: 'VARCHAR(MAX)', <DType.TIMESTAMP: 'TIMESTAMP'>: 'DATETIME2', <DType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>: 'DATETIME2', <DType.TIMESTAMPTZ: 'TIMESTAMPTZ'>: 'DATETIME2', <DType.UTINYINT: 'UTINYINT'>: 'SMALLINT', <DType.VARIANT: 'VARIANT'>: 'SQL_VARIANT', <DType.UUID: 'UUID'>: 'UNIQUEIDENTIFIER', <DType.DATETIME: 'DATETIME'>: 'DATETIME2', <DType.IMAGE: 'IMAGE'>: 'VARBINARY', <DType.JSON: 'JSON'>: 'VARCHAR', <DType.MONEY: 'MONEY'>: 'DECIMAL', <DType.NCHAR: 'NCHAR'>: 'CHAR', <DType.NVARCHAR: 'NVARCHAR'>: 'VARCHAR', <DType.SMALLMONEY: 'SMALLMONEY'>: 'DECIMAL', <DType.TINYINT: 'TINYINT'>: 'SMALLINT', <DType.XML: 'XML'>: 'VARCHAR'}
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.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 rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.constraints.CharacterSetColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.CharacterSetProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.ClusteredColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.CollateColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.CommentColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.functions.ConnectByRoot'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.string.ConvertToCharset'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.CopyGrantsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.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 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.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 TSQLGenerator.<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 any_value_to_max_sql>, <class 'sqlglot.expressions.math.Atan2'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.array.ArrayToString'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.constraints.AutoIncrementColumnConstraint'>: <function TSQLGenerator.<lambda>>, <class 'sqlglot.expressions.string.Chr'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.DateAdd'>: <function date_delta_sql.<locals>._delta_sql>, <class 'sqlglot.expressions.query.CTE'>: <function preprocess.<locals>._to_sql>, <class 'sqlglot.expressions.temporal.CurrentDate'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.CurrentTimestamp'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.CurrentTimestampLTZ'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.DateStrToDate'>: <function datestrtodate_sql>, <class 'sqlglot.expressions.constraints.GeneratedAsIdentityColumnConstraint'>: <function generatedasidentitycolumnconstraint_sql>, <class 'sqlglot.expressions.aggregate.GroupConcat'>: <function _string_agg_sql>, <class 'sqlglot.expressions.functions.If'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.json.JSONExtract'>: <function _json_extract_sql>, <class 'sqlglot.expressions.json.JSONExtractScalar'>: <function _json_extract_sql>, <class 'sqlglot.expressions.temporal.LastDay'>: <function TSQLGenerator.<lambda>>, <class 'sqlglot.expressions.math.Ln'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.aggregate.Max'>: <function max_or_greatest>, <class 'sqlglot.expressions.string.MD5'>: <function TSQLGenerator.<lambda>>, <class 'sqlglot.expressions.aggregate.Min'>: <function min_or_least>, <class 'sqlglot.expressions.string.NumberToStr'>: <function _format_sql>, <class 'sqlglot.expressions.string.Repeat'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.functions.CurrentSchema'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.query.Select'>: <function preprocess.<locals>._to_sql>, <class 'sqlglot.expressions.aggregate.Stddev'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.string.StrPosition'>: <function TSQLGenerator.<lambda>>, <class 'sqlglot.expressions.query.Subquery'>: <function preprocess.<locals>._to_sql>, <class 'sqlglot.expressions.string.SHA'>: <function TSQLGenerator.<lambda>>, <class 'sqlglot.expressions.string.SHA1Digest'>: <function TSQLGenerator.<lambda>>, <class 'sqlglot.expressions.string.SHA2'>: <function TSQLGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.TimeStrToTime'>: <function _timestrtotime_sql>, <class 'sqlglot.expressions.temporal.TimeToStr'>: <function _format_sql>, <class 'sqlglot.expressions.string.Trim'>: <function trim_sql>, <class 'sqlglot.expressions.temporal.TsOrDsAdd'>: <function date_delta_sql.<locals>._delta_sql>, <class 'sqlglot.expressions.temporal.TsOrDsDiff'>: <function date_delta_sql.<locals>._delta_sql>, <class 'sqlglot.expressions.temporal.TimestampTrunc'>: <function TSQLGenerator.<lambda>>, <class 'sqlglot.expressions.math.Trunc'>: <function TSQLGenerator.<lambda>>, <class 'sqlglot.expressions.functions.Uuid'>: <function TSQLGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.DateFromParts'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.ddl.Create'>: <function preprocess.<locals>._to_sql>}
def datatype_sql(self, expression: sqlglot.expressions.datatypes.DataType) -> str:
79    def datatype_sql(self, expression: exp.DataType) -> str:
80        # Check if this is a temporal type that needs precision handling. Fabric limits temporal
81        # types to max 6 digits precision. When no precision is specified, we default to 6 digits.
82        if expression.is_type(*exp.DataType.TEMPORAL_TYPES) and expression.this != exp.DType.DATE:
83            # Create a new expression with the capped precision
84            expression = _cap_data_type_precision(expression)
85
86        return super().datatype_sql(expression)
def cast_sql( self, expression: sqlglot.expressions.functions.Cast, safe_prefix: str | None = None) -> str:
 88    def cast_sql(self, expression: exp.Cast, safe_prefix: str | None = None) -> str:
 89        # Cast to DATETIMEOFFSET if inside an AT TIME ZONE expression
 90        # https://learn.microsoft.com/en-us/sql/t-sql/data-types/datetimeoffset-transact-sql#microsoft-fabric-support
 91        if expression.is_type(exp.DType.TIMESTAMPTZ):
 92            at_time_zone = expression.find_ancestor(exp.AtTimeZone, exp.Select)
 93
 94            # Return normal cast, if the expression is not in an AT TIME ZONE context
 95            if not isinstance(at_time_zone, exp.AtTimeZone):
 96                return super().cast_sql(expression, safe_prefix)
 97
 98            # Get the precision from the original TIMESTAMPTZ cast and cap it to 6
 99            capped_data_type = _cap_data_type_precision(expression.to, max_precision=6)
100            precision = capped_data_type.find(exp.DataTypeParam)
101            precision_value = precision.this.to_py() if precision and precision.this.is_int else 6
102
103            # Do the cast explicitly to bypass sqlglot's default handling
104            datetimeoffset = f"CAST({expression.this} AS DATETIMEOFFSET({precision_value}))"
105
106            return self.sql(datetimeoffset)
107
108        return super().cast_sql(expression, safe_prefix)
def attimezone_sql(self, expression: sqlglot.expressions.core.AtTimeZone) -> str:
110    def attimezone_sql(self, expression: exp.AtTimeZone) -> str:
111        # Wrap the AT TIME ZONE expression in a cast to DATETIME2 if it contains a TIMESTAMPTZ
112        ## https://learn.microsoft.com/en-us/sql/t-sql/data-types/datetimeoffset-transact-sql#microsoft-fabric-support
113        timestamptz_cast = expression.find(exp.Cast)
114        if timestamptz_cast and timestamptz_cast.to.is_type(exp.DType.TIMESTAMPTZ):
115            # Get the precision from the original TIMESTAMPTZ cast and cap it to 6
116            data_type = timestamptz_cast.to
117            capped_data_type = _cap_data_type_precision(data_type, max_precision=6)
118            precision_param = capped_data_type.find(exp.DataTypeParam)
119            precision = precision_param.this.to_py() if precision_param else 6
120
121            # Generate the AT TIME ZONE expression (which will handle the inner cast conversion)
122            at_time_zone_sql = super().attimezone_sql(expression)
123
124            # Wrap it in an outer cast to DATETIME2
125            return f"CAST({at_time_zone_sql} AS DATETIME2({precision}))"
126
127        return super().attimezone_sql(expression)
def unixtotime_sql(self, expression: sqlglot.expressions.temporal.UnixToTime) -> str:
129    def unixtotime_sql(self, expression: exp.UnixToTime) -> str:
130        scale = expression.args.get("scale")
131        timestamp = expression.this
132
133        if scale not in (None, exp.UnixToTime.SECONDS):
134            self.unsupported(f"UnixToTime scale {scale} is not supported by Fabric")
135            return ""
136
137        # Convert unix timestamp (seconds) to microseconds and round to avoid decimals
138        microseconds = timestamp * exp.Literal.number("1e6")
139        rounded = exp.func("round", microseconds, 0)
140        rounded_ms_as_bigint = exp.cast(rounded, exp.DType.BIGINT)
141
142        # Create the base datetime as '1970-01-01' cast to DATETIME2(6)
143        epoch_start = exp.cast("'1970-01-01'", "datetime2(6)", dialect="fabric")
144
145        dateadd = exp.DateAdd(
146            this=epoch_start,
147            expression=rounded_ms_as_bigint,
148            unit=exp.Literal.string("MICROSECONDS"),
149        )
150        return self.sql(dateadd)
Inherited Members
sqlglot.generator.Generator
Generator
WINDOW_FUNCS_WITH_NULL_ORDERING
IGNORE_NULLS_IN_FUNC
IGNORE_NULLS_BEFORE_ORDER
LOCKING_READS_SUPPORTED
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
INDEX_ON
INOUT_SEPARATOR
JOIN_HINTS
DIRECTED_JOINS
TABLE_HINTS
QUERY_HINT_SEP
IS_BOOL_ALLOWED
DUPLICATE_KEY_UPDATE_WITH_SET
EXTRACT_ALLOWS_QUOTES
TZ_TO_WITH_TIME_ZONE
VALUES_AS_TABLE
UNNEST_WITH_ORDINALITY
AGGREGATE_FILTER_SUPPORTED
SEMI_ANTI_JOIN_WITH_SIDE
SUPPORTS_TABLE_COPY
TABLESAMPLE_REQUIRES_PARENS
TABLESAMPLE_SIZE_IS_ROWS
TABLESAMPLE_KEYWORDS
TABLESAMPLE_WITH_METHOD
COLLATE_IS_FUNC
DATA_TYPE_SPECIFIERS_ALLOWED
LAST_DAY_SUPPORTS_DATE_PART
SUPPORTS_TABLE_ALIAS_COLUMNS
UNPIVOT_ALIASES_ARE_IDENTIFIERS
JSON_KEY_VALUE_PAIR_SEP
INSERT_OVERWRITE
SUPPORTS_UNLOGGED_TABLES
SUPPORTS_CREATE_TABLE_LIKE
LIKE_PROPERTY_INSIDE_SCHEMA
MULTI_ARG_DISTINCT
JSON_TYPE_REQUIRED_FOR_EXTRACTION
JSON_PATH_SINGLE_QUOTE_ESCAPE
CAN_IMPLEMENT_ARRAY_ANY
SUPPORTS_WINDOW_EXCLUDE
COPY_PARAMS_ARE_WRAPPED
COPY_HAS_INTO_KEYWORD
UNICODE_SUBSTITUTE
STAR_EXCEPT
HEX_FUNC
WITH_PROPERTIES_PREFIX
QUOTE_JSON_PATH
PAD_FILL_PATTERN_IS_REQUIRED
SUPPORTS_EXPLODING_PROJECTIONS
ARRAY_CONCAT_IS_VAR_LEN
SUPPORTS_CONVERT_TIMEZONE
SUPPORTS_MEDIAN
SUPPORTS_UNIX_SECONDS
NORMALIZE_EXTRACT_DATE_PARTS
ARRAY_SIZE_NAME
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
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
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
computedcolumnconstraint_sql
autoincrementcolumnconstraint_sql
compresscolumnconstraint_sql
generatedasidentitycolumnconstraint_sql
generatedasrowcolumnconstraint_sql
periodforsystemtimeconstraint_sql
notnullcolumnconstraint_sql
primarykeycolumnconstraint_sql
uniquecolumnconstraint_sql
inoutcolumnconstraint_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
set_operation
set_operations
fetch_sql
limitoptions_sql
filter_sql
hint_sql
indexparameters_sql
index_sql
hex_sql
lowerhex_sql
inputoutputformat_sql
national_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
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
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_sql
limit_sql
set_sql
queryband_sql
pragma_sql
lock_sql
literal_sql
escape_str
loaddata_sql
null_sql
booland_sql
boolor_sql
order_sql
withfill_sql
cluster_sql
distribute_sql
sort_sql
ordered_sql
matchrecognizemeasure_sql
matchrecognize_sql
query_modifiers
for_modifiers
offset_limit_modifiers
after_limit_modifiers
schema_sql
schema_columns_sql
star_sql
parameter_sql
sessionparameter_sql
placeholder_sql
subquery_sql
qualify_sql
unnest_sql
prewhere_sql
where_sql
window_sql
partition_by_sql
windowspec_sql
withingroup_sql
between_sql
bracket_offset_expressions
bracket_sql
all_sql
any_sql
exists_sql
case_sql
nextvaluefor_sql
trim_sql
convert_concat_args
concat_sql
concatws_sql
check_sql
foreignkey_sql
primarykey_sql
if_sql
matchagainst_sql
jsonkeyvalue_sql
jsonpath_sql
json_path_part
formatjson_sql
formatphrase_sql
jsonarray_sql
jsonarrayagg_sql
jsoncolumndef_sql
jsonschema_sql
jsontable_sql
openjsoncolumndef_sql
openjson_sql
in_sql
in_unnest_op
interval_sql
return_sql
reference_sql
anonymous_sql
paren_sql
neg_sql
not_sql
alias_sql
pivotalias_sql
aliases_sql
atindex_sql
fromtimezone_sql
add_sql
and_sql
or_sql
xor_sql
connector_sql
bitwiseand_sql
bitwiseleftshift_sql
bitwisenot_sql
bitwiseor_sql
bitwiserightshift_sql
bitwisexor_sql
strtotime_sql
currentdate_sql
collate_sql
command_sql
comment_sql
mergetreettlaction_sql
mergetreettl_sql
altercolumn_sql
alterindex_sql
alterdiststyle_sql
altersortkey_sql
alterrename_sql
renamecolumn_sql
alterset_sql
altersession_sql
add_column_sql
droppartition_sql
addconstraint_sql
addpartition_sql
distinct_sql
ignorenulls_sql
respectnulls_sql
havingmax_sql
intdiv_sql
div_sql
safedivide_sql
overlaps_sql
distance_sql
dot_sql
eq_sql
propertyeq_sql
escape_sql
glob_sql
gt_sql
gte_sql
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
copyparameter_sql
credentials_sql
copy_sql
semicolon_sql
datadeletionproperty_sql
maskingpolicycolumnconstraint_sql
gapfill_sql
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
altermodifysqlsecurity_sql
usingproperty_sql
renameindex_sql
sqlglot.generators.tsql.TSQLGenerator
SELECT_KINDS
TRY_SUPPORTED
SUPPORTS_UESCAPE
SUPPORTS_DECODE_CASE
AFTER_HAVING_MODIFIER_TRANSFORMS
LIMIT_IS_TOP
QUERY_HINTS
RETURNING_END
NVL2_SUPPORTED
ALTER_TABLE_INCLUDE_COLUMN_KEYWORD
LIMIT_FETCH
COMPUTED_COLUMN_WITH_TYPE
CTE_RECURSIVE_KEYWORD_REQUIRED
ENSURE_BOOLS
NULL_ORDERING_SUPPORTED
SUPPORTS_SINGLE_ARG_CONCAT
TABLESAMPLE_SEED_KEYWORD
SUPPORTS_SELECT_INTO
JSON_PATH_BRACKETED_KEY_SUPPORTED
SUPPORTS_TO_NUMBER
SET_OP_MODIFIERS
COPY_PARAMS_EQ_REQUIRED
PARSE_JSON_NAME
EXCEPT_INTERSECT_SUPPORT_ALL_CLAUSE
ALTER_SET_WRAPPED
ALTER_SET_TYPE
EXPRESSIONS_WITHOUT_NESTED_CTES
SUPPORTED_JSON_PATH_PARTS
PROPERTIES_LOCATION
scope_resolution
select_sql
convert_sql
queryoption_sql
lateral_op
splitpart_sql
extract_sql
timefromparts_sql
timestampfromparts_sql
setitem_sql
boolean_sql
is_sql
createable_sql
create_sql
into_sql
count_sql
datediff_sql
offset_sql
version_sql
returnsproperty_sql
returning_sql
transaction_sql
commit_sql
rollback_sql
identifier_sql
constraint_sql
length_sql
right_sql
left_sql
partition_sql
alter_sql
drop_sql
options_modifier
dpipe_sql
isascii_sql
columndef_sql
coalesce_sql
storedprocedure_sql
ifblock_sql
whileblock_sql
execute_sql
executesql_sql