From 473712fa46cdf7923c719de9979ef2b3b07cfcf7 Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Mon, 27 Jun 2022 11:10:25 -0500 Subject: [PATCH 01/24] minor update --- dbt/include/snowflake/macros/adapters.sql | 1 + dbt/include/snowflake/macros/materializations/incremental.sql | 3 +++ dbt/include/snowflake/macros/materializations/seed.sql | 2 ++ dbt/include/snowflake/macros/materializations/snapshot.sql | 3 ++- dbt/include/snowflake/macros/materializations/table.sql | 4 ++++ dbt/include/snowflake/macros/materializations/view.sql | 3 +++ dev-requirements.txt | 1 + 7 files changed, 16 insertions(+), 1 deletion(-) diff --git a/dbt/include/snowflake/macros/adapters.sql b/dbt/include/snowflake/macros/adapters.sql index f89957896..1c48a74b4 100644 --- a/dbt/include/snowflake/macros/adapters.sql +++ b/dbt/include/snowflake/macros/adapters.sql @@ -284,3 +284,4 @@ {{ snowflake_dml_explicit_transaction(truncate_dml) }} {%- endcall %} {% endmacro %} + diff --git a/dbt/include/snowflake/macros/materializations/incremental.sql b/dbt/include/snowflake/macros/materializations/incremental.sql index 5710284f3..24a8f69ae 100644 --- a/dbt/include/snowflake/macros/materializations/incremental.sql +++ b/dbt/include/snowflake/macros/materializations/incremental.sql @@ -35,6 +35,8 @@ {% set existing_relation = load_relation(this) %} {% set tmp_relation = make_temp_relation(this) %} + {% set grant_config = config.get('grants') %} + {#-- Validate early so we don't run SQL if the strategy is invalid --#} {% set strategy = dbt_snowflake_validate_get_incremental_strategy(config) -%} {% set on_schema_change = incremental_validate_on_schema_change(config.get('on_schema_change'), default='ignore') %} @@ -74,6 +76,7 @@ {{ run_hooks(post_hooks) }} {% set target_relation = target_relation.incorporate(type='table') %} + {% do apply_grants(relation, grant_config, should_revoke=True) %} {% do persist_docs(target_relation, model) %} {% do unset_query_tag(original_query_tag) %} diff --git a/dbt/include/snowflake/macros/materializations/seed.sql b/dbt/include/snowflake/macros/materializations/seed.sql index 66c7348a9..1a8e8c4d6 100644 --- a/dbt/include/snowflake/macros/materializations/seed.sql +++ b/dbt/include/snowflake/macros/materializations/seed.sql @@ -38,9 +38,11 @@ {% materialization seed, adapter='snowflake' %} {% set original_query_tag = set_query_tag() %} + {% set grant_config = config.get('grants') %} {% set relations = materialization_seed_default() %} + {% do apply_grants(relation, grant_config, should_revoke=True) %} {% do unset_query_tag(original_query_tag) %} {{ return(relations) }} diff --git a/dbt/include/snowflake/macros/materializations/snapshot.sql b/dbt/include/snowflake/macros/materializations/snapshot.sql index c115229cd..5c887003e 100644 --- a/dbt/include/snowflake/macros/materializations/snapshot.sql +++ b/dbt/include/snowflake/macros/materializations/snapshot.sql @@ -1,8 +1,9 @@ {% materialization snapshot, adapter='snowflake' %} {% set original_query_tag = set_query_tag() %} + {% set grant_config = config.get('grants') %} {% set relations = materialization_snapshot_default() %} - + {% do apply_grants(relation, grant_config, should_revoke=True) %} {% do unset_query_tag(original_query_tag) %} {{ return(relations) }} diff --git a/dbt/include/snowflake/macros/materializations/table.sql b/dbt/include/snowflake/macros/materializations/table.sql index 49f97069b..3ee77208a 100644 --- a/dbt/include/snowflake/macros/materializations/table.sql +++ b/dbt/include/snowflake/macros/materializations/table.sql @@ -4,6 +4,8 @@ {%- set identifier = model['alias'] -%} + {% set grant_config = config.get('grants') %} + {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%} {%- set target_relation = api.Relation.create(identifier=identifier, schema=schema, @@ -25,6 +27,8 @@ {{ run_hooks(post_hooks) }} + {% do apply_grants(relation, grant_config, should_revoke=False) %} + {% do persist_docs(target_relation, model) %} {% do unset_query_tag(original_query_tag) %} diff --git a/dbt/include/snowflake/macros/materializations/view.sql b/dbt/include/snowflake/macros/materializations/view.sql index b3858c674..80101561b 100644 --- a/dbt/include/snowflake/macros/materializations/view.sql +++ b/dbt/include/snowflake/macros/materializations/view.sql @@ -2,8 +2,11 @@ {% set original_query_tag = set_query_tag() %} {% set to_return = create_or_replace_view() %} + {% set grant_config = config.get('grants') %} {% set target_relation = this.incorporate(type='view') %} + + {% do apply_grants(relation, grant_config, should_revoke=False) %} {% do persist_docs(target_relation, model, for_columns=false) %} {% do return(to_return) %} diff --git a/dev-requirements.txt b/dev-requirements.txt index 6711f16df..55eaa44b3 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -3,6 +3,7 @@ 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 + black==22.3.0 click~=8.0.4 bumpversion From f847ff6632f110f30298ead00325de6aab33264d Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Mon, 27 Jun 2022 17:02:54 -0500 Subject: [PATCH 02/24] 6/27 eod update --- dbt/include/snowflake/macros/adapters.sql | 1 - dbt/include/snowflake/macros/materializations/incremental.sql | 2 +- dbt/include/snowflake/macros/materializations/snapshot.sql | 2 +- dbt/include/snowflake/macros/materializations/table.sql | 2 +- dbt/include/snowflake/macros/materializations/view.sql | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/dbt/include/snowflake/macros/adapters.sql b/dbt/include/snowflake/macros/adapters.sql index 1c48a74b4..f89957896 100644 --- a/dbt/include/snowflake/macros/adapters.sql +++ b/dbt/include/snowflake/macros/adapters.sql @@ -284,4 +284,3 @@ {{ snowflake_dml_explicit_transaction(truncate_dml) }} {%- endcall %} {% endmacro %} - diff --git a/dbt/include/snowflake/macros/materializations/incremental.sql b/dbt/include/snowflake/macros/materializations/incremental.sql index 24a8f69ae..d53b4dffe 100644 --- a/dbt/include/snowflake/macros/materializations/incremental.sql +++ b/dbt/include/snowflake/macros/materializations/incremental.sql @@ -76,7 +76,7 @@ {{ run_hooks(post_hooks) }} {% set target_relation = target_relation.incorporate(type='table') %} - {% do apply_grants(relation, grant_config, should_revoke=True) %} + {% do apply_grants(target_relation, grant_config, should_revoke=True) %} {% do persist_docs(target_relation, model) %} {% do unset_query_tag(original_query_tag) %} diff --git a/dbt/include/snowflake/macros/materializations/snapshot.sql b/dbt/include/snowflake/macros/materializations/snapshot.sql index 5c887003e..0867c8098 100644 --- a/dbt/include/snowflake/macros/materializations/snapshot.sql +++ b/dbt/include/snowflake/macros/materializations/snapshot.sql @@ -3,7 +3,7 @@ {% set grant_config = config.get('grants') %} {% set relations = materialization_snapshot_default() %} - {% do apply_grants(relation, grant_config, should_revoke=True) %} + {% do apply_grants(target_relation, grant_config, should_revoke=True) %} {% do unset_query_tag(original_query_tag) %} {{ return(relations) }} diff --git a/dbt/include/snowflake/macros/materializations/table.sql b/dbt/include/snowflake/macros/materializations/table.sql index 3ee77208a..f8ce0af0d 100644 --- a/dbt/include/snowflake/macros/materializations/table.sql +++ b/dbt/include/snowflake/macros/materializations/table.sql @@ -27,7 +27,7 @@ {{ run_hooks(post_hooks) }} - {% do apply_grants(relation, grant_config, should_revoke=False) %} + {% do apply_grants(target_relation, grant_config, should_revoke=True) %} {% do persist_docs(target_relation, model) %} diff --git a/dbt/include/snowflake/macros/materializations/view.sql b/dbt/include/snowflake/macros/materializations/view.sql index 80101561b..e4d530763 100644 --- a/dbt/include/snowflake/macros/materializations/view.sql +++ b/dbt/include/snowflake/macros/materializations/view.sql @@ -6,7 +6,7 @@ {% set target_relation = this.incorporate(type='view') %} - {% do apply_grants(relation, grant_config, should_revoke=False) %} + {% do apply_grants(target_relation, grant_config, should_revoke=False) %} {% do persist_docs(target_relation, model, for_columns=false) %} {% do return(to_return) %} From ebaff10c3c11ce68b7652873777f6b7965f2cbd5 Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Wed, 29 Jun 2022 16:41:11 -0500 Subject: [PATCH 03/24] adding standardize_grants_dict for snowlfake --- dbt/adapters/snowflake/impl.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dbt/adapters/snowflake/impl.py b/dbt/adapters/snowflake/impl.py index f2af32795..d5603ecd3 100644 --- a/dbt/adapters/snowflake/impl.py +++ b/dbt/adapters/snowflake/impl.py @@ -9,6 +9,7 @@ LIST_SCHEMAS_MACRO_NAME, LIST_RELATIONS_MACRO_NAME, ) +from dbt.adapters.base.meta import available from dbt.adapters.snowflake import SnowflakeConnectionManager from dbt.adapters.snowflake import SnowflakeRelation from dbt.adapters.snowflake import SnowflakeColumn @@ -86,6 +87,7 @@ def post_model_hook(self, config: Mapping[str, Any], context: Optional[str]) -> if context is not None: self._use_warehouse(context) + def list_schemas(self, database: str) -> List[str]: try: results = self.execute_macro(LIST_SCHEMAS_MACRO_NAME, kwargs={"database": database}) @@ -158,5 +160,17 @@ def quote_seed_column(self, column: str, quote_config: Optional[bool]) -> str: else: return column + @available + def standardize_grants_dict(self, grants_table: agate.Table) -> dict: + grants_dict = {} + for row in grants_table: + grantee = row['grantee_name'].lower() + privilege = row['privilege'].lower() + if privilege in grants_dict.keys(): + grants_dict[privilege].append(grantee) + else: + grants_dict.update({privilege: [grantee]}) + return grants_dict + def timestamp_add_sql(self, add_to: str, number: int = 1, interval: str = "hour") -> str: return f"DATEADD({interval}, {number}, {add_to})" From 31fdaeb7b034887040f2c9c0fd0f2786a67ea138 Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Tue, 5 Jul 2022 16:17:53 -0500 Subject: [PATCH 04/24] models are building but never seeing revoke statements --- dbt/adapters/snowflake/impl.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dbt/adapters/snowflake/impl.py b/dbt/adapters/snowflake/impl.py index d5603ecd3..aa7153709 100644 --- a/dbt/adapters/snowflake/impl.py +++ b/dbt/adapters/snowflake/impl.py @@ -163,13 +163,15 @@ def quote_seed_column(self, column: str, quote_config: Optional[bool]) -> str: @available def standardize_grants_dict(self, grants_table: agate.Table) -> dict: grants_dict = {} + for row in grants_table: - grantee = row['grantee_name'].lower() - privilege = row['privilege'].lower() - if privilege in grants_dict.keys(): - grants_dict[privilege].append(grantee) - else: - grants_dict.update({privilege: [grantee]}) + grantee = row['grantee_name'] + privilege = row['privilege'] + if privilege != 'OWNERSHIP': + if privilege in grants_dict.keys(): + grants_dict[privilege].append(grantee) + else: + grants_dict.update({privilege: [grantee]}) return grants_dict def timestamp_add_sql(self, add_to: str, number: int = 1, interval: str = "hour") -> str: From aaccebfa958e7173868741565cfaa30513736f8c Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Wed, 6 Jul 2022 15:38:33 -0500 Subject: [PATCH 05/24] updating snowflake implementation of apply_grants after pairing with jeremey and doug earlier today. --- dbt/adapters/snowflake/impl.py | 17 ++++++++++++++--- dbt/include/snowflake/macros/adapters.sql | 5 +++++ .../macros/materializations/incremental.sql | 6 +++++- .../snowflake/macros/materializations/seed.sql | 2 -- .../macros/materializations/snapshot.sql | 4 +--- .../snowflake/macros/materializations/table.sql | 5 +++-- .../snowflake/macros/materializations/view.sql | 2 -- 7 files changed, 28 insertions(+), 13 deletions(-) diff --git a/dbt/adapters/snowflake/impl.py b/dbt/adapters/snowflake/impl.py index aa7153709..0598591aa 100644 --- a/dbt/adapters/snowflake/impl.py +++ b/dbt/adapters/snowflake/impl.py @@ -87,7 +87,6 @@ def post_model_hook(self, config: Mapping[str, Any], context: Optional[str]) -> if context is not None: self._use_warehouse(context) - def list_schemas(self, database: str) -> List[str]: try: results = self.execute_macro(LIST_SCHEMAS_MACRO_NAME, kwargs={"database": database}) @@ -163,11 +162,23 @@ def quote_seed_column(self, column: str, quote_config: Optional[bool]) -> str: @available def standardize_grants_dict(self, grants_table: agate.Table) -> dict: grants_dict = {} - + for row in grants_table: grantee = row['grantee_name'] privilege = row['privilege'] - if privilege != 'OWNERSHIP': + granted_by = row['granted_by'] + + # super gross, but it works + # (this is the value from profiles.yml) + current_role = self.connections.profile.credentials.role + + if( + # granted BY the current role + granted_by.lower() == current_role.lower() + and + # NOT granted TO the current role + grantee.lower() != current_role.lower() + ): if privilege in grants_dict.keys(): grants_dict[privilege].append(grantee) else: diff --git a/dbt/include/snowflake/macros/adapters.sql b/dbt/include/snowflake/macros/adapters.sql index f89957896..031a88491 100644 --- a/dbt/include/snowflake/macros/adapters.sql +++ b/dbt/include/snowflake/macros/adapters.sql @@ -284,3 +284,8 @@ {{ snowflake_dml_explicit_transaction(truncate_dml) }} {%- endcall %} {% endmacro %} + +{% macro snowflake__are_grants_copied_over_when_replaced() %} + {% set copy_grants = config.get('copy_grants', False) %} + {{ return(copy_grants) }} +{% endmacro %} \ No newline at end of file diff --git a/dbt/include/snowflake/macros/materializations/incremental.sql b/dbt/include/snowflake/macros/materializations/incremental.sql index d53b4dffe..fe96e5275 100644 --- a/dbt/include/snowflake/macros/materializations/incremental.sql +++ b/dbt/include/snowflake/macros/materializations/incremental.sql @@ -76,7 +76,11 @@ {{ run_hooks(post_hooks) }} {% set target_relation = target_relation.incorporate(type='table') %} - {% do apply_grants(target_relation, grant_config, should_revoke=True) %} + + {% set should_revoke = + do_we_need_to_show_and_revoke_grants(existing_relation.is_table, full_refresh_mode) %} + {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %} + {% do persist_docs(target_relation, model) %} {% do unset_query_tag(original_query_tag) %} diff --git a/dbt/include/snowflake/macros/materializations/seed.sql b/dbt/include/snowflake/macros/materializations/seed.sql index 1a8e8c4d6..66c7348a9 100644 --- a/dbt/include/snowflake/macros/materializations/seed.sql +++ b/dbt/include/snowflake/macros/materializations/seed.sql @@ -38,11 +38,9 @@ {% materialization seed, adapter='snowflake' %} {% set original_query_tag = set_query_tag() %} - {% set grant_config = config.get('grants') %} {% set relations = materialization_seed_default() %} - {% do apply_grants(relation, grant_config, should_revoke=True) %} {% do unset_query_tag(original_query_tag) %} {{ return(relations) }} diff --git a/dbt/include/snowflake/macros/materializations/snapshot.sql b/dbt/include/snowflake/macros/materializations/snapshot.sql index 0867c8098..ccc1bc129 100644 --- a/dbt/include/snowflake/macros/materializations/snapshot.sql +++ b/dbt/include/snowflake/macros/materializations/snapshot.sql @@ -1,9 +1,7 @@ {% materialization snapshot, adapter='snowflake' %} {% set original_query_tag = set_query_tag() %} - {% set grant_config = config.get('grants') %} - {% set relations = materialization_snapshot_default() %} - {% do apply_grants(target_relation, grant_config, should_revoke=True) %} + {% do unset_query_tag(original_query_tag) %} {{ return(relations) }} diff --git a/dbt/include/snowflake/macros/materializations/table.sql b/dbt/include/snowflake/macros/materializations/table.sql index f8ce0af0d..0c1760d5f 100644 --- a/dbt/include/snowflake/macros/materializations/table.sql +++ b/dbt/include/snowflake/macros/materializations/table.sql @@ -4,7 +4,7 @@ {%- set identifier = model['alias'] -%} - {% set grant_config = config.get('grants') %} + {% set grant_config = config.get('grants') %} {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%} {%- set target_relation = api.Relation.create(identifier=identifier, @@ -27,7 +27,8 @@ {{ run_hooks(post_hooks) }} - {% do apply_grants(target_relation, grant_config, should_revoke=True) %} + {% set should_revoke = do_we_need_to_show_and_revoke_grants(old_relation, full_refresh_mode=True) %} + {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %} {% do persist_docs(target_relation, model) %} diff --git a/dbt/include/snowflake/macros/materializations/view.sql b/dbt/include/snowflake/macros/materializations/view.sql index e4d530763..90535f365 100644 --- a/dbt/include/snowflake/macros/materializations/view.sql +++ b/dbt/include/snowflake/macros/materializations/view.sql @@ -2,11 +2,9 @@ {% set original_query_tag = set_query_tag() %} {% set to_return = create_or_replace_view() %} - {% set grant_config = config.get('grants') %} {% set target_relation = this.incorporate(type='view') %} - {% do apply_grants(target_relation, grant_config, should_revoke=False) %} {% do persist_docs(target_relation, model, for_columns=false) %} {% do return(to_return) %} From 33d6c3764768ddf387789a55f6ffa4a1d3cd92e5 Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Thu, 7 Jul 2022 11:09:59 -0500 Subject: [PATCH 06/24] post morning feedback updates --- dbt/adapters/snowflake/impl.py | 15 ++++++++++++--- dbt/include/snowflake/macros/adapters.sql | 2 +- .../macros/materializations/incremental.sql | 2 +- .../snowflake/macros/materializations/table.sql | 2 +- dev-requirements.txt | 4 ++-- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/dbt/adapters/snowflake/impl.py b/dbt/adapters/snowflake/impl.py index 0598591aa..f7f935dbd 100644 --- a/dbt/adapters/snowflake/impl.py +++ b/dbt/adapters/snowflake/impl.py @@ -74,6 +74,16 @@ def _use_warehouse(self, warehouse: str): """Use the given warehouse. Quotes are never applied.""" self.execute("use warehouse {}".format(warehouse)) + def _get_role(self) -> str: + configured_role = self.connections.profile.credentials.role + if configured_role: + return configured_role + else: + _, table = self.execute("select current_role() as warehouse", fetch=True) + if len(table) == 0 or len(table[0]) == 0: + raise RuntimeException("Could not get current role: no results") + return str(table[0][0]) + def pre_model_hook(self, config: Mapping[str, Any]) -> Optional[str]: default_warehouse = self.config.credentials.warehouse warehouse = config.get("snowflake_warehouse", default_warehouse) @@ -168,9 +178,8 @@ def standardize_grants_dict(self, grants_table: agate.Table) -> dict: privilege = row['privilege'] granted_by = row['granted_by'] - # super gross, but it works - # (this is the value from profiles.yml) - current_role = self.connections.profile.credentials.role + current_role = self._get_role() + breakpoint() if( # granted BY the current role diff --git a/dbt/include/snowflake/macros/adapters.sql b/dbt/include/snowflake/macros/adapters.sql index f5f202644..40ec24ae2 100644 --- a/dbt/include/snowflake/macros/adapters.sql +++ b/dbt/include/snowflake/macros/adapters.sql @@ -294,7 +294,7 @@ {%- endcall %} {% endmacro %} -{% macro snowflake__are_grants_copied_over_when_replaced() %} +{% macro snowflake__copy_grants() %} {% set copy_grants = config.get('copy_grants', False) %} {{ return(copy_grants) }} {% endmacro %} \ No newline at end of file diff --git a/dbt/include/snowflake/macros/materializations/incremental.sql b/dbt/include/snowflake/macros/materializations/incremental.sql index fe96e5275..fc3bc34fa 100644 --- a/dbt/include/snowflake/macros/materializations/incremental.sql +++ b/dbt/include/snowflake/macros/materializations/incremental.sql @@ -78,7 +78,7 @@ {% set target_relation = target_relation.incorporate(type='table') %} {% set should_revoke = - do_we_need_to_show_and_revoke_grants(existing_relation.is_table, full_refresh_mode) %} + should_revoke(existing_relation.is_table, full_refresh_mode) %} {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %} {% do persist_docs(target_relation, model) %} diff --git a/dbt/include/snowflake/macros/materializations/table.sql b/dbt/include/snowflake/macros/materializations/table.sql index 0c1760d5f..b1a6739c4 100644 --- a/dbt/include/snowflake/macros/materializations/table.sql +++ b/dbt/include/snowflake/macros/materializations/table.sql @@ -27,7 +27,7 @@ {{ run_hooks(post_hooks) }} - {% set should_revoke = do_we_need_to_show_and_revoke_grants(old_relation, full_refresh_mode=True) %} + {% set should_revoke = should_revoke(old_relation, full_refresh_mode=True) %} {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %} {% do persist_docs(target_relation, model) %} diff --git a/dev-requirements.txt b/dev-requirements.txt index 55eaa44b3..b7f419cd7 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,7 +1,7 @@ # install latest changes in dbt-core # TODO: how to automate switching from develop to version branches? -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@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 black==22.3.0 From 09c523897b00c32ece5be713fc2496f65737107f Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Thu, 7 Jul 2022 14:37:35 -0500 Subject: [PATCH 07/24] remove _get_role and revert to filter based on OWNERSHIP --- dbt/adapters/snowflake/impl.py | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/dbt/adapters/snowflake/impl.py b/dbt/adapters/snowflake/impl.py index f7f935dbd..9ea6726c2 100644 --- a/dbt/adapters/snowflake/impl.py +++ b/dbt/adapters/snowflake/impl.py @@ -74,16 +74,6 @@ def _use_warehouse(self, warehouse: str): """Use the given warehouse. Quotes are never applied.""" self.execute("use warehouse {}".format(warehouse)) - def _get_role(self) -> str: - configured_role = self.connections.profile.credentials.role - if configured_role: - return configured_role - else: - _, table = self.execute("select current_role() as warehouse", fetch=True) - if len(table) == 0 or len(table[0]) == 0: - raise RuntimeException("Could not get current role: no results") - return str(table[0][0]) - def pre_model_hook(self, config: Mapping[str, Any]) -> Optional[str]: default_warehouse = self.config.credentials.warehouse warehouse = config.get("snowflake_warehouse", default_warehouse) @@ -176,18 +166,7 @@ def standardize_grants_dict(self, grants_table: agate.Table) -> dict: for row in grants_table: grantee = row['grantee_name'] privilege = row['privilege'] - granted_by = row['granted_by'] - - current_role = self._get_role() - breakpoint() - - if( - # granted BY the current role - granted_by.lower() == current_role.lower() - and - # NOT granted TO the current role - grantee.lower() != current_role.lower() - ): + if privilege != 'OWNERSHIP': if privilege in grants_dict.keys(): grants_dict[privilege].append(grantee) else: From d613a38655b0218a571f22ca9b5c8cc0e0253e37 Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Thu, 7 Jul 2022 14:41:36 -0500 Subject: [PATCH 08/24] ping original core dev-requirements pointer and note for post mergers in core to swap back to --- dev-requirements.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dev-requirements.txt b/dev-requirements.txt index b7f419cd7..566b8dbb2 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -3,6 +3,9 @@ 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 +# TODO: revert back to main pointer after PR's 5447, and 5369 are merged into core. +# 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 black==22.3.0 click~=8.0.4 From 581e1d3b9c1ef248cfc1427f6293af83ebef3b93 Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Thu, 7 Jul 2022 15:08:42 -0500 Subject: [PATCH 09/24] typo in dev-requirements.txt --- dev-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 566b8dbb2..b894b33bc 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,6 +1,6 @@ # install latest changes in dbt-core # TODO: how to automate switching from develop to version branches? -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-core&subdirectory=core git+https://github.com/dbt-labs/dbt-core.git@ct-660-grant-sql#egg=dbt-tests-adapter&subdirectory=tests/adapter # TODO: revert back to main pointer after PR's 5447, and 5369 are merged into core. From 8bb27fc1214b4f37fdb0c4239ef7f0f15245fff3 Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Thu, 7 Jul 2022 15:13:48 -0500 Subject: [PATCH 10/24] pre-commit fixes --- dbt/adapters/snowflake/impl.py | 6 +++--- dbt/include/snowflake/macros/adapters.sql | 2 +- dbt/include/snowflake/macros/materializations/snapshot.sql | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dbt/adapters/snowflake/impl.py b/dbt/adapters/snowflake/impl.py index 9ea6726c2..3b37f2653 100644 --- a/dbt/adapters/snowflake/impl.py +++ b/dbt/adapters/snowflake/impl.py @@ -164,9 +164,9 @@ def standardize_grants_dict(self, grants_table: agate.Table) -> dict: grants_dict = {} for row in grants_table: - grantee = row['grantee_name'] - privilege = row['privilege'] - if privilege != 'OWNERSHIP': + grantee = row["grantee_name"] + privilege = row["privilege"] + if privilege != "OWNERSHIP": if privilege in grants_dict.keys(): grants_dict[privilege].append(grantee) else: diff --git a/dbt/include/snowflake/macros/adapters.sql b/dbt/include/snowflake/macros/adapters.sql index 40ec24ae2..1d6c0029b 100644 --- a/dbt/include/snowflake/macros/adapters.sql +++ b/dbt/include/snowflake/macros/adapters.sql @@ -297,4 +297,4 @@ {% macro snowflake__copy_grants() %} {% set copy_grants = config.get('copy_grants', False) %} {{ return(copy_grants) }} -{% endmacro %} \ No newline at end of file +{% endmacro %} diff --git a/dbt/include/snowflake/macros/materializations/snapshot.sql b/dbt/include/snowflake/macros/materializations/snapshot.sql index ccc1bc129..e79516ba2 100644 --- a/dbt/include/snowflake/macros/materializations/snapshot.sql +++ b/dbt/include/snowflake/macros/materializations/snapshot.sql @@ -1,7 +1,7 @@ {% materialization snapshot, adapter='snowflake' %} {% set original_query_tag = set_query_tag() %} {% set relations = materialization_snapshot_default() %} - + {% do unset_query_tag(original_query_tag) %} {{ return(relations) }} From 3e3b2f85cee14113654076c8c49fe5c4644c9b47 Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Thu, 7 Jul 2022 15:35:26 -0500 Subject: [PATCH 11/24] add test to functional tests --- tests/functional/test_grants.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 tests/functional/test_grants.py diff --git a/tests/functional/test_grants.py b/tests/functional/test_grants.py new file mode 100644 index 000000000..34136b400 --- /dev/null +++ b/tests/functional/test_grants.py @@ -0,0 +1,5 @@ +import pytest +from dbt.tests.adapter.dbt.tests.adapter.grants.test_models import TestModelGrants + +class testModelGrantsSNowflake(TestModelGrants): + pass \ No newline at end of file From e0b5bbc44ec915f94c52f69b4c99fc708a2e3c90 Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Thu, 7 Jul 2022 16:31:39 -0500 Subject: [PATCH 12/24] adding in test envs and passing locally, augmented new envs in github on snowflake to match correctly --- test.env.example | 4 ++++ tests/functional/adapter/test_grants.py | 6 ++++++ tests/functional/test_grants.py | 5 ----- 3 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 tests/functional/adapter/test_grants.py delete mode 100644 tests/functional/test_grants.py diff --git a/test.env.example b/test.env.example index 9fdc37a21..2a03bcad7 100644 --- a/test.env.example +++ b/test.env.example @@ -29,3 +29,7 @@ SNOWFLAKE_TEST_PASSWORD=my_password SNOWFLAKE_TEST_QUOTED_DATABASE=my_quoted_database_name SNOWFLAKE_TEST_USER=my_username SNOWFLAKE_TEST_WAREHOUSE=my_warehouse_name + +DBT_TEST_USER_1=dbt_test_role_1 +DBT_TEST_USER_2=dbt_test_role_2 +DBT_TEST_USER_3=dbt_test_role_3 \ No newline at end of file diff --git a/tests/functional/adapter/test_grants.py b/tests/functional/adapter/test_grants.py new file mode 100644 index 000000000..acb9a4b60 --- /dev/null +++ b/tests/functional/adapter/test_grants.py @@ -0,0 +1,6 @@ +import pytest + +from dbt.tests.adapter.grants.test_models import TestModelGrants + +class TestModelGrantsSnowflake(TestModelGrants): + pass \ No newline at end of file diff --git a/tests/functional/test_grants.py b/tests/functional/test_grants.py deleted file mode 100644 index 34136b400..000000000 --- a/tests/functional/test_grants.py +++ /dev/null @@ -1,5 +0,0 @@ -import pytest -from dbt.tests.adapter.dbt.tests.adapter.grants.test_models import TestModelGrants - -class testModelGrantsSNowflake(TestModelGrants): - pass \ No newline at end of file From 3a7c473dedc3a4e0f0b92dbf5bcb5d53b5e7ee69 Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Thu, 7 Jul 2022 16:37:10 -0500 Subject: [PATCH 13/24] add end line in file --- test.env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.env.example b/test.env.example index 2a03bcad7..3bc676d2e 100644 --- a/test.env.example +++ b/test.env.example @@ -32,4 +32,4 @@ SNOWFLAKE_TEST_WAREHOUSE=my_warehouse_name DBT_TEST_USER_1=dbt_test_role_1 DBT_TEST_USER_2=dbt_test_role_2 -DBT_TEST_USER_3=dbt_test_role_3 \ No newline at end of file +DBT_TEST_USER_3=dbt_test_role_3 From 84c06e855bb5c0a5f59e2e9628b92c689746ceda Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Thu, 7 Jul 2022 17:23:29 -0500 Subject: [PATCH 14/24] add envs to integration.yml --- .github/workflows/integration.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 554ef5b03..e4fcc13fb 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -173,6 +173,9 @@ jobs: SNOWFLAKE_TEST_DATABASE: ${{ secrets.SNOWFLAKE_TEST_DATABASE }} SNOWFLAKE_TEST_QUOTED_DATABASE: ${{ secrets.SNOWFLAKE_TEST_QUOTED_DATABASE }} SNOWFLAKE_TEST_ROLE: ${{ secrets.SNOWFLAKE_TEST_ROLE }} + 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 4157117b38dd5273f028e4b7c599354a95d19576 Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Thu, 7 Jul 2022 17:39:13 -0500 Subject: [PATCH 15/24] fix typing issue --- dbt/adapters/snowflake/impl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbt/adapters/snowflake/impl.py b/dbt/adapters/snowflake/impl.py index 3b37f2653..56541f16b 100644 --- a/dbt/adapters/snowflake/impl.py +++ b/dbt/adapters/snowflake/impl.py @@ -1,5 +1,5 @@ from dataclasses import dataclass -from typing import Mapping, Any, Optional, List, Union +from typing import Mapping, Any, Optional, List, Union, Dict import agate @@ -161,7 +161,7 @@ def quote_seed_column(self, column: str, quote_config: Optional[bool]) -> str: @available def standardize_grants_dict(self, grants_table: agate.Table) -> dict: - grants_dict = {} + grants_dict: Dict[str, Any] = {} for row in grants_table: grantee = row["grantee_name"] From e3f5bccd53f402c4f4b3fa532593052eab73cb5a Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Fri, 8 Jul 2022 09:43:30 -0500 Subject: [PATCH 16/24] nit file formatting --- tests/functional/adapter/test_grants.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/functional/adapter/test_grants.py b/tests/functional/adapter/test_grants.py index acb9a4b60..6e73013f8 100644 --- a/tests/functional/adapter/test_grants.py +++ b/tests/functional/adapter/test_grants.py @@ -1,6 +1,5 @@ -import pytest - from dbt.tests.adapter.grants.test_models import TestModelGrants + class TestModelGrantsSnowflake(TestModelGrants): pass \ No newline at end of file From eabfef2db51e8f0622ac72031909ed101cbdaf25 Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Fri, 8 Jul 2022 13:14:42 -0500 Subject: [PATCH 17/24] push up addition of more tests pr --- dev-requirements.txt | 12 +++++++--- tests/functional/adapter/test_grants.py | 30 +++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index b894b33bc..a07ebf742 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,9 +1,15 @@ # install latest changes in dbt-core # TODO: how to automate switching from develop to version branches? -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 -# TODO: revert back to main pointer after PR's 5447, and 5369 are merged into core. +# Extended testing branch +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 + +# MY Main Branch +# 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 + +# TODO: revert back to main pointer after PR's 5452, and 5369 are merged into core. # 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 diff --git a/tests/functional/adapter/test_grants.py b/tests/functional/adapter/test_grants.py index 6e73013f8..0ba890ba3 100644 --- a/tests/functional/adapter/test_grants.py +++ b/tests/functional/adapter/test_grants.py @@ -1,5 +1,31 @@ -from dbt.tests.adapter.grants.test_models import TestModelGrants +from dbt.tests.adapter.grants.base_grants import BaseGrants +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_model_grants import BaseModelGrants +# to do: from dbt.tests.adapter.grants.test_revoke_all import +from dbt.tests.adapter.grants.test_seed_grants import BaseSeedGrants +from dbt.tests.adapter.grants.test_snapshot_grants import BaseSnapshotGrants -class TestModelGrantsSnowflake(TestModelGrants): +class TestGrantsSnowflake(BaseGrants): + pass + + +class TestIncrementalGrantsSnowflake(BaseIncrementalGrants): + pass + + +class TestInvalidGrantsSnowflake(BaseInvalidGrants): + pass + + +class TestModelGrantsSnowflake(BaseModelGrants): + pass + + +class TestSeedGrantsSnowflake(BaseSeedGrants): + pass + + +class TestSnapshotGrants(BaseSnapshotGrants): pass \ No newline at end of file From 1247bbabad12f264b1880d429e6fd025544ffe38 Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Fri, 8 Jul 2022 13:54:41 -0500 Subject: [PATCH 18/24] incorporating message changes for snowflake specific error --- tests/functional/adapter/test_grants.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/functional/adapter/test_grants.py b/tests/functional/adapter/test_grants.py index 0ba890ba3..92ca28af9 100644 --- a/tests/functional/adapter/test_grants.py +++ b/tests/functional/adapter/test_grants.py @@ -16,7 +16,11 @@ class TestIncrementalGrantsSnowflake(BaseIncrementalGrants): class TestInvalidGrantsSnowflake(BaseInvalidGrants): - pass + def grantee_does_not_exist_error(self): + return "does not exist or not authorized" + + def privilege_does_not_exist_error(self): + return "unexpected" class TestModelGrantsSnowflake(BaseModelGrants): From c63fe08a86478d8b5e19b090660ca9f95a60d409 Mon Sep 17 00:00:00 2001 From: Jeremy Cohen Date: Mon, 11 Jul 2022 12:06:29 +0200 Subject: [PATCH 19/24] Account for refactor in dbt-labs/dbt-core@c763601 --- dbt/include/snowflake/macros/adapters.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dbt/include/snowflake/macros/adapters.sql b/dbt/include/snowflake/macros/adapters.sql index 1d6c0029b..310072651 100644 --- a/dbt/include/snowflake/macros/adapters.sql +++ b/dbt/include/snowflake/macros/adapters.sql @@ -298,3 +298,7 @@ {% set copy_grants = config.get('copy_grants', False) %} {{ return(copy_grants) }} {% endmacro %} + +{%- macro snowflake__support_multiple_grantees_per_dcl_statement() -%} + {{ return(False) }} +{%- endmacro -%} From ffecf75b5caaba1f2bb56f443470f61f296c8c34 Mon Sep 17 00:00:00 2001 From: Jeremy Cohen Date: Mon, 11 Jul 2022 12:06:44 +0200 Subject: [PATCH 20/24] Run test cases with copy_grants True, too --- tests/functional/adapter/test_grants.py | 40 +++++++++++++++++++------ 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/tests/functional/adapter/test_grants.py b/tests/functional/adapter/test_grants.py index 92ca28af9..4feac6814 100644 --- a/tests/functional/adapter/test_grants.py +++ b/tests/functional/adapter/test_grants.py @@ -1,18 +1,27 @@ -from dbt.tests.adapter.grants.base_grants import BaseGrants +import pytest 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_model_grants import BaseModelGrants -# to do: from dbt.tests.adapter.grants.test_revoke_all import from dbt.tests.adapter.grants.test_seed_grants import BaseSeedGrants from dbt.tests.adapter.grants.test_snapshot_grants import BaseSnapshotGrants -class TestGrantsSnowflake(BaseGrants): - pass - - -class TestIncrementalGrantsSnowflake(BaseIncrementalGrants): - pass +class BaseCopyGrantsSnowflake: + # Try every test case without copy_grants enabled (default), + # and with copy_grants enabled (this base class) + @pytest.fixture(scope="class") + def project_config_update(self): + return { + "models": { + "+copy_grants": True, + }, + "seeds": { + "+copy_grants": True, + }, + "snapshots": { + "+copy_grants": True, + } + } class TestInvalidGrantsSnowflake(BaseInvalidGrants): @@ -26,10 +35,23 @@ def privilege_does_not_exist_error(self): class TestModelGrantsSnowflake(BaseModelGrants): pass +class TestModelGrantsCopyGrantsSnowflake(BaseCopyGrantsSnowflake, BaseModelGrants): + pass + +class TestIncrementalGrantsSnowflake(BaseIncrementalGrants): + pass + +class TestIncrementalCopyGrantsSnowflake(BaseCopyGrantsSnowflake, BaseIncrementalGrants): + pass class TestSeedGrantsSnowflake(BaseSeedGrants): pass +class TestSeedCopyGrantsSnowflake(BaseCopyGrantsSnowflake, BaseSeedGrants): + pass class TestSnapshotGrants(BaseSnapshotGrants): - pass \ No newline at end of file + pass + +class TestSnapshotCopyGrantsSnowflake(BaseCopyGrantsSnowflake, BaseSnapshotGrants): + pass From 5589fcce0b5dcffe48b31defd2fa5a9761c8cfaf Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Mon, 11 Jul 2022 11:38:02 -0500 Subject: [PATCH 21/24] test against ct-660 branch --- dev-requirements.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index a07ebf742..f8f7ba44d 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,13 +1,11 @@ # install latest changes in dbt-core # TODO: how to automate switching from develop to version branches? -# Extended testing branch -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 + # MY Main Branch -# 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-core&subdirectory=core +git+https://github.com/dbt-labs/dbt-core.git@ct-660-grant-sql#egg=dbt-tests-adapter&subdirectory=tests/adapter # TODO: revert back to main pointer after PR's 5452, and 5369 are merged into core. # git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core From cef389ca90d447dd2197637fa2b00e0c86228684 Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Mon, 11 Jul 2022 11:38:57 -0500 Subject: [PATCH 22/24] test against ct-660 branch --- dev-requirements.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index f8f7ba44d..3f782118c 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,8 +1,6 @@ # install latest changes in dbt-core # TODO: how to automate switching from develop to version branches? - - # MY Main Branch 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 From 2fc0828eade51bf638083490e4b569191b0c22e8 Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Mon, 11 Jul 2022 11:59:42 -0500 Subject: [PATCH 23/24] change dev-requirments to point to main dbt-core and test --- dev-requirements.txt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 3f782118c..0b94851fe 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,13 +1,8 @@ # install latest changes in dbt-core # TODO: how to automate switching from develop to version branches? -# MY Main Branch -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 - -# TODO: revert back to main pointer after PR's 5452, and 5369 are merged into core. -# 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-core&subdirectory=core +git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-tests-adapter&subdirectory=tests/adapter black==22.3.0 click~=8.0.4 From abaea859f9bff8a6c69a29f1156fa3e0830d7edf Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Mon, 11 Jul 2022 12:08:23 -0500 Subject: [PATCH 24/24] add changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ad3fcd2b..b425184c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ - In multi-query statements, prepend all queries with query comments. Use the last non-`COMMIT` query to store metadata about the model result. **Note:** this restores previous (pre-v0.21) behavior for incremental models and snapshots, which will again correctly reflect the number of rows modified in `adapter_response.rows_affected` ([#140](https://github.com/dbt-labs/dbt-snowflake/issues/140), [#147](https://github.com/dbt-labs/dbt-snowflake/issues147140), [#153](https://github.com/dbt-labs/dbt-snowflake/pull/153)) - Improve column comment handling when `persist_docs` is enabled ([#161](https://github.com/dbt-labs/dbt-snowflake/pull/161)) +### Features +- Add grants to materializations ([#168](https://github.com/dbt-labs/dbt-snowflake/issues/168), [#178](https://github.com/dbt-labs/dbt-snowflake/pull/178)) + ### Contributors - [@LewisDavies](https://github.com/LewisDavies) ([#161](https://github.com/dbt-labs/dbt-snowflake/pull/161))