From 80aa2bffbdef2089415ee6fb1ae934a7c2b706c7 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Thu, 7 Jul 2022 08:39:29 -0600 Subject: [PATCH 01/21] Use development branch of dbt-core [skip ci] --- dev_requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dev_requirements.txt b/dev_requirements.txt index a63ecbcf0..df50b4ff6 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -1,8 +1,8 @@ # install latest changes in dbt-core + dbt-postgres # TODO: how to switch from HEAD to x.y.latest branches after minor releases? -git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core -git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-tests-adapter&subdirectory=tests/adapter -git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-postgres&subdirectory=plugins/postgres +git+https://github.com/dbt-labs/dbt-core.git@ct-660-grant-sql#egg=dbt-core&subdirectory=core +git+https://github.com/dbt-labs/dbt-core.git@ct-660-grant-sql#egg=dbt-tests-adapter&subdirectory=tests/adapter +git+https://github.com/dbt-labs/dbt-core.git@ct-660-grant-sql#egg=dbt-postgres&subdirectory=plugins/postgres black==22.3.0 click~=8.0.4 From 67ad01ea6be25e85514b91ff7cf9d71ef8ce8a54 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Thu, 7 Jul 2022 09:59:20 -0600 Subject: [PATCH 02/21] Adapter-specific macro to show grants / get a list of table privileges from Redshift --- .../redshift/macros/adapters/apply_grants.sql | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 dbt/include/redshift/macros/adapters/apply_grants.sql diff --git a/dbt/include/redshift/macros/adapters/apply_grants.sql b/dbt/include/redshift/macros/adapters/apply_grants.sql new file mode 100644 index 000000000..89e2a9cce --- /dev/null +++ b/dbt/include/redshift/macros/adapters/apply_grants.sql @@ -0,0 +1,25 @@ +{% 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 + union all + select 'insert' as privilege + union all + select 'update' as privilege + union all + select 'delete' as privilege + union all + select 'references' as privilege + +) + +select + u.usename as grantee, + p.privilege +from pg_user u +cross join privileges p +where has_table_privilege(u.usename, '{{ relation }}', privilege) + +{% endmacro %} From 6168963902d2ac2c7dab59b97eb60733439ff6e8 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Thu, 7 Jul 2022 11:55:24 -0600 Subject: [PATCH 03/21] Replace with tests that exist --- CONTRIBUTING.MD | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.MD b/CONTRIBUTING.MD index 1ce797980..b27a34cf0 100644 --- a/CONTRIBUTING.MD +++ b/CONTRIBUTING.MD @@ -77,14 +77,15 @@ Finally, you can also run a specific test or group of tests using `pytest` direc ```sh # run specific redshift integration tests -python -m pytest -m profile_redshift tests/integration/adapter_methods_test +python -m pytest -m profile_redshift tests/integration/simple_seed_test # run specific redshift functional tests in a file python -m pytest tests/functional/adapter/test_basic.py # run all unit tests in a file python -m pytest tests/unit/test_redshift_adapter.py # run a specific unit test -python -m pytest tests/unit/test_redshift_adapter.py::TestRedshiftAdapter::test_convert_date_type +python -m pytest tests/unit/test_redshift_adapter.py::TestRedshiftAdapterConversions::test_convert_date_type ``` + ## Updating Docs Many changes will require an update to the `dbt-redshift` docs. If so, here are some useful resources to find where the current behavior is documented. From 349960b0290515dabe4f225a20a571e2843f69c5 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Thu, 7 Jul 2022 15:34:44 -0600 Subject: [PATCH 04/21] Inherit functional tests for grants --- test.env.example | 4 ++++ tests/functional/adapter/test_grants.py | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 tests/functional/adapter/test_grants.py diff --git a/test.env.example b/test.env.example index 4d965c0d6..4de05edab 100644 --- a/test.env.example +++ b/test.env.example @@ -12,3 +12,7 @@ REDSHIFT_TEST_PASS= REDSHIFT_TEST_PORT= # Name of Redshift database in your account to test against REDSHIFT_TEST_DBNAME= +# Users for testing +DBT_TEST_USER_1=dbt_test_user_1 +DBT_TEST_USER_2=dbt_test_user_2 +DBT_TEST_USER_3=dbt_test_user_3 diff --git a/tests/functional/adapter/test_grants.py b/tests/functional/adapter/test_grants.py new file mode 100644 index 000000000..fdf5234e5 --- /dev/null +++ b/tests/functional/adapter/test_grants.py @@ -0,0 +1,5 @@ +from dbt.tests.adapter.grants.test_models import TestModelGrants + + +class TestModelGrantsRedshift(TestModelGrants): + pass From d031572539d79084b0d2b996af3fb86c25e4a3c4 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Thu, 7 Jul 2022 15:56:38 -0600 Subject: [PATCH 05/21] Align `privilege_type` nomenclature with postgres adapter --- .../redshift/macros/adapters/apply_grants.sql | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/dbt/include/redshift/macros/adapters/apply_grants.sql b/dbt/include/redshift/macros/adapters/apply_grants.sql index 89e2a9cce..e279ec129 100644 --- a/dbt/include/redshift/macros/adapters/apply_grants.sql +++ b/dbt/include/redshift/macros/adapters/apply_grants.sql @@ -3,23 +3,35 @@ with privileges as ( -- valid options per https://docs.aws.amazon.com/redshift/latest/dg/r_HAS_TABLE_PRIVILEGE.html - select 'select' as privilege + select 'select' as privilege_type union all - select 'insert' as privilege + select 'insert' as privilege_type union all - select 'update' as privilege + select 'update' as privilege_type union all - select 'delete' as privilege + select 'delete' as privilege_type union all - select 'references' as privilege + select 'references' as privilege_type ) select u.usename as grantee, - p.privilege + p.privilege_type from pg_user u cross join privileges p -where has_table_privilege(u.usename, '{{ relation }}', privilege) +where has_table_privilege(u.usename, '{{ relation }}', privilege_type) {% endmacro %} + + +{% macro redshift__get_revoke_sql(relation, grant_config) %} + {%- for privilege in grant_config.keys() -%} + {%- set grantees = grant_config[privilege] -%} + {%- if grantees -%} + {%- for grantee in grantees -%} + revoke {{ privilege }} on {{ relation }} from {{ grantee }}; + {% endfor -%} + {%- endif -%} + {%- endfor -%} +{%- endmacro -%} From 632940ea9f7dc000252efc6b16616867035f395e Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Thu, 7 Jul 2022 16:23:25 -0600 Subject: [PATCH 06/21] Add new environment variables to CI --- .github/workflows/integration.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index cddbc6529..c9538afb6 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -167,6 +167,9 @@ jobs: REDSHIFT_TEST_USER: ${{ secrets.REDSHIFT_TEST_USER }} REDSHIFT_TEST_PORT: ${{ secrets.REDSHIFT_TEST_PORT }} REDSHIFT_TEST_HOST: ${{ secrets.REDSHIFT_TEST_HOST }} + DBT_TEST_USER_1: ${{ secrets.DBT_TEST_USER_1 }} + DBT_TEST_USER_2: ${{ secrets.DBT_TEST_USER_2 }} + DBT_TEST_USER_3: ${{ secrets.DBT_TEST_USER_3 }} run: tox - uses: actions/upload-artifact@v2 From 0576383fb225be46d7fe3aa4683d984fdf4972cd Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Thu, 7 Jul 2022 17:11:15 -0600 Subject: [PATCH 07/21] Add new environment variables to CI --- .github/workflows/integration.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index c9538afb6..a12c4b843 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -130,6 +130,9 @@ jobs: TOXENV: integration-${{ matrix.adapter }} PYTEST_ADDOPTS: "-v --color=yes -n4 --csv integration_results.csv" DBT_INVOCATION_ENV: github-actions + DBT_TEST_USER_1: ${{ secrets.DBT_TEST_USER_1 }} + DBT_TEST_USER_2: ${{ secrets.DBT_TEST_USER_2 }} + DBT_TEST_USER_3: ${{ secrets.DBT_TEST_USER_3 }} steps: - name: Check out the repository @@ -167,9 +170,6 @@ jobs: REDSHIFT_TEST_USER: ${{ secrets.REDSHIFT_TEST_USER }} REDSHIFT_TEST_PORT: ${{ secrets.REDSHIFT_TEST_PORT }} REDSHIFT_TEST_HOST: ${{ secrets.REDSHIFT_TEST_HOST }} - DBT_TEST_USER_1: ${{ secrets.DBT_TEST_USER_1 }} - DBT_TEST_USER_2: ${{ secrets.DBT_TEST_USER_2 }} - DBT_TEST_USER_3: ${{ secrets.DBT_TEST_USER_3 }} run: tox - uses: actions/upload-artifact@v2 From af06c4ac080797790fd944195b76bbae20a981c0 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Thu, 7 Jul 2022 18:02:05 -0600 Subject: [PATCH 08/21] Try hard-coded user names --- .github/workflows/integration.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index a12c4b843..160d58846 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -130,9 +130,9 @@ jobs: TOXENV: integration-${{ matrix.adapter }} PYTEST_ADDOPTS: "-v --color=yes -n4 --csv integration_results.csv" DBT_INVOCATION_ENV: github-actions - DBT_TEST_USER_1: ${{ secrets.DBT_TEST_USER_1 }} - DBT_TEST_USER_2: ${{ secrets.DBT_TEST_USER_2 }} - DBT_TEST_USER_3: ${{ secrets.DBT_TEST_USER_3 }} + DBT_TEST_USER_1: dbt_test_user_1 + DBT_TEST_USER_2: dbt_test_user_2 + DBT_TEST_USER_3: dbt_test_user_3 steps: - name: Check out the repository From 99a290b816b829d10642d877a1b973b6b3a6d9b2 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Thu, 7 Jul 2022 19:56:14 -0600 Subject: [PATCH 09/21] Remove adapter-specific implementation of `get_revoke_sql` --- .../redshift/macros/adapters/apply_grants.sql | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/dbt/include/redshift/macros/adapters/apply_grants.sql b/dbt/include/redshift/macros/adapters/apply_grants.sql index e279ec129..ac7b793ed 100644 --- a/dbt/include/redshift/macros/adapters/apply_grants.sql +++ b/dbt/include/redshift/macros/adapters/apply_grants.sql @@ -23,15 +23,3 @@ cross join privileges p where has_table_privilege(u.usename, '{{ relation }}', privilege_type) {% endmacro %} - - -{% macro redshift__get_revoke_sql(relation, grant_config) %} - {%- for privilege in grant_config.keys() -%} - {%- set grantees = grant_config[privilege] -%} - {%- if grantees -%} - {%- for grantee in grantees -%} - revoke {{ privilege }} on {{ relation }} from {{ grantee }}; - {% endfor -%} - {%- endif -%} - {%- endfor -%} -{%- endmacro -%} From 964edecd56bc6be1477b97d10aa7b7cbfb100740 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Thu, 7 Jul 2022 19:56:57 -0600 Subject: [PATCH 10/21] Covert hard-code env vars to pull from GitHub secrets instead --- .github/workflows/integration.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 160d58846..c9538afb6 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -130,9 +130,6 @@ jobs: TOXENV: integration-${{ matrix.adapter }} PYTEST_ADDOPTS: "-v --color=yes -n4 --csv integration_results.csv" DBT_INVOCATION_ENV: github-actions - DBT_TEST_USER_1: dbt_test_user_1 - DBT_TEST_USER_2: dbt_test_user_2 - DBT_TEST_USER_3: dbt_test_user_3 steps: - name: Check out the repository @@ -170,6 +167,9 @@ jobs: REDSHIFT_TEST_USER: ${{ secrets.REDSHIFT_TEST_USER }} REDSHIFT_TEST_PORT: ${{ secrets.REDSHIFT_TEST_PORT }} REDSHIFT_TEST_HOST: ${{ secrets.REDSHIFT_TEST_HOST }} + DBT_TEST_USER_1: ${{ secrets.DBT_TEST_USER_1 }} + DBT_TEST_USER_2: ${{ secrets.DBT_TEST_USER_2 }} + DBT_TEST_USER_3: ${{ secrets.DBT_TEST_USER_3 }} run: tox - uses: actions/upload-artifact@v2 From 8dc15133d0383e5bf609723786498ed653f4b8d9 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Fri, 8 Jul 2022 06:09:59 -0600 Subject: [PATCH 11/21] Plain text rather than repo secrets --- .github/workflows/integration.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index c9538afb6..3d827e983 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -167,9 +167,9 @@ jobs: REDSHIFT_TEST_USER: ${{ secrets.REDSHIFT_TEST_USER }} REDSHIFT_TEST_PORT: ${{ secrets.REDSHIFT_TEST_PORT }} REDSHIFT_TEST_HOST: ${{ secrets.REDSHIFT_TEST_HOST }} - DBT_TEST_USER_1: ${{ secrets.DBT_TEST_USER_1 }} - DBT_TEST_USER_2: ${{ secrets.DBT_TEST_USER_2 }} - DBT_TEST_USER_3: ${{ secrets.DBT_TEST_USER_3 }} + DBT_TEST_USER_1: dbt_test_user_1 + DBT_TEST_USER_2: dbt_test_user_2 + DBT_TEST_USER_3: dbt_test_user_3 run: tox - uses: actions/upload-artifact@v2 From d3c0495807f466b820fc52af6804fc9f989bb376 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Fri, 8 Jul 2022 06:25:12 -0600 Subject: [PATCH 12/21] Filter out grants to the current user --- dbt/include/redshift/macros/adapters/apply_grants.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/dbt/include/redshift/macros/adapters/apply_grants.sql b/dbt/include/redshift/macros/adapters/apply_grants.sql index ac7b793ed..266c69af8 100644 --- a/dbt/include/redshift/macros/adapters/apply_grants.sql +++ b/dbt/include/redshift/macros/adapters/apply_grants.sql @@ -21,5 +21,6 @@ select from pg_user u cross join privileges p where has_table_privilege(u.usename, '{{ relation }}', privilege_type) +and u.usename != current_user {% endmacro %} From af971988b9e24c1f2fe4f9c08d1481396e969638 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Fri, 8 Jul 2022 09:54:47 -0600 Subject: [PATCH 13/21] Switch to branch with more tests [skip ci] --- dev-requirements.txt | 6 +++--- tests/functional/adapter/test_grants.py | 25 +++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index df50b4ff6..9b733369d 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,8 +1,8 @@ # install latest changes in dbt-core + dbt-postgres # TODO: how to switch from HEAD to x.y.latest branches after minor releases? -git+https://github.com/dbt-labs/dbt-core.git@ct-660-grant-sql#egg=dbt-core&subdirectory=core -git+https://github.com/dbt-labs/dbt-core.git@ct-660-grant-sql#egg=dbt-tests-adapter&subdirectory=tests/adapter -git+https://github.com/dbt-labs/dbt-core.git@ct-660-grant-sql#egg=dbt-postgres&subdirectory=plugins/postgres +git+https://github.com/dbt-labs/dbt-core.git@ct-808-more_grant_adapter_tests#egg=dbt-core&subdirectory=core +git+https://github.com/dbt-labs/dbt-core.git@ct-808-more_grant_adapter_tests#egg=dbt-tests-adapter&subdirectory=tests/adapter +git+https://github.com/dbt-labs/dbt-core.git@ct-808-more_grant_adapter_tests#egg=dbt-postgres&subdirectory=plugins/postgres black==22.3.0 click~=8.0.4 diff --git a/tests/functional/adapter/test_grants.py b/tests/functional/adapter/test_grants.py index fdf5234e5..bbad59f96 100644 --- a/tests/functional/adapter/test_grants.py +++ b/tests/functional/adapter/test_grants.py @@ -1,5 +1,26 @@ -from dbt.tests.adapter.grants.test_models import TestModelGrants +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(TestModelGrants): +class TestModelGrantsRedshift(BaseModelGrants): + pass + + +class TestIncrementalGrantsRedshift(BaseIncrementalGrants): + pass + + +class TestSeedGrantsRedshift(BaseSeedGrants): + pass + + +class TestSnapshotGrantsRedshift(BaseSnapshotGrants): + pass + + +class TestInvalidGrantsRedshift(BaseModelGrants): pass From efb4e990bdfbabda422ec6c06eed5761146151b6 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Fri, 8 Jul 2022 12:14:51 -0600 Subject: [PATCH 14/21] Ignore super users --- dbt/include/redshift/macros/adapters/apply_grants.sql | 3 ++- tests/functional/adapter/test_grants.py | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dbt/include/redshift/macros/adapters/apply_grants.sql b/dbt/include/redshift/macros/adapters/apply_grants.sql index 266c69af8..fa6523a26 100644 --- a/dbt/include/redshift/macros/adapters/apply_grants.sql +++ b/dbt/include/redshift/macros/adapters/apply_grants.sql @@ -21,6 +21,7 @@ select from pg_user u cross join privileges p where has_table_privilege(u.usename, '{{ relation }}', privilege_type) -and u.usename != current_user + and u.usename != current_user + and not u.usesuper {% endmacro %} diff --git a/tests/functional/adapter/test_grants.py b/tests/functional/adapter/test_grants.py index bbad59f96..915a7b71d 100644 --- a/tests/functional/adapter/test_grants.py +++ b/tests/functional/adapter/test_grants.py @@ -14,12 +14,12 @@ class TestIncrementalGrantsRedshift(BaseIncrementalGrants): pass -class TestSeedGrantsRedshift(BaseSeedGrants): - pass +# class TestSeedGrantsRedshift(BaseSeedGrants): +# pass -class TestSnapshotGrantsRedshift(BaseSnapshotGrants): - pass +# class TestSnapshotGrantsRedshift(BaseSnapshotGrants): +# pass class TestInvalidGrantsRedshift(BaseModelGrants): From c6c52532a46f5eb69b321b99b46e78875fdf228b Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Fri, 8 Jul 2022 17:23:01 -0600 Subject: [PATCH 15/21] Replace untyped constant with an explicit typed constant --- tests/functional/adapter/test_grants.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/tests/functional/adapter/test_grants.py b/tests/functional/adapter/test_grants.py index 915a7b71d..b236fcb33 100644 --- a/tests/functional/adapter/test_grants.py +++ b/tests/functional/adapter/test_grants.py @@ -3,7 +3,18 @@ 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 +from dbt.tests.adapter.grants.test_snapshot_grants import BaseSnapshotGrants, snapshot_schema_yml + + +my_snapshot_sql = """ +{% snapshot my_snapshot %} + {{ config( + check_cols='all', unique_key='id', strategy='check', + target_database=database, target_schema=schema + ) }} + select 1 as id, cast('blue' as {{ type_string() }}) as color +{% endsnapshot %} +""".strip() class TestModelGrantsRedshift(BaseModelGrants): @@ -14,12 +25,16 @@ class TestIncrementalGrantsRedshift(BaseIncrementalGrants): pass -# class TestSeedGrantsRedshift(BaseSeedGrants): -# pass +class TestSeedGrantsRedshift(BaseSeedGrants): + pass -# class TestSnapshotGrantsRedshift(BaseSnapshotGrants): -# pass +class TestSnapshotGrantsRedshift(BaseSnapshotGrants): + pass + + @pytest.fixture(scope="class") + def snapshots(self): + return {"my_snapshot.sql": my_snapshot_sql, "schema.yml": snapshot_schema_yml} class TestInvalidGrantsRedshift(BaseModelGrants): From 7f176a6d4f2ba015c64f83ef1d01119df9f16e8f Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Fri, 8 Jul 2022 17:40:33 -0600 Subject: [PATCH 16/21] Remove extraneous `pass` --- tests/functional/adapter/test_grants.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/functional/adapter/test_grants.py b/tests/functional/adapter/test_grants.py index b236fcb33..337bc87a6 100644 --- a/tests/functional/adapter/test_grants.py +++ b/tests/functional/adapter/test_grants.py @@ -30,8 +30,6 @@ class TestSeedGrantsRedshift(BaseSeedGrants): class TestSnapshotGrantsRedshift(BaseSnapshotGrants): - pass - @pytest.fixture(scope="class") def snapshots(self): return {"my_snapshot.sql": my_snapshot_sql, "schema.yml": snapshot_schema_yml} From bae99ca393e0db3a967206f0244342e4e5f5955a Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Sun, 10 Jul 2022 19:16:19 -0600 Subject: [PATCH 17/21] Update CHANGELOG [skip ci] --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ff25250b..7d182b0d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## dbt-redshift next + +### Features +- Add grants to materializations ([#128](https://github.com/dbt-labs/dbt-redshift/issues/128), [#131](https://github.com/dbt-labs/dbt-redshift/pull/131)) + ## dbt-redshift 1.2.0b1 (June 24, 2022) ### Under the hood From bd7e23a3d90f436aa0a19ac2e9058566ab8ceef2 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Sun, 10 Jul 2022 19:22:13 -0600 Subject: [PATCH 18/21] Fix CHANGELOG [skip ci] --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d182b0d5..560b42a8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,16 +6,16 @@ ## dbt-redshift 1.2.0b1 (June 24, 2022) ### Under the hood -- Lift + shift for cross-db macros ([#120](https://github.com/dbt-labs/dbt-snowflake/pull/120)) -- Rm duplicated parts of unit test ([#100](https://github.com/dbt-labs/dbt-snowflake/pull/100)) +- Lift + shift for cross-db macros ([#120](https://github.com/dbt-labs/dbt-redshift/pull/120)) +- Remove duplicated parts of unit test ([#100](https://github.com/dbt-labs/dbt-redshift/pull/100)) ### Contributors -- [@dbeatty10](https://github.com/dbeatty10) ([#120](https://github.com/dbt-labs/dbt-snowflake/pull/120)) +- [@dbeatty10](https://github.com/dbeatty10) ([#120](https://github.com/dbt-labs/dbt-redshift/pull/120)) ## dbt-redshift 1.1.0 (April 28, 2022) ### Under the hood -- Add precommits for this repo ([#XX](https://github.com/dbt-labs/dbt-snowflake/pull/XX)) +- Add precommits for this repo ([#72](https://github.com/dbt-labs/dbt-redshift/issues/72), [#106](https://github.com/dbt-labs/dbt-redshift/pull/106)) ## dbt-redshift 1.0.1 (April 19, 2022) From eaa680a70e83a6461d14c2dcb7e504db5c5b52b1 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Mon, 11 Jul 2022 07:53:51 -0600 Subject: [PATCH 19/21] Inherit default tests --- tests/functional/adapter/test_grants.py | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/tests/functional/adapter/test_grants.py b/tests/functional/adapter/test_grants.py index 337bc87a6..bbad59f96 100644 --- a/tests/functional/adapter/test_grants.py +++ b/tests/functional/adapter/test_grants.py @@ -3,18 +3,7 @@ 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, snapshot_schema_yml - - -my_snapshot_sql = """ -{% snapshot my_snapshot %} - {{ config( - check_cols='all', unique_key='id', strategy='check', - target_database=database, target_schema=schema - ) }} - select 1 as id, cast('blue' as {{ type_string() }}) as color -{% endsnapshot %} -""".strip() +from dbt.tests.adapter.grants.test_snapshot_grants import BaseSnapshotGrants class TestModelGrantsRedshift(BaseModelGrants): @@ -30,9 +19,7 @@ class TestSeedGrantsRedshift(BaseSeedGrants): class TestSnapshotGrantsRedshift(BaseSnapshotGrants): - @pytest.fixture(scope="class") - def snapshots(self): - return {"my_snapshot.sql": my_snapshot_sql, "schema.yml": snapshot_schema_yml} + pass class TestInvalidGrantsRedshift(BaseModelGrants): From d6580fdb4b0df8904031e51493f440a956d25c77 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Mon, 11 Jul 2022 10:30:42 -0600 Subject: [PATCH 20/21] Update development branch --- dev-requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 9b733369d..df50b4ff6 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,8 +1,8 @@ # install latest changes in dbt-core + dbt-postgres # TODO: how to switch from HEAD to x.y.latest branches after minor releases? -git+https://github.com/dbt-labs/dbt-core.git@ct-808-more_grant_adapter_tests#egg=dbt-core&subdirectory=core -git+https://github.com/dbt-labs/dbt-core.git@ct-808-more_grant_adapter_tests#egg=dbt-tests-adapter&subdirectory=tests/adapter -git+https://github.com/dbt-labs/dbt-core.git@ct-808-more_grant_adapter_tests#egg=dbt-postgres&subdirectory=plugins/postgres +git+https://github.com/dbt-labs/dbt-core.git@ct-660-grant-sql#egg=dbt-core&subdirectory=core +git+https://github.com/dbt-labs/dbt-core.git@ct-660-grant-sql#egg=dbt-tests-adapter&subdirectory=tests/adapter +git+https://github.com/dbt-labs/dbt-core.git@ct-660-grant-sql#egg=dbt-postgres&subdirectory=plugins/postgres black==22.3.0 click~=8.0.4 From 84e06b6b1cf332be5d52c47f08a071c7abcefbe8 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Mon, 11 Jul 2022 11:18:59 -0600 Subject: [PATCH 21/21] Point back to main branch for dbt-core --- dev-requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index df50b4ff6..a63ecbcf0 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,8 +1,8 @@ # install latest changes in dbt-core + dbt-postgres # TODO: how to switch from HEAD to x.y.latest branches after minor releases? -git+https://github.com/dbt-labs/dbt-core.git@ct-660-grant-sql#egg=dbt-core&subdirectory=core -git+https://github.com/dbt-labs/dbt-core.git@ct-660-grant-sql#egg=dbt-tests-adapter&subdirectory=tests/adapter -git+https://github.com/dbt-labs/dbt-core.git@ct-660-grant-sql#egg=dbt-postgres&subdirectory=plugins/postgres +git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core +git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-tests-adapter&subdirectory=tests/adapter +git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-postgres&subdirectory=plugins/postgres black==22.3.0 click~=8.0.4