forked from dbt-labs/dbt-redshift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CT-789] Add Grants to Materializations dbt-labs#212 (dbt-labs#131)
* Use development branch of dbt-core [skip ci] * Adapter-specific macro to show grants / get a list of table privileges from Redshift * Replace with tests that exist * Inherit functional tests for grants * Align `privilege_type` nomenclature with postgres adapter * Add new environment variables to CI * Add new environment variables to CI * Try hard-coded user names * Remove adapter-specific implementation of `get_revoke_sql` * Covert hard-code env vars to pull from GitHub secrets instead * Plain text rather than repo secrets * Filter out grants to the current user * Switch to branch with more tests [skip ci] * Ignore super users * Replace untyped constant with an explicit typed constant * Remove extraneous `pass` * Update CHANGELOG [skip ci] * Fix CHANGELOG [skip ci] * Inherit default tests * Update development branch * Point back to main branch for dbt-core
- Loading branch information
Showing
6 changed files
with
72 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{% macro redshift__get_show_grant_sql(relation) %} | ||
|
||
with privileges as ( | ||
|
||
-- valid options per https://docs.aws.amazon.com/redshift/latest/dg/r_HAS_TABLE_PRIVILEGE.html | ||
select 'select' as privilege_type | ||
union all | ||
select 'insert' as privilege_type | ||
union all | ||
select 'update' as privilege_type | ||
union all | ||
select 'delete' as privilege_type | ||
union all | ||
select 'references' as privilege_type | ||
|
||
) | ||
|
||
select | ||
u.usename as grantee, | ||
p.privilege_type | ||
from pg_user u | ||
cross join privileges p | ||
where has_table_privilege(u.usename, '{{ relation }}', privilege_type) | ||
and u.usename != current_user | ||
and not u.usesuper | ||
|
||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pytest | ||
from dbt.tests.adapter.grants.test_model_grants import BaseModelGrants | ||
from dbt.tests.adapter.grants.test_incremental_grants import BaseIncrementalGrants | ||
from dbt.tests.adapter.grants.test_invalid_grants import BaseInvalidGrants | ||
from dbt.tests.adapter.grants.test_seed_grants import BaseSeedGrants | ||
from dbt.tests.adapter.grants.test_snapshot_grants import BaseSnapshotGrants | ||
|
||
|
||
class TestModelGrantsRedshift(BaseModelGrants): | ||
pass | ||
|
||
|
||
class TestIncrementalGrantsRedshift(BaseIncrementalGrants): | ||
pass | ||
|
||
|
||
class TestSeedGrantsRedshift(BaseSeedGrants): | ||
pass | ||
|
||
|
||
class TestSnapshotGrantsRedshift(BaseSnapshotGrants): | ||
pass | ||
|
||
|
||
class TestInvalidGrantsRedshift(BaseModelGrants): | ||
pass |