diff options
Diffstat (limited to '')
-rw-r--r-- | sqlglot/dialects/redshift.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sqlglot/dialects/redshift.py b/sqlglot/dialects/redshift.py index b0a6774..a7e25fa 100644 --- a/sqlglot/dialects/redshift.py +++ b/sqlglot/dialects/redshift.py @@ -3,7 +3,7 @@ from __future__ import annotations import typing as t from sqlglot import exp, transforms -from sqlglot.dialects.dialect import rename_func +from sqlglot.dialects.dialect import concat_to_dpipe_sql, rename_func from sqlglot.dialects.postgres import Postgres from sqlglot.helper import seq_get from sqlglot.tokens import TokenType @@ -14,9 +14,9 @@ def _json_sql(self: Postgres.Generator, expression: exp.JSONExtract | exp.JSONEx class Redshift(Postgres): - time_format = "'YYYY-MM-DD HH:MI:SS'" - time_mapping = { - **Postgres.time_mapping, + TIME_FORMAT = "'YYYY-MM-DD HH:MI:SS'" + TIME_MAPPING = { + **Postgres.TIME_MAPPING, "MON": "%b", "HH": "%H", } @@ -51,7 +51,7 @@ class Redshift(Postgres): and this.expressions and this.expressions[0].this == exp.column("MAX") ): - this.set("expressions", [exp.Var(this="MAX")]) + this.set("expressions", [exp.var("MAX")]) return this @@ -94,6 +94,7 @@ class Redshift(Postgres): TRANSFORMS = { **Postgres.Generator.TRANSFORMS, + exp.Concat: concat_to_dpipe_sql, exp.CurrentTimestamp: lambda self, e: "SYSDATE", exp.DateAdd: lambda self, e: self.func( "DATEADD", exp.var(e.text("unit") or "day"), e.expression, e.this @@ -106,6 +107,7 @@ class Redshift(Postgres): exp.FromBase: rename_func("STRTOL"), exp.JSONExtract: _json_sql, exp.JSONExtractScalar: _json_sql, + exp.SafeConcat: concat_to_dpipe_sql, exp.Select: transforms.preprocess([transforms.eliminate_distinct_on]), exp.SortKeyProperty: lambda self, e: f"{'COMPOUND ' if e.args['compound'] else ''}SORTKEY({self.format_args(*e.this)})", exp.TsOrDsToDate: lambda self, e: self.sql(e.this), @@ -170,6 +172,6 @@ class Redshift(Postgres): precision = expression.args.get("expressions") if not precision: - expression.append("expressions", exp.Var(this="MAX")) + expression.append("expressions", exp.var("MAX")) return super().datatype_sql(expression) |