Merging upstream version 18.13.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
a56b8dde5c
commit
320822f1c4
76 changed files with 21248 additions and 19605 deletions
|
@ -58,6 +58,11 @@ class Redshift(Postgres):
|
|||
"STRTOL": exp.FromBase.from_arg_list,
|
||||
}
|
||||
|
||||
NO_PAREN_FUNCTION_PARSERS = {
|
||||
**Postgres.Parser.NO_PAREN_FUNCTION_PARSERS,
|
||||
"APPROXIMATE": lambda self: self._parse_approximate_count(),
|
||||
}
|
||||
|
||||
def _parse_table(
|
||||
self,
|
||||
schema: bool = False,
|
||||
|
@ -93,11 +98,22 @@ class Redshift(Postgres):
|
|||
|
||||
return this
|
||||
|
||||
def _parse_convert(self, strict: bool) -> t.Optional[exp.Expression]:
|
||||
def _parse_convert(
|
||||
self, strict: bool, safe: t.Optional[bool] = None
|
||||
) -> t.Optional[exp.Expression]:
|
||||
to = self._parse_types()
|
||||
self._match(TokenType.COMMA)
|
||||
this = self._parse_bitwise()
|
||||
return self.expression(exp.TryCast, this=this, to=to)
|
||||
return self.expression(exp.TryCast, this=this, to=to, safe=safe)
|
||||
|
||||
def _parse_approximate_count(self) -> t.Optional[exp.ApproxDistinct]:
|
||||
index = self._index - 1
|
||||
func = self._parse_function()
|
||||
|
||||
if isinstance(func, exp.Count) and isinstance(func.this, exp.Distinct):
|
||||
return self.expression(exp.ApproxDistinct, this=seq_get(func.this.expressions, 0))
|
||||
self._retreat(index)
|
||||
return None
|
||||
|
||||
class Tokenizer(Postgres.Tokenizer):
|
||||
BIT_STRINGS = []
|
||||
|
@ -144,6 +160,7 @@ class Redshift(Postgres):
|
|||
**Postgres.Generator.TRANSFORMS,
|
||||
exp.Concat: concat_to_dpipe_sql,
|
||||
exp.ConcatWs: concat_ws_to_dpipe_sql,
|
||||
exp.ApproxDistinct: lambda self, e: f"APPROXIMATE COUNT(DISTINCT {self.sql(e, 'this')})",
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue