Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sqlglot-integration-tests
4 changes: 3 additions & 1 deletion sqlglot/dialects/redshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ class Tokenizer(Postgres.Tokenizer):
KEYWORDS = {
**Postgres.Tokenizer.KEYWORDS,
"(+)": TokenType.JOIN_MARKER,
"BINARY VARYING": TokenType.VARBINARY,
"CURRENT_USER_ID": TokenType.CURRENT_USER_ID,
"HLLSKETCH": TokenType.HLLSKETCH,
"MINUS": TokenType.EXCEPT,
"SUPER": TokenType.SUPER,
"TOP": TokenType.TOP,
"UNLOAD": TokenType.COMMAND,
"USER": TokenType.CURRENT_USER,
"VARBYTE": TokenType.VARBINARY,
"BINARY VARYING": TokenType.VARBINARY,
}
KEYWORDS.pop("VALUES")

Expand Down
4 changes: 4 additions & 0 deletions sqlglot/expressions/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ class CurrentUser(Expression, Func):
arg_types = {"this": False}


class CurrentUserId(Expression, Func):
arg_types = {}


class CurrentVersion(Expression, Func):
arg_types = {}

Expand Down
1 change: 1 addition & 0 deletions sqlglot/generators/redshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class RedshiftGenerator(PostgresGenerator):
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" if e.args.get("sysdate") else "GETDATE()",
exp.CurrentUserId: lambda *_: "CURRENT_USER_ID",
exp.DateAdd: date_delta_sql("DATEADD"),
exp.DateDiff: date_delta_sql("DATEDIFF"),
exp.DistKeyProperty: lambda self, e: self.func("DISTKEY", e.this),
Expand Down
5 changes: 5 additions & 0 deletions sqlglot/parsers/redshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ class RedshiftParser(PostgresParser):
),
}

NO_PAREN_FUNCTIONS = {
**PostgresParser.NO_PAREN_FUNCTIONS,
TokenType.CURRENT_USER_ID: exp.CurrentUserId,
}

NO_PAREN_FUNCTION_PARSERS = {
**PostgresParser.NO_PAREN_FUNCTION_PARSERS,
"APPROXIMATE": lambda self: self._parse_approximate_count(),
Expand Down
1 change: 1 addition & 0 deletions sqlglot/tokenizer_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ class TokenType(IntEnum):
CURRENT_TIME = auto()
CURRENT_TIMESTAMP = auto()
CURRENT_USER = auto()
CURRENT_USER_ID = auto()
CURRENT_ROLE = auto()
CURRENT_CATALOG = auto()
DECLARE = auto()
Expand Down
Loading