Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -6348,6 +6348,10 @@ class CurrentRegion(Func):
arg_types = {}


class CurrentRole(Func):
arg_types = {}


class CurrentOrganizationUser(Func):
arg_types = {}

Expand Down
1 change: 1 addition & 0 deletions sqlglot/typing/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ def _annotate_math_with_float_decfloat(
exp.Collation,
exp.CurrentOrganizationUser,
exp.CurrentRegion,
exp.CurrentRole,
exp.CurrentOrganizationName,
exp.DecompressString,
exp.HexDecodeString,
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 @@ -231,6 +231,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 YEAR(CURRENT_TIMESTAMP())")
self.validate_identity("SELECT YEAROFWEEK(CURRENT_TIMESTAMP())")
self.validate_identity("SELECT YEAROFWEEKISO(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 @@ -2180,6 +2180,10 @@ VARCHAR;
CURRENT_REGION();
VARCHAR;

# dialect: snowflake
CURRENT_ROLE();
VARCHAR;

# dialect: snowflake
CURRENT_ORGANIZATION_NAME();
VARCHAR;
Expand Down