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
4 changes: 4 additions & 0 deletions sqlglot/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6360,6 +6360,10 @@ class CurrentRegion(Func):
arg_types = {}


class CurrentRole(Func):
arg_types = {}


class CurrentRoleType(Func):
arg_types = {}

Expand Down
1 change: 1 addition & 0 deletions sqlglot/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ class Parser(metaclass=_Parser):
TokenType.CURRENT_USER: exp.CurrentUser,
TokenType.LOCALTIME: exp.Localtime,
TokenType.LOCALTIMESTAMP: exp.Localtimestamp,
TokenType.CURRENT_ROLE: exp.CurrentRole,
}

STRUCT_TYPE_TOKENS = {
Expand Down
1 change: 1 addition & 0 deletions sqlglot/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ class TokenType(AutoName):
CURRENT_TIME = auto()
CURRENT_TIMESTAMP = auto()
CURRENT_USER = auto()
CURRENT_ROLE = auto()
DECLARE = auto()
DEFAULT = auto()
DELETE = auto()
Expand Down
1 change: 1 addition & 0 deletions sqlglot/typing/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ def _annotate_math_with_float_decfloat(
exp.Collation,
exp.CurrentOrganizationUser,
exp.CurrentRegion,
exp.CurrentRole,
exp.CurrentRoleType,
exp.CurrentOrganizationName,
exp.DecompressString,
Expand Down
1 change: 1 addition & 0 deletions tests/dialects/test_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ def test_identity(self):
self.validate_identity("""SELECT 'ab' MEMBER OF('[23, "abc", 17, "ab", 10]')""")
self.validate_identity("""SELECT * FROM foo WHERE 'ab' MEMBER OF(content)""")
self.validate_identity("SELECT CURRENT_TIMESTAMP(6)")
self.validate_identity("SELECT CURRENT_ROLE()")
self.validate_identity("x ->> '$.name'")
self.validate_identity("SELECT CAST(`a`.`b` AS CHAR) FROM foo")
self.validate_identity("SELECT TRIM(LEADING 'bla' FROM ' XXX ')")
Expand Down
1 change: 1 addition & 0 deletions tests/dialects/test_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def test_postgres(self):
self.validate_identity("EXEC AS myfunc @id = 123", check_command_warning=True)
self.validate_identity("SELECT CURRENT_SCHEMA")
self.validate_identity("SELECT CURRENT_USER")
self.validate_identity("SELECT CURRENT_ROLE")
self.validate_identity("SELECT * FROM ONLY t1")
self.validate_identity("SELECT INTERVAL '-1 MONTH'")
self.validate_identity("SELECT INTERVAL '4.1 DAY'")
Expand Down
1 change: 1 addition & 0 deletions tests/dialects/test_snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ def test_snowflake(self):
self.validate_identity("SELECT OBJECT_CONSTRUCT()")
self.validate_identity("SELECT CURRENT_ORGANIZATION_USER()")
self.validate_identity("SELECT CURRENT_REGION()")
self.validate_identity("SELECT CURRENT_ROLE()")
self.validate_identity("SELECT CURRENT_ROLE_TYPE()")
self.validate_identity("SELECT YEAR(CURRENT_TIMESTAMP())")
self.validate_identity("SELECT YEAROFWEEK(CURRENT_TIMESTAMP())")
Expand Down
4 changes: 4 additions & 0 deletions tests/fixtures/optimizer/annotate_functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2284,6 +2284,10 @@ VARCHAR;
CURRENT_REGION();
VARCHAR;

# dialect: snowflake
CURRENT_ROLE();
VARCHAR;

# dialect: snowflake
CURRENT_ROLE_TYPE();
VARCHAR;
Expand Down
Loading