diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-03 14:11:07 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-03 14:11:07 +0000 |
commit | 42a1548cecf48d18233f56e3385cf9c89abcb9c2 (patch) | |
tree | 5e0fff4ecbd1fd7dd1022a7580139038df2a824c /sqlglot/dialects/redshift.py | |
parent | Releasing debian version 21.1.2-1. (diff) | |
download | sqlglot-42a1548cecf48d18233f56e3385cf9c89abcb9c2.tar.xz sqlglot-42a1548cecf48d18233f56e3385cf9c89abcb9c2.zip |
Merging upstream version 22.2.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/dialects/redshift.py')
-rw-r--r-- | sqlglot/dialects/redshift.py | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/sqlglot/dialects/redshift.py b/sqlglot/dialects/redshift.py index 2201c78..0db87ec 100644 --- a/sqlglot/dialects/redshift.py +++ b/sqlglot/dialects/redshift.py @@ -70,6 +70,8 @@ class Redshift(Postgres): "SYSDATE": lambda self: self.expression(exp.CurrentTimestamp, transaction=True), } + SUPPORTS_IMPLICIT_UNNEST = True + def _parse_table( self, schema: bool = False, @@ -124,27 +126,6 @@ class Redshift(Postgres): self._retreat(index) return None - def _parse_query_modifiers( - self, this: t.Optional[exp.Expression] - ) -> t.Optional[exp.Expression]: - this = super()._parse_query_modifiers(this) - - if this: - refs = set() - - for i, join in enumerate(this.args.get("joins", [])): - refs.add( - ( - this.args["from"] if i == 0 else this.args["joins"][i - 1] - ).this.alias.lower() - ) - - table = join.this - if isinstance(table, exp.Table) and not join.args.get("on"): - if table.parts[0].name.lower() in refs: - table.replace(table.to_column()) - return this - class Tokenizer(Postgres.Tokenizer): BIT_STRINGS = [] HEX_STRINGS = [] @@ -225,6 +206,18 @@ class Redshift(Postgres): RESERVED_KEYWORDS = {*Postgres.Generator.RESERVED_KEYWORDS, "snapshot", "type"} + def unnest_sql(self, expression: exp.Unnest) -> str: + args = expression.expressions + num_args = len(args) + + if num_args > 1: + self.unsupported(f"Unsupported number of arguments in UNNEST: {num_args}") + return "" + + arg = self.sql(seq_get(args, 0)) + alias = self.expressions(expression.args.get("alias"), key="columns") + return f"{arg} AS {alias}" if alias else arg + def with_properties(self, properties: exp.Properties) -> str: """Redshift doesn't have `WITH` as part of their with_properties so we remove it""" return self.properties(properties, prefix=" ", suffix="") |