Edit on GitHub

sqlglot.dialects.redshift

  1from __future__ import annotations
  2
  3import typing as t
  4
  5from sqlglot import exp, transforms
  6from sqlglot.dialects.postgres import Postgres
  7from sqlglot.helper import seq_get
  8from sqlglot.tokens import TokenType
  9
 10
 11class Redshift(Postgres):
 12    time_format = "'YYYY-MM-DD HH:MI:SS'"
 13    time_mapping = {
 14        **Postgres.time_mapping,  # type: ignore
 15        "MON": "%b",
 16        "HH": "%H",
 17    }
 18
 19    class Parser(Postgres.Parser):
 20        FUNCTIONS = {
 21            **Postgres.Parser.FUNCTIONS,  # type: ignore
 22            "DATEADD": lambda args: exp.DateAdd(
 23                this=seq_get(args, 2),
 24                expression=seq_get(args, 1),
 25                unit=seq_get(args, 0),
 26            ),
 27            "DATEDIFF": lambda args: exp.DateDiff(
 28                this=seq_get(args, 2),
 29                expression=seq_get(args, 1),
 30                unit=seq_get(args, 0),
 31            ),
 32            "NVL": exp.Coalesce.from_arg_list,
 33        }
 34
 35        CONVERT_TYPE_FIRST = True
 36
 37        def _parse_types(self, check_func: bool = False) -> t.Optional[exp.Expression]:
 38            this = super()._parse_types(check_func=check_func)
 39
 40            if (
 41                isinstance(this, exp.DataType)
 42                and this.this == exp.DataType.Type.VARCHAR
 43                and this.expressions
 44                and this.expressions[0] == exp.column("MAX")
 45            ):
 46                this.set("expressions", [exp.Var(this="MAX")])
 47
 48            return this
 49
 50    class Tokenizer(Postgres.Tokenizer):
 51        STRING_ESCAPES = ["\\"]
 52
 53        KEYWORDS = {
 54            **Postgres.Tokenizer.KEYWORDS,  # type: ignore
 55            "GEOMETRY": TokenType.GEOMETRY,
 56            "GEOGRAPHY": TokenType.GEOGRAPHY,
 57            "HLLSKETCH": TokenType.HLLSKETCH,
 58            "SUPER": TokenType.SUPER,
 59            "TIME": TokenType.TIMESTAMP,
 60            "TIMETZ": TokenType.TIMESTAMPTZ,
 61            "TOP": TokenType.TOP,
 62            "UNLOAD": TokenType.COMMAND,
 63            "VARBYTE": TokenType.VARBINARY,
 64        }
 65
 66    class Generator(Postgres.Generator):
 67        TYPE_MAPPING = {
 68            **Postgres.Generator.TYPE_MAPPING,  # type: ignore
 69            exp.DataType.Type.BINARY: "VARBYTE",
 70            exp.DataType.Type.VARBINARY: "VARBYTE",
 71            exp.DataType.Type.INT: "INTEGER",
 72        }
 73
 74        PROPERTIES_LOCATION = {
 75            **Postgres.Generator.PROPERTIES_LOCATION,  # type: ignore
 76            exp.LikeProperty: exp.Properties.Location.POST_WITH,
 77        }
 78
 79        TRANSFORMS = {
 80            **Postgres.Generator.TRANSFORMS,  # type: ignore
 81            **transforms.ELIMINATE_DISTINCT_ON,  # type: ignore
 82            exp.DateAdd: lambda self, e: self.func(
 83                "DATEADD", exp.var(e.text("unit") or "day"), e.expression, e.this
 84            ),
 85            exp.DateDiff: lambda self, e: self.func(
 86                "DATEDIFF", exp.var(e.text("unit") or "day"), e.expression, e.this
 87            ),
 88            exp.DistKeyProperty: lambda self, e: f"DISTKEY({e.name})",
 89            exp.DistStyleProperty: lambda self, e: self.naked_property(e),
 90            exp.SortKeyProperty: lambda self, e: f"{'COMPOUND ' if e.args['compound'] else ''}SORTKEY({self.format_args(*e.this)})",
 91        }
 92
 93        # Redshift uses the POW | POWER (expr1, expr2) syntax instead of expr1 ^ expr2 (postgres)
 94        TRANSFORMS.pop(exp.Pow)
 95
 96        def values_sql(self, expression: exp.Values) -> str:
 97            """
 98            Converts `VALUES...` expression into a series of unions.
 99
100            Note: If you have a lot of unions then this will result in a large number of recursive statements to
101            evaluate the expression. You may need to increase `sys.setrecursionlimit` to run and it can also be
102            very slow.
103            """
104            if not isinstance(expression.unnest().parent, exp.From):
105                return super().values_sql(expression)
106            rows = [tuple_exp.expressions for tuple_exp in expression.expressions]
107            selects = []
108            for i, row in enumerate(rows):
109                if i == 0 and expression.alias:
110                    row = [
111                        exp.alias_(value, column_name)
112                        for value, column_name in zip(row, expression.args["alias"].args["columns"])
113                    ]
114                selects.append(exp.Select(expressions=row))
115            subquery_expression = selects[0]
116            if len(selects) > 1:
117                for select in selects[1:]:
118                    subquery_expression = exp.union(subquery_expression, select, distinct=False)
119            return self.subquery_sql(subquery_expression.subquery(expression.alias))
120
121        def with_properties(self, properties: exp.Properties) -> str:
122            """Redshift doesn't have `WITH` as part of their with_properties so we remove it"""
123            return self.properties(properties, prefix=" ", suffix="")
124
125        def renametable_sql(self, expression: exp.RenameTable) -> str:
126            """Redshift only supports defining the table name itself (not the db) when renaming tables"""
127            expression = expression.copy()
128            target_table = expression.this
129            for arg in target_table.args:
130                if arg != "this":
131                    target_table.set(arg, None)
132            this = self.sql(expression, "this")
133            return f"RENAME TO {this}"
134
135        def datatype_sql(self, expression: exp.DataType) -> str:
136            """
137            Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean
138            VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type
139            without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert
140            `TEXT` to `VARCHAR`.
141            """
142            if expression.this == exp.DataType.Type.TEXT:
143                expression = expression.copy()
144                expression.set("this", exp.DataType.Type.VARCHAR)
145                precision = expression.args.get("expressions")
146                if not precision:
147                    expression.append("expressions", exp.Var(this="MAX"))
148            return super().datatype_sql(expression)
class Redshift(sqlglot.dialects.postgres.Postgres):
 12class Redshift(Postgres):
 13    time_format = "'YYYY-MM-DD HH:MI:SS'"
 14    time_mapping = {
 15        **Postgres.time_mapping,  # type: ignore
 16        "MON": "%b",
 17        "HH": "%H",
 18    }
 19
 20    class Parser(Postgres.Parser):
 21        FUNCTIONS = {
 22            **Postgres.Parser.FUNCTIONS,  # type: ignore
 23            "DATEADD": lambda args: exp.DateAdd(
 24                this=seq_get(args, 2),
 25                expression=seq_get(args, 1),
 26                unit=seq_get(args, 0),
 27            ),
 28            "DATEDIFF": lambda args: exp.DateDiff(
 29                this=seq_get(args, 2),
 30                expression=seq_get(args, 1),
 31                unit=seq_get(args, 0),
 32            ),
 33            "NVL": exp.Coalesce.from_arg_list,
 34        }
 35
 36        CONVERT_TYPE_FIRST = True
 37
 38        def _parse_types(self, check_func: bool = False) -> t.Optional[exp.Expression]:
 39            this = super()._parse_types(check_func=check_func)
 40
 41            if (
 42                isinstance(this, exp.DataType)
 43                and this.this == exp.DataType.Type.VARCHAR
 44                and this.expressions
 45                and this.expressions[0] == exp.column("MAX")
 46            ):
 47                this.set("expressions", [exp.Var(this="MAX")])
 48
 49            return this
 50
 51    class Tokenizer(Postgres.Tokenizer):
 52        STRING_ESCAPES = ["\\"]
 53
 54        KEYWORDS = {
 55            **Postgres.Tokenizer.KEYWORDS,  # type: ignore
 56            "GEOMETRY": TokenType.GEOMETRY,
 57            "GEOGRAPHY": TokenType.GEOGRAPHY,
 58            "HLLSKETCH": TokenType.HLLSKETCH,
 59            "SUPER": TokenType.SUPER,
 60            "TIME": TokenType.TIMESTAMP,
 61            "TIMETZ": TokenType.TIMESTAMPTZ,
 62            "TOP": TokenType.TOP,
 63            "UNLOAD": TokenType.COMMAND,
 64            "VARBYTE": TokenType.VARBINARY,
 65        }
 66
 67    class Generator(Postgres.Generator):
 68        TYPE_MAPPING = {
 69            **Postgres.Generator.TYPE_MAPPING,  # type: ignore
 70            exp.DataType.Type.BINARY: "VARBYTE",
 71            exp.DataType.Type.VARBINARY: "VARBYTE",
 72            exp.DataType.Type.INT: "INTEGER",
 73        }
 74
 75        PROPERTIES_LOCATION = {
 76            **Postgres.Generator.PROPERTIES_LOCATION,  # type: ignore
 77            exp.LikeProperty: exp.Properties.Location.POST_WITH,
 78        }
 79
 80        TRANSFORMS = {
 81            **Postgres.Generator.TRANSFORMS,  # type: ignore
 82            **transforms.ELIMINATE_DISTINCT_ON,  # type: ignore
 83            exp.DateAdd: lambda self, e: self.func(
 84                "DATEADD", exp.var(e.text("unit") or "day"), e.expression, e.this
 85            ),
 86            exp.DateDiff: lambda self, e: self.func(
 87                "DATEDIFF", exp.var(e.text("unit") or "day"), e.expression, e.this
 88            ),
 89            exp.DistKeyProperty: lambda self, e: f"DISTKEY({e.name})",
 90            exp.DistStyleProperty: lambda self, e: self.naked_property(e),
 91            exp.SortKeyProperty: lambda self, e: f"{'COMPOUND ' if e.args['compound'] else ''}SORTKEY({self.format_args(*e.this)})",
 92        }
 93
 94        # Redshift uses the POW | POWER (expr1, expr2) syntax instead of expr1 ^ expr2 (postgres)
 95        TRANSFORMS.pop(exp.Pow)
 96
 97        def values_sql(self, expression: exp.Values) -> str:
 98            """
 99            Converts `VALUES...` expression into a series of unions.
100
101            Note: If you have a lot of unions then this will result in a large number of recursive statements to
102            evaluate the expression. You may need to increase `sys.setrecursionlimit` to run and it can also be
103            very slow.
104            """
105            if not isinstance(expression.unnest().parent, exp.From):
106                return super().values_sql(expression)
107            rows = [tuple_exp.expressions for tuple_exp in expression.expressions]
108            selects = []
109            for i, row in enumerate(rows):
110                if i == 0 and expression.alias:
111                    row = [
112                        exp.alias_(value, column_name)
113                        for value, column_name in zip(row, expression.args["alias"].args["columns"])
114                    ]
115                selects.append(exp.Select(expressions=row))
116            subquery_expression = selects[0]
117            if len(selects) > 1:
118                for select in selects[1:]:
119                    subquery_expression = exp.union(subquery_expression, select, distinct=False)
120            return self.subquery_sql(subquery_expression.subquery(expression.alias))
121
122        def with_properties(self, properties: exp.Properties) -> str:
123            """Redshift doesn't have `WITH` as part of their with_properties so we remove it"""
124            return self.properties(properties, prefix=" ", suffix="")
125
126        def renametable_sql(self, expression: exp.RenameTable) -> str:
127            """Redshift only supports defining the table name itself (not the db) when renaming tables"""
128            expression = expression.copy()
129            target_table = expression.this
130            for arg in target_table.args:
131                if arg != "this":
132                    target_table.set(arg, None)
133            this = self.sql(expression, "this")
134            return f"RENAME TO {this}"
135
136        def datatype_sql(self, expression: exp.DataType) -> str:
137            """
138            Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean
139            VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type
140            without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert
141            `TEXT` to `VARCHAR`.
142            """
143            if expression.this == exp.DataType.Type.TEXT:
144                expression = expression.copy()
145                expression.set("this", exp.DataType.Type.VARCHAR)
146                precision = expression.args.get("expressions")
147                if not precision:
148                    expression.append("expressions", exp.Var(this="MAX"))
149            return super().datatype_sql(expression)
class Redshift.Parser(sqlglot.dialects.postgres.Postgres.Parser):
20    class Parser(Postgres.Parser):
21        FUNCTIONS = {
22            **Postgres.Parser.FUNCTIONS,  # type: ignore
23            "DATEADD": lambda args: exp.DateAdd(
24                this=seq_get(args, 2),
25                expression=seq_get(args, 1),
26                unit=seq_get(args, 0),
27            ),
28            "DATEDIFF": lambda args: exp.DateDiff(
29                this=seq_get(args, 2),
30                expression=seq_get(args, 1),
31                unit=seq_get(args, 0),
32            ),
33            "NVL": exp.Coalesce.from_arg_list,
34        }
35
36        CONVERT_TYPE_FIRST = True
37
38        def _parse_types(self, check_func: bool = False) -> t.Optional[exp.Expression]:
39            this = super()._parse_types(check_func=check_func)
40
41            if (
42                isinstance(this, exp.DataType)
43                and this.this == exp.DataType.Type.VARCHAR
44                and this.expressions
45                and this.expressions[0] == exp.column("MAX")
46            ):
47                this.set("expressions", [exp.Var(this="MAX")])
48
49            return this

Parser consumes a list of tokens produced by the sqlglot.tokens.Tokenizer and produces a parsed syntax tree.

Arguments:
  • error_level: the desired error level. Default: ErrorLevel.RAISE
  • error_message_context: determines the amount of context to capture from a query string when displaying the error message (in number of characters). Default: 50.
  • index_offset: Index offset for arrays eg ARRAY[0] vs ARRAY[1] as the head of a list. Default: 0
  • alias_post_tablesample: If the table alias comes after tablesample. Default: False
  • max_errors: Maximum number of error messages to include in a raised ParseError. This is only relevant if error_level is ErrorLevel.RAISE. Default: 3
  • null_ordering: Indicates the default null ordering method to use if not explicitly set. Options are "nulls_are_small", "nulls_are_large", "nulls_are_last". Default: "nulls_are_small"
class Redshift.Tokenizer(sqlglot.dialects.postgres.Postgres.Tokenizer):
51    class Tokenizer(Postgres.Tokenizer):
52        STRING_ESCAPES = ["\\"]
53
54        KEYWORDS = {
55            **Postgres.Tokenizer.KEYWORDS,  # type: ignore
56            "GEOMETRY": TokenType.GEOMETRY,
57            "GEOGRAPHY": TokenType.GEOGRAPHY,
58            "HLLSKETCH": TokenType.HLLSKETCH,
59            "SUPER": TokenType.SUPER,
60            "TIME": TokenType.TIMESTAMP,
61            "TIMETZ": TokenType.TIMESTAMPTZ,
62            "TOP": TokenType.TOP,
63            "UNLOAD": TokenType.COMMAND,
64            "VARBYTE": TokenType.VARBINARY,
65        }
class Redshift.Generator(sqlglot.dialects.postgres.Postgres.Generator):
 67    class Generator(Postgres.Generator):
 68        TYPE_MAPPING = {
 69            **Postgres.Generator.TYPE_MAPPING,  # type: ignore
 70            exp.DataType.Type.BINARY: "VARBYTE",
 71            exp.DataType.Type.VARBINARY: "VARBYTE",
 72            exp.DataType.Type.INT: "INTEGER",
 73        }
 74
 75        PROPERTIES_LOCATION = {
 76            **Postgres.Generator.PROPERTIES_LOCATION,  # type: ignore
 77            exp.LikeProperty: exp.Properties.Location.POST_WITH,
 78        }
 79
 80        TRANSFORMS = {
 81            **Postgres.Generator.TRANSFORMS,  # type: ignore
 82            **transforms.ELIMINATE_DISTINCT_ON,  # type: ignore
 83            exp.DateAdd: lambda self, e: self.func(
 84                "DATEADD", exp.var(e.text("unit") or "day"), e.expression, e.this
 85            ),
 86            exp.DateDiff: lambda self, e: self.func(
 87                "DATEDIFF", exp.var(e.text("unit") or "day"), e.expression, e.this
 88            ),
 89            exp.DistKeyProperty: lambda self, e: f"DISTKEY({e.name})",
 90            exp.DistStyleProperty: lambda self, e: self.naked_property(e),
 91            exp.SortKeyProperty: lambda self, e: f"{'COMPOUND ' if e.args['compound'] else ''}SORTKEY({self.format_args(*e.this)})",
 92        }
 93
 94        # Redshift uses the POW | POWER (expr1, expr2) syntax instead of expr1 ^ expr2 (postgres)
 95        TRANSFORMS.pop(exp.Pow)
 96
 97        def values_sql(self, expression: exp.Values) -> str:
 98            """
 99            Converts `VALUES...` expression into a series of unions.
100
101            Note: If you have a lot of unions then this will result in a large number of recursive statements to
102            evaluate the expression. You may need to increase `sys.setrecursionlimit` to run and it can also be
103            very slow.
104            """
105            if not isinstance(expression.unnest().parent, exp.From):
106                return super().values_sql(expression)
107            rows = [tuple_exp.expressions for tuple_exp in expression.expressions]
108            selects = []
109            for i, row in enumerate(rows):
110                if i == 0 and expression.alias:
111                    row = [
112                        exp.alias_(value, column_name)
113                        for value, column_name in zip(row, expression.args["alias"].args["columns"])
114                    ]
115                selects.append(exp.Select(expressions=row))
116            subquery_expression = selects[0]
117            if len(selects) > 1:
118                for select in selects[1:]:
119                    subquery_expression = exp.union(subquery_expression, select, distinct=False)
120            return self.subquery_sql(subquery_expression.subquery(expression.alias))
121
122        def with_properties(self, properties: exp.Properties) -> str:
123            """Redshift doesn't have `WITH` as part of their with_properties so we remove it"""
124            return self.properties(properties, prefix=" ", suffix="")
125
126        def renametable_sql(self, expression: exp.RenameTable) -> str:
127            """Redshift only supports defining the table name itself (not the db) when renaming tables"""
128            expression = expression.copy()
129            target_table = expression.this
130            for arg in target_table.args:
131                if arg != "this":
132                    target_table.set(arg, None)
133            this = self.sql(expression, "this")
134            return f"RENAME TO {this}"
135
136        def datatype_sql(self, expression: exp.DataType) -> str:
137            """
138            Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean
139            VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type
140            without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert
141            `TEXT` to `VARCHAR`.
142            """
143            if expression.this == exp.DataType.Type.TEXT:
144                expression = expression.copy()
145                expression.set("this", exp.DataType.Type.VARCHAR)
146                precision = expression.args.get("expressions")
147                if not precision:
148                    expression.append("expressions", exp.Var(this="MAX"))
149            return super().datatype_sql(expression)

Generator interprets the given syntax tree and produces a SQL string as an output.

Arguments:
  • time_mapping (dict): the dictionary of custom time mappings in which the key represents a python time format and the output the target time format
  • time_trie (trie): a trie of the time_mapping keys
  • pretty (bool): if set to True the returned string will be formatted. Default: False.
  • quote_start (str): specifies which starting character to use to delimit quotes. Default: '.
  • quote_end (str): specifies which ending character to use to delimit quotes. Default: '.
  • identifier_start (str): specifies which starting character to use to delimit identifiers. Default: ".
  • identifier_end (str): specifies which ending character to use to delimit identifiers. Default: ".
  • identify (bool | str): 'always': always quote, 'safe': quote identifiers if they don't contain an upcase, True defaults to always.
  • normalize (bool): if set to True all identifiers will lower cased
  • string_escape (str): specifies a string escape character. Default: '.
  • identifier_escape (str): specifies an identifier escape character. Default: ".
  • pad (int): determines padding in a formatted string. Default: 2.
  • indent (int): determines the size of indentation in a formatted string. Default: 4.
  • unnest_column_only (bool): if true unnest table aliases are considered only as column aliases
  • normalize_functions (str): normalize function names, "upper", "lower", or None Default: "upper"
  • alias_post_tablesample (bool): if the table alias comes after tablesample Default: False
  • unsupported_level (ErrorLevel): determines the generator's behavior when it encounters unsupported expressions. Default ErrorLevel.WARN.
  • null_ordering (str): Indicates the default null ordering method to use if not explicitly set. Options are "nulls_are_small", "nulls_are_large", "nulls_are_last". Default: "nulls_are_small"
  • max_unsupported (int): 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 (bool): if the the comma is leading or trailing in select statements 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 or not to preserve comments in the output SQL code. Default: True
def values_sql(self, expression: sqlglot.expressions.Values) -> str:
 97        def values_sql(self, expression: exp.Values) -> str:
 98            """
 99            Converts `VALUES...` expression into a series of unions.
100
101            Note: If you have a lot of unions then this will result in a large number of recursive statements to
102            evaluate the expression. You may need to increase `sys.setrecursionlimit` to run and it can also be
103            very slow.
104            """
105            if not isinstance(expression.unnest().parent, exp.From):
106                return super().values_sql(expression)
107            rows = [tuple_exp.expressions for tuple_exp in expression.expressions]
108            selects = []
109            for i, row in enumerate(rows):
110                if i == 0 and expression.alias:
111                    row = [
112                        exp.alias_(value, column_name)
113                        for value, column_name in zip(row, expression.args["alias"].args["columns"])
114                    ]
115                selects.append(exp.Select(expressions=row))
116            subquery_expression = selects[0]
117            if len(selects) > 1:
118                for select in selects[1:]:
119                    subquery_expression = exp.union(subquery_expression, select, distinct=False)
120            return self.subquery_sql(subquery_expression.subquery(expression.alias))

Converts VALUES... expression into a series of unions.

Note: If you have a lot of unions then this will result in a large number of recursive statements to evaluate the expression. You may need to increase sys.setrecursionlimit to run and it can also be very slow.

