Adding upstream version 16.2.1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
577b79f5a7
commit
d61627452f
106 changed files with 41940 additions and 40162 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue