diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-30 04:54:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-30 04:54:49 +0000 |
commit | 3baf961bf84d7a67c838d6bc09cc5f0fe90a35b4 (patch) | |
tree | dc974c69ee45867df73e46342261aa658eb50392 /tests/dialects/test_redshift.py | |
parent | Releasing debian version 25.21.3-1. (diff) | |
download | sqlglot-3baf961bf84d7a67c838d6bc09cc5f0fe90a35b4.tar.xz sqlglot-3baf961bf84d7a67c838d6bc09cc5f0fe90a35b4.zip |
Merging upstream version 25.24.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_redshift.py')
-rw-r--r-- | tests/dialects/test_redshift.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/dialects/test_redshift.py b/tests/dialects/test_redshift.py index c13b61a..6f561da 100644 --- a/tests/dialects/test_redshift.py +++ b/tests/dialects/test_redshift.py @@ -626,3 +626,36 @@ FROM ( "TIME_TO_STR(a, '%Y-%m-%d %H:%M:%S.%f')", write={"redshift": "TO_CHAR(a, 'YYYY-MM-DD HH24:MI:SS.US')"}, ) + + def test_grant(self): + grant_cmds = [ + "GRANT SELECT ON ALL TABLES IN SCHEMA qa_tickit TO fred", + "GRANT USAGE ON DATASHARE salesshare TO NAMESPACE '13b8833d-17c6-4f16-8fe4-1a018f5ed00d'", + "GRANT USAGE FOR SCHEMAS IN DATABASE Sales_db TO ROLE Sales", + "GRANT EXECUTE FOR FUNCTIONS IN SCHEMA Sales_schema TO bob", + "GRANT SELECT FOR TABLES IN DATABASE Sales_db TO alice WITH GRANT OPTION", + "GRANT ALL FOR TABLES IN SCHEMA ShareSchema DATABASE ShareDb TO ROLE Sales", + "GRANT ASSUMEROLE ON 'arn:aws:iam::123456789012:role/Redshift-Exfunc' TO reg_user1 FOR EXTERNAL FUNCTION", + "GRANT ROLE sample_role1 TO ROLE sample_role2", + ] + + for sql in grant_cmds: + with self.subTest(f"Testing Redshift's GRANT command statement: {sql}"): + self.validate_identity(sql, check_command_warning=True) + + self.validate_identity("GRANT SELECT ON TABLE sales TO fred") + self.validate_identity("GRANT ALL ON SCHEMA qa_tickit TO GROUP qa_users") + self.validate_identity("GRANT ALL ON TABLE qa_tickit.sales TO GROUP qa_users") + self.validate_identity( + "GRANT ALL ON TABLE qa_tickit.sales TO GROUP qa_users, GROUP ro_users" + ) + self.validate_identity("GRANT ALL ON view_date TO view_user") + self.validate_identity( + "GRANT SELECT(cust_name, cust_phone), UPDATE(cust_contact_preference) ON cust_profile TO GROUP sales_group" + ) + self.validate_identity( + "GRANT ALL(cust_name, cust_phone, cust_contact_preference) ON cust_profile TO GROUP sales_admin" + ) + self.validate_identity("GRANT USAGE ON DATABASE sales_db TO Bob") + self.validate_identity("GRANT USAGE ON SCHEMA sales_schema TO ROLE Analyst_role") + self.validate_identity("GRANT SELECT ON sales_db.sales_schema.tickit_sales_redshift TO Bob") |