def with_properties(self, properties: sqlglot.expressions.Properties) -> str:
122        def with_properties(self, properties: exp.Properties) -> str:
123            """Redshift doesn't have `WITH` as part of their with_properties so we remove it"""
124            return self.properties(properties, prefix=" ", suffix="")

Redshift doesn't have WITH as part of their with_properties so we remove it

def renametable_sql(self, expression: sqlglot.expressions.RenameTable) -> str:
126        def renametable_sql(self, expression: exp.RenameTable) -> str:
127            """Redshift only supports defining the table name itself (not the db) when renaming tables"""
128            expression = expression.copy()
129            target_table = expression.this
130            for arg in target_table.args:
131                if arg != "this":
132                    target_table.set(arg, None)
133            this = self.sql(expression, "this")
134            return f"RENAME TO {this}"

Redshift only supports defining the table name itself (not the db) when renaming tables

def datatype_sql(self, expression: sqlglot.expressions.DataType) -> str:
136        def datatype_sql(self, expression: exp.DataType) -> str:
137            """
138            Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean
139            VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type
140            without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert
141            `TEXT` to `VARCHAR`.
142            """
143            if expression.this == exp.DataType.Type.TEXT:
144                expression = expression.copy()
145                expression.set("this", exp.DataType.Type.VARCHAR)
146                precision = expression.args.get("expressions")
147                if not precision:
148                    expression.append("expressions", exp.Var(this="MAX"))
149            return super().datatype_sql(expression)

Redshift converts the TEXT data type to VARCHAR(255) by default when people more generally mean VARCHAR of max length which is VARCHAR(max) in Redshift. Therefore if we get a TEXT data type without precision we convert it to VARCHAR(max) and if it does have precision then we just convert TEXT to VARCHAR.

Inherited Members
sqlglot.generator.Generator
Generator
generate
unsupported
sep
seg
pad_comment
maybe_comment
wrap
no_identify
normalize_func
indent
sql
uncache_sql
cache_sql
characterset_sql
column_sql
columnposition_sql
columndef_sql
columnconstraint_sql
autoincrementcolumnconstraint_sql
compresscolumnconstraint_sql
generatedasidentitycolumnconstraint_sql
notnullcolumnconstraint_sql
primarykeycolumnconstraint_sql
uniquecolumnconstraint_sql
create_sql
describe_sql
prepend_ctes
with_sql
cte_sql
tablealias_sql
bitstring_sql
hexstring_sql
directory_sql
delete_sql
drop_sql
except_sql
except_op
fetch_sql
filter_sql
hint_sql
index_sql
identifier_sql
national_sql
partition_sql
properties_sql
root_properties
properties
locate_properties
property_sql
likeproperty_sql
fallbackproperty_sql
journalproperty_sql
freespaceproperty_sql
afterjournalproperty_sql
checksumproperty_sql
mergeblockratioproperty_sql
datablocksizeproperty_sql
blockcompressionproperty_sql
isolatedloadingproperty_sql
lockingproperty_sql
withdataproperty_sql
insert_sql
intersect_sql
intersect_op
introducer_sql
pseudotype_sql
returning_sql
rowformatdelimitedproperty_sql
table_sql
tablesample_sql
pivot_sql
tuple_sql
update_sql
var_sql
into_sql
from_sql
group_sql
having_sql
join_sql
lambda_sql
lateral_sql
limit_sql
offset_sql
setitem_sql
set_sql
pragma_sql
lock_sql
literal_sql
loaddata_sql
null_sql
boolean_sql
order_sql
cluster_sql
distribute_sql
sort_sql
ordered_sql
matchrecognize_sql
query_modifiers
select_sql
schema_sql
star_sql
structkwarg_sql
parameter_sql
sessionparameter_sql
placeholder_sql
subquery_sql
qualify_sql
union_sql
union_op
unnest_sql
where_sql
window_sql
partition_by_sql
window_spec_sql
withingroup_sql
between_sql
bracket_sql
all_sql
any_sql
exists_sql
case_sql
constraint_sql
extract_sql
trim_sql
concat_sql
check_sql
foreignkey_sql
primarykey_sql
unique_sql
if_sql
matchagainst_sql
jsonkeyvalue_sql
jsonobject_sql
in_sql
in_unnest_op
interval_sql
return_sql
reference_sql
anonymous_sql
paren_sql
neg_sql
not_sql
alias_sql
aliases_sql
attimezone_sql
add_sql
and_sql
connector_sql
bitwiseand_sql
bitwiseleftshift_sql
bitwisenot_sql
bitwiseor_sql
bitwiserightshift_sql
bitwisexor_sql
cast_sql
currentdate_sql
collate_sql
command_sql
comment_sql
transaction_sql
commit_sql
rollback_sql
altercolumn_sql
altertable_sql
droppartition_sql
addconstraint_sql
distinct_sql
ignorenulls_sql
respectnulls_sql
intdiv_sql
dpipe_sql
div_sql
overlaps_sql
distance_sql
dot_sql
eq_sql
escape_sql
glob_sql
gt_sql
gte_sql
ilike_sql
ilikeany_sql
is_sql
like_sql
likeany_sql
similarto_sql
lt_sql
lte_sql
mod_sql
mul_sql
neq_sql
nullsafeeq_sql
nullsafeneq_sql
or_sql
slice_sql
sub_sql
trycast_sql
use_sql
binary
function_fallback_sql
func
format_args
text_width
format_time
expressions
op_expressions
naked_property
set_operation
tag_sql
token_sql
userdefinedfunction_sql
joinhint_sql
kwarg_sql
when_sql
merge_sql
tochar_sql