summaryrefslogtreecommitdiffstats
path: root/sqlglot/dialects/redshift.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 02:50:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 02:50:25 +0000
commitcf49728f719975144a958f23ba5f3336fb81ae55 (patch)
tree78aa5446e86cc5623808508ee167c9a476754939 /sqlglot/dialects/redshift.py
parentReleasing debian version 23.10.0-1. (diff)
downloadsqlglot-cf49728f719975144a958f23ba5f3336fb81ae55.tar.xz
sqlglot-cf49728f719975144a958f23ba5f3336fb81ae55.zip
Merging upstream version 23.12.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/dialects/redshift.py')
-rw-r--r--sqlglot/dialects/redshift.py162
1 files changed, 161 insertions, 1 deletions
diff --git a/sqlglot/dialects/redshift.py b/sqlglot/dialects/redshift.py
index 7a86c61..7b98ed4 100644
--- a/sqlglot/dialects/redshift.py
+++ b/sqlglot/dialects/redshift.py
@@ -79,6 +79,7 @@ class Redshift(Postgres):
alias_tokens: t.Optional[t.Collection[TokenType]] = None,
parse_bracket: bool = False,
is_db_reference: bool = False,
+ parse_partition: bool = False,
) -> t.Optional[exp.Expression]:
# Redshift supports UNPIVOTing SUPER objects, e.g. `UNPIVOT foo.obj[0] AS val AT attr`
unpivot = self._match(TokenType.UNPIVOT)
@@ -145,6 +146,7 @@ class Redshift(Postgres):
exp.DataType.Type.TIMETZ: "TIME",
exp.DataType.Type.TIMESTAMPTZ: "TIMESTAMP",
exp.DataType.Type.VARBINARY: "VARBYTE",
+ exp.DataType.Type.ROWVERSION: "VARBYTE",
}
TRANSFORMS = {
@@ -196,7 +198,165 @@ class Redshift(Postgres):
# Redshift supports LAST_DAY(..)
TRANSFORMS.pop(exp.LastDay)
- RESERVED_KEYWORDS = {*Postgres.Generator.RESERVED_KEYWORDS, "snapshot", "type"}
+ RESERVED_KEYWORDS = {
+ "aes128",
+ "aes256",
+ "all",
+ "allowoverwrite",
+ "analyse",
+ "analyze",
+ "and",
+ "any",
+ "array",
+ "as",
+ "asc",
+ "authorization",
+ "az64",
+ "backup",
+ "between",
+ "binary",
+ "blanksasnull",
+ "both",
+ "bytedict",
+ "bzip2",
+ "case",
+ "cast",
+ "check",
+ "collate",
+ "column",
+ "constraint",
+ "create",
+ "credentials",
+ "cross",
+ "current_date",
+ "current_time",
+ "current_timestamp",
+ "current_user",
+ "current_user_id",
+ "default",
+ "deferrable",
+ "deflate",
+ "defrag",
+ "delta",
+ "delta32k",
+ "desc",
+ "disable",
+ "distinct",
+ "do",
+ "else",
+ "emptyasnull",
+ "enable",
+ "encode",
+ "encrypt ",
+ "encryption",
+ "end",
+ "except",
+ "explicit",
+ "false",
+ "for",
+ "foreign",
+ "freeze",
+ "from",
+ "full",
+ "globaldict256",
+ "globaldict64k",
+ "grant",
+ "group",
+ "gzip",
+ "having",
+ "identity",
+ "ignore",
+ "ilike",
+ "in",
+ "initially",
+ "inner",
+ "intersect",
+ "interval",
+ "into",
+ "is",
+ "isnull",
+ "join",
+ "leading",
+ "left",
+ "like",
+ "limit",
+ "localtime",
+ "localtimestamp",
+ "lun",
+ "luns",
+ "lzo",
+ "lzop",
+ "minus",
+ "mostly16",
+ "mostly32",
+ "mostly8",
+ "natural",
+ "new",
+ "not",
+ "notnull",
+ "null",
+ "nulls",
+ "off",
+ "offline",
+ "offset",
+ "oid",
+ "old",
+ "on",
+ "only",
+ "open",
+ "or",
+ "order",
+ "outer",
+ "overlaps",
+ "parallel",
+ "partition",
+ "percent",
+ "permissions",
+ "pivot",
+ "placing",
+ "primary",
+ "raw",
+ "readratio",
+ "recover",
+ "references",
+ "rejectlog",
+ "resort",
+ "respect",
+ "restore",
+ "right",
+ "select",
+ "session_user",
+ "similar",
+ "snapshot",
+ "some",
+ "sysdate",
+ "system",
+ "table",
+ "tag",
+ "tdes",
+ "text255",
+ "text32k",
+ "then",
+ "timestamp",
+ "to",
+ "top",
+ "trailing",
+ "true",
+ "truncatecolumns",
+ "type",
+ "union",
+ "unique",
+ "unnest",
+ "unpivot",
+ "user",
+ "using",
+ "verbose",
+ "wallet",
+ "when",
+ "where",
+ "with",
+ "without",
+ }
def unnest_sql(self, expression: exp.Unnest) -> str:
args = expression.expressions