From bb20df0db98398419a944642c74efff71519c4ec Mon Sep 17 00:00:00 2001 From: Azhar Dewji Date: Mon, 8 Jun 2020 17:30:26 -0400 Subject: [PATCH 1/8] #1718 - Added support for BigQuery authorized views --- CHANGELOG.md | 4 ++- .../global_project/macros/adapters/common.sql | 9 ++++++ .../dbt/adapters/bigquery/connections.py | 4 +++ .../bigquery/dbt/adapters/bigquery/impl.py | 32 ++++++++++++++++++- .../dbt/include/bigquery/macros/adapters.sql | 4 +++ .../bigquery/macros/materializations/view.sql | 6 ++++ 6 files changed, 57 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef79df452af..36364a93f1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Added a "docs" field to macros, with a "show" subfield to allow for hiding macros from the documentation site ([#2430](https://github.com/fishtown-analytics/dbt/issues/2430)) - Added intersection syntax for model selector ([#2167](https://github.com/fishtown-analytics/dbt/issues/2167), [#2417](https://github.com/fishtown-analytics/dbt/pull/2417)) - Extends model selection syntax with at most n-th parent/children `dbt run --models 3+m1+2` ([#2052](https://github.com/fishtown-analytics/dbt/issues/2052), [#2485](https://github.com/fishtown-analytics/dbt/pull/2485)) +- Added support for BigQuery authorized views ([#1718](https://github.com/fishtown-analytics/dbt/issues/1718), [#2517](https://github.com/fishtown-analytics/dbt/issues/2517)) ### Fixes - Fixed an error in create_adapter_plugins.py script when -dependency arg not passed ([#2507](https://github.com/fishtown-analytics/dbt/issues/2507), [#2508](https://github.com/fishtown-analytics/dbt/pull/2508)) @@ -14,7 +15,8 @@ Contributors: - [@raalsky](https://github.com/Raalsky) ([#2417](https://github.com/fishtown-analytics/dbt/pull/2417), [#2485](https://github.com/fishtown-analytics/dbt/pull/2485)) - [@alf-mindshift](https://github.com/alf-mindshift) ([#2431](https://github.com/fishtown-analytics/dbt/pull/2431)) - [@scarrucciu](https://github.com/scarrucciu) ([#2508](https://github.com/fishtown-analytics/dbt/pull/2508)) -- [@southpolemonkey](https://github.com/southpolemonkey)([#2511](https://github.com/fishtown-analytics/dbt/issues/2511)) + - [@southpolemonkey](https://github.com/southpolemonkey) ([#2511](https://github.com/fishtown-analytics/dbt/issues/2511)) + - [@azhard](https://github.com/azhard) ([#2517](https://github.com/fishtown-analytics/dbt/issues/2517)) ## dbt 0.17.0 (June 08, 2020) diff --git a/core/dbt/include/global_project/macros/adapters/common.sql b/core/dbt/include/global_project/macros/adapters/common.sql index 9dcc71003fe..ef8d46d8c02 100644 --- a/core/dbt/include/global_project/macros/adapters/common.sql +++ b/core/dbt/include/global_project/macros/adapters/common.sql @@ -317,3 +317,12 @@ {% macro set_sql_header(config) -%} {{ config.set('sql_header', caller()) }} {%- endmacro %} + +{% macro grant_access_to(entity, entity_type, role, dataset_id) -%} + {{ return(adapter_macro('grant_access_to', entity, entity_type, role, dataset_id)) }} +{% endmacro %} + +{% macro default__grant_access_to(entity, entity_type, role, dataset_id) -%} + {{ exceptions.raise_not_implemented( + 'grant_access_to macro not implemented for adapter '+adapter.type()) }} +{% endmacro %} diff --git a/plugins/bigquery/dbt/adapters/bigquery/connections.py b/plugins/bigquery/dbt/adapters/bigquery/connections.py index ec07565ed0f..74e5d7d3690 100644 --- a/plugins/bigquery/dbt/adapters/bigquery/connections.py +++ b/plugins/bigquery/dbt/adapters/bigquery/connections.py @@ -313,6 +313,10 @@ def dataset(database, schema, conn): dataset_ref = conn.handle.dataset(schema, database) return google.cloud.bigquery.Dataset(dataset_ref) + @staticmethod + def dataset_from_id(dataset_id): + return google.cloud.bigquery.Dataset.from_string(dataset_id) + def table_ref(self, database, schema, table_name, conn): dataset = self.dataset(database, schema, conn) return dataset.table(table_name) diff --git a/plugins/bigquery/dbt/adapters/bigquery/impl.py b/plugins/bigquery/dbt/adapters/bigquery/impl.py index caafcb0fbfb..8c85bb54db3 100644 --- a/plugins/bigquery/dbt/adapters/bigquery/impl.py +++ b/plugins/bigquery/dbt/adapters/bigquery/impl.py @@ -26,7 +26,7 @@ import google.cloud.exceptions import google.cloud.bigquery -from google.cloud.bigquery import SchemaField +from google.cloud.bigquery import AccessEntry, SchemaField import time import agate @@ -94,6 +94,7 @@ class BigqueryConfig(AdapterConfig): kms_key_name: Optional[str] = None labels: Optional[Dict[str, str]] = None partitions: Optional[List[str]] = None + grant_access_to: Optional[List[str]] = None class BigQueryAdapter(BaseAdapter): @@ -674,3 +675,32 @@ def get_table_options( opts['labels'] = list(labels.items()) return opts + + @available.parse_none + def grant_access_to(self, entity, entity_type, role, dataset_id): + """ + Given an entity, grants it access to a permissioned dataset. + """ + conn = self.connections.get_thread_connection() + client = conn.handle + + dataset = client.get_dataset( + self.connections.dataset_from_id(dataset_id)) + + if entity_type == 'view': + entity = self.connections.table_ref( + entity.database, + entity.schema, + entity.identifier, + conn).to_api_repr() + + access_entry = AccessEntry(role, entity_type, entity) + access_entries = dataset.access_entries + + if access_entry in access_entries: + logger.debug(f"Access entry {access_entry} already in dataset") + return + + access_entries.append(AccessEntry(role, entity_type, entity)) + dataset.access_entries = access_entries + client.update_dataset(dataset, ['access_entries']) diff --git a/plugins/bigquery/dbt/include/bigquery/macros/adapters.sql b/plugins/bigquery/dbt/include/bigquery/macros/adapters.sql index d6365a27653..98739aea038 100644 --- a/plugins/bigquery/dbt/include/bigquery/macros/adapters.sql +++ b/plugins/bigquery/dbt/include/bigquery/macros/adapters.sql @@ -123,3 +123,7 @@ {% macro bigquery__alter_column_comment(relation, column_dict) -%} {% do adapter.update_column_descriptions(relation, column_dict) %} {% endmacro %} + +{% macro bigquery__grant_access_to(entity, entity_type, role, dataset_id) -%} + {% do adapter.grant_access_to(entity, entity_type, role, dataset_id) %} +{% endmacro %} diff --git a/plugins/bigquery/dbt/include/bigquery/macros/materializations/view.sql b/plugins/bigquery/dbt/include/bigquery/macros/materializations/view.sql index 3e43abfcf68..b5de687e0d6 100644 --- a/plugins/bigquery/dbt/include/bigquery/macros/materializations/view.sql +++ b/plugins/bigquery/dbt/include/bigquery/macros/materializations/view.sql @@ -14,6 +14,12 @@ {% set target_relation = this.incorporate(type='view') %} {% do persist_docs(target_relation, model) %} + {% if config.get('grant_access_to') %} + {% for dataset_id in config.get('grant_access_to') %} + {% do adapter.grant_access_to(this, 'view', None, dataset_id) %} + {% endfor %} + {% endif %} + {% do return(to_return) %} {%- endmaterialization %} From 78cf84310c2f134eb6a5e1475f08294880dfbc8b Mon Sep 17 00:00:00 2001 From: Azhar Dewji Date: Tue, 9 Jun 2020 11:58:24 -0400 Subject: [PATCH 2/8] Changed dataset_id to relation --- .../include/global_project/macros/adapters/common.sql | 6 +++--- plugins/bigquery/dbt/adapters/bigquery/impl.py | 9 ++++++--- .../bigquery/dbt/include/bigquery/macros/adapters.sql | 4 ++-- .../include/bigquery/macros/materializations/view.sql | 4 ++-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/core/dbt/include/global_project/macros/adapters/common.sql b/core/dbt/include/global_project/macros/adapters/common.sql index ef8d46d8c02..e4cf14aca6a 100644 --- a/core/dbt/include/global_project/macros/adapters/common.sql +++ b/core/dbt/include/global_project/macros/adapters/common.sql @@ -318,11 +318,11 @@ {{ config.set('sql_header', caller()) }} {%- endmacro %} -{% macro grant_access_to(entity, entity_type, role, dataset_id) -%} - {{ return(adapter_macro('grant_access_to', entity, entity_type, role, dataset_id)) }} +{% macro grant_access_to(entity, entity_type, role, relation) -%} + {{ return(adapter_macro('grant_access_to', entity, entity_type, role, relation)) }} {% endmacro %} -{% macro default__grant_access_to(entity, entity_type, role, dataset_id) -%} +{% macro default__grant_access_to(entity, entity_type, role, relation) -%} {{ exceptions.raise_not_implemented( 'grant_access_to macro not implemented for adapter '+adapter.type()) }} {% endmacro %} diff --git a/plugins/bigquery/dbt/adapters/bigquery/impl.py b/plugins/bigquery/dbt/adapters/bigquery/impl.py index 8c85bb54db3..cf0ecc900f5 100644 --- a/plugins/bigquery/dbt/adapters/bigquery/impl.py +++ b/plugins/bigquery/dbt/adapters/bigquery/impl.py @@ -94,7 +94,7 @@ class BigqueryConfig(AdapterConfig): kms_key_name: Optional[str] = None labels: Optional[Dict[str, str]] = None partitions: Optional[List[str]] = None - grant_access_to: Optional[List[str]] = None + grant_access_to: Optional[List[BigQueryRelation]] = None class BigQueryAdapter(BaseAdapter): @@ -677,7 +677,7 @@ def get_table_options( return opts @available.parse_none - def grant_access_to(self, entity, entity_type, role, dataset_id): + def grant_access_to(self, entity, entity_type, role, relation): """ Given an entity, grants it access to a permissioned dataset. """ @@ -685,7 +685,10 @@ def grant_access_to(self, entity, entity_type, role, dataset_id): client = conn.handle dataset = client.get_dataset( - self.connections.dataset_from_id(dataset_id)) + self.connections.dataset_from_id( + f'{relation.database}.{relation.schema}' + ) + ) if entity_type == 'view': entity = self.connections.table_ref( diff --git a/plugins/bigquery/dbt/include/bigquery/macros/adapters.sql b/plugins/bigquery/dbt/include/bigquery/macros/adapters.sql index 98739aea038..33be32a0d94 100644 --- a/plugins/bigquery/dbt/include/bigquery/macros/adapters.sql +++ b/plugins/bigquery/dbt/include/bigquery/macros/adapters.sql @@ -124,6 +124,6 @@ {% do adapter.update_column_descriptions(relation, column_dict) %} {% endmacro %} -{% macro bigquery__grant_access_to(entity, entity_type, role, dataset_id) -%} - {% do adapter.grant_access_to(entity, entity_type, role, dataset_id) %} +{% macro bigquery__grant_access_to(entity, entity_type, role, relation) -%} + {% do adapter.grant_access_to(entity, entity_type, role, relation) %} {% endmacro %} diff --git a/plugins/bigquery/dbt/include/bigquery/macros/materializations/view.sql b/plugins/bigquery/dbt/include/bigquery/macros/materializations/view.sql index b5de687e0d6..8e0fd725106 100644 --- a/plugins/bigquery/dbt/include/bigquery/macros/materializations/view.sql +++ b/plugins/bigquery/dbt/include/bigquery/macros/materializations/view.sql @@ -15,8 +15,8 @@ {% do persist_docs(target_relation, model) %} {% if config.get('grant_access_to') %} - {% for dataset_id in config.get('grant_access_to') %} - {% do adapter.grant_access_to(this, 'view', None, dataset_id) %} + {% for relation in config.get('grant_access_to') %} + {% do adapter.grant_access_to(this, 'view', None, relation) %} {% endfor %} {% endif %} From 8422c3a9d3c4e04bcb5e63d7f620a882a4be23b3 Mon Sep 17 00:00:00 2001 From: Azhar Dewji Date: Wed, 10 Jun 2020 11:35:18 -0400 Subject: [PATCH 3/8] grant_access no longer common and takes in grant_target_dict param --- .../global_project/macros/adapters/common.sql | 8 -------- plugins/bigquery/dbt/adapters/bigquery/impl.py | 18 +++++++++++++----- .../dbt/include/bigquery/macros/adapters.sql | 4 ---- .../dbt/include/bigquery/macros/etc.sql | 5 ++++- .../bigquery/macros/materializations/view.sql | 4 ++-- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/core/dbt/include/global_project/macros/adapters/common.sql b/core/dbt/include/global_project/macros/adapters/common.sql index e4cf14aca6a..cb48614f607 100644 --- a/core/dbt/include/global_project/macros/adapters/common.sql +++ b/core/dbt/include/global_project/macros/adapters/common.sql @@ -318,11 +318,3 @@ {{ config.set('sql_header', caller()) }} {%- endmacro %} -{% macro grant_access_to(entity, entity_type, role, relation) -%} - {{ return(adapter_macro('grant_access_to', entity, entity_type, role, relation)) }} -{% endmacro %} - -{% macro default__grant_access_to(entity, entity_type, role, relation) -%} - {{ exceptions.raise_not_implemented( - 'grant_access_to macro not implemented for adapter '+adapter.type()) }} -{% endmacro %} diff --git a/plugins/bigquery/dbt/adapters/bigquery/impl.py b/plugins/bigquery/dbt/adapters/bigquery/impl.py index cf0ecc900f5..e471474e8ab 100644 --- a/plugins/bigquery/dbt/adapters/bigquery/impl.py +++ b/plugins/bigquery/dbt/adapters/bigquery/impl.py @@ -77,6 +77,15 @@ def parse(cls, raw_partition_by) -> Optional['PartitionConfig']: ) +@dataclass +class GrantTarget(JsonSchemaMixin): + dataset: str + project: str + + def render(self): + return f'{self.project}.{self.dataset}' + + def _stub_relation(*args, **kwargs): return BigQueryRelation.create( database='', @@ -94,7 +103,7 @@ class BigqueryConfig(AdapterConfig): kms_key_name: Optional[str] = None labels: Optional[Dict[str, str]] = None partitions: Optional[List[str]] = None - grant_access_to: Optional[List[BigQueryRelation]] = None + grant_access_to: Optional[List[Dict[str, str]]] = None class BigQueryAdapter(BaseAdapter): @@ -677,17 +686,16 @@ def get_table_options( return opts @available.parse_none - def grant_access_to(self, entity, entity_type, role, relation): + def grant_access_to(self, entity, entity_type, role, grant_target_dict): """ Given an entity, grants it access to a permissioned dataset. """ conn = self.connections.get_thread_connection() client = conn.handle + grant_target = GrantTarget.from_dict(grant_target_dict) dataset = client.get_dataset( - self.connections.dataset_from_id( - f'{relation.database}.{relation.schema}' - ) + self.connections.dataset_from_id(grant_target.render()) ) if entity_type == 'view': diff --git a/plugins/bigquery/dbt/include/bigquery/macros/adapters.sql b/plugins/bigquery/dbt/include/bigquery/macros/adapters.sql index 33be32a0d94..d6365a27653 100644 --- a/plugins/bigquery/dbt/include/bigquery/macros/adapters.sql +++ b/plugins/bigquery/dbt/include/bigquery/macros/adapters.sql @@ -123,7 +123,3 @@ {% macro bigquery__alter_column_comment(relation, column_dict) -%} {% do adapter.update_column_descriptions(relation, column_dict) %} {% endmacro %} - -{% macro bigquery__grant_access_to(entity, entity_type, role, relation) -%} - {% do adapter.grant_access_to(entity, entity_type, role, relation) %} -{% endmacro %} diff --git a/plugins/bigquery/dbt/include/bigquery/macros/etc.sql b/plugins/bigquery/dbt/include/bigquery/macros/etc.sql index 7bd0cba9086..a10ad1a5bd0 100644 --- a/plugins/bigquery/dbt/include/bigquery/macros/etc.sql +++ b/plugins/bigquery/dbt/include/bigquery/macros/etc.sql @@ -1,4 +1,7 @@ - {% macro date_sharded_table(base_name) %} {{ return(base_name ~ "[DBT__PARTITION_DATE]") }} {% endmacro %} + +{% macro grant_access_to(entity, entity_type, role, grant_target_dict) -%} + {% do adapter.grant_access_to(entity, entity_type, role, grant_target_dict) %} +{% endmacro %} diff --git a/plugins/bigquery/dbt/include/bigquery/macros/materializations/view.sql b/plugins/bigquery/dbt/include/bigquery/macros/materializations/view.sql index 8e0fd725106..8879051293d 100644 --- a/plugins/bigquery/dbt/include/bigquery/macros/materializations/view.sql +++ b/plugins/bigquery/dbt/include/bigquery/macros/materializations/view.sql @@ -15,8 +15,8 @@ {% do persist_docs(target_relation, model) %} {% if config.get('grant_access_to') %} - {% for relation in config.get('grant_access_to') %} - {% do adapter.grant_access_to(this, 'view', None, relation) %} + {% for grant_target_dict in config.get('grant_access_to') %} + {% do adapter.grant_access_to(this, 'view', None, grant_target_dict) %} {% endfor %} {% endif %} From cd0fe51109ec365421d7d7bf634afac85fec7f21 Mon Sep 17 00:00:00 2001 From: Azhar Dewji Date: Wed, 10 Jun 2020 11:55:51 -0400 Subject: [PATCH 4/8] Re-add dropped changelog lines --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 823d396c074..97f7945c2f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ## dbt 0.18.0 (Release TBD) +## dbt 0.18.0b1 (June 08, 2020) + + ### Features - Added a `full_refresh` config item that overrides the behavior of the `--full-refresh` flag ([#1009](https://github.com/fishtown-analytics/dbt/issues/1009), [#2348](https://github.com/fishtown-analytics/dbt/pull/2348)) - Added a "docs" field to macros, with a "show" subfield to allow for hiding macros from the documentation site ([#2430](https://github.com/fishtown-analytics/dbt/issues/2430)) From e7dfe97eccad786729710c529c3122776254df84 Mon Sep 17 00:00:00 2001 From: Azhar Dewji Date: Wed, 10 Jun 2020 14:33:29 -0400 Subject: [PATCH 5/8] Debug message change --- plugins/bigquery/dbt/adapters/bigquery/impl.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/bigquery/dbt/adapters/bigquery/impl.py b/plugins/bigquery/dbt/adapters/bigquery/impl.py index 1f7a144af82..325190aedfb 100644 --- a/plugins/bigquery/dbt/adapters/bigquery/impl.py +++ b/plugins/bigquery/dbt/adapters/bigquery/impl.py @@ -730,7 +730,8 @@ def grant_access_to(self, entity, entity_type, role, grant_target_dict): access_entries = dataset.access_entries if access_entry in access_entries: - logger.debug(f"Access entry {access_entry} already in dataset") + logger.debug(f"Access entry {access_entry} " + f"already exists in dataset") return access_entries.append(AccessEntry(role, entity_type, entity)) From e53a45b3e018a8e1b06cabbdb10f72a2017a8dfa Mon Sep 17 00:00:00 2001 From: Azhar Dewji Date: Thu, 11 Jun 2020 13:10:10 -0400 Subject: [PATCH 6/8] Added integration test --- .../dbt/adapters/bigquery/__init__.py | 2 +- .../test_adapter_methods.py | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/plugins/bigquery/dbt/adapters/bigquery/__init__.py b/plugins/bigquery/dbt/adapters/bigquery/__init__.py index daff48a32ee..dc45b50c393 100644 --- a/plugins/bigquery/dbt/adapters/bigquery/__init__.py +++ b/plugins/bigquery/dbt/adapters/bigquery/__init__.py @@ -2,7 +2,7 @@ from dbt.adapters.bigquery.connections import BigQueryCredentials from dbt.adapters.bigquery.relation import BigQueryRelation # noqa from dbt.adapters.bigquery.column import BigQueryColumn # noqa -from dbt.adapters.bigquery.impl import BigQueryAdapter +from dbt.adapters.bigquery.impl import BigQueryAdapter, GrantTarget from dbt.adapters.base import AdapterPlugin from dbt.include import bigquery diff --git a/test/integration/054_adapter_methods_test/test_adapter_methods.py b/test/integration/054_adapter_methods_test/test_adapter_methods.py index c431550433b..ceabf7efcb2 100644 --- a/test/integration/054_adapter_methods_test/test_adapter_methods.py +++ b/test/integration/054_adapter_methods_test/test_adapter_methods.py @@ -1,4 +1,6 @@ from test.integration.base import DBTIntegrationTest, use_profile +from dbt.adapters.bigquery import GrantTarget +from google.cloud.bigquery import AccessEntry import yaml @@ -70,3 +72,49 @@ def test_bigquery_adapter_methods(self): }) self.run_dbt(['run-operation', 'rename_named_relation', '--args', rename_relation_args]) self.run_dbt() + + +class TestGrantAccess(DBTIntegrationTest): + @property + def schema(self): + return "grant_access_054" + + @property + def models(self): + return 'bigquery-models' + + @property + def project_config(self): + return { + 'config-version': 2, + 'source-paths': ['models'] + } + + @use_profile('bigquery') + def test_bigquery_adapter_methods(self): + self.run_dbt(['compile']) # trigger any compile-time issues + self.run_sql_file("seed_bq.sql") + self.run_dbt(['seed']) + + ae_role = "READER" + ae_entity = "user@email.com" + ae_entity_type = "userByEmail" + ae_grant_target_dict = { + 'project': self.default_database, + 'dataset': self.unique_schema() + } + self.adapter.grant_access_to(ae_entity, ae_entity_type, ae_role, ae_grant_target_dict) + + conn = self.adapter.connections.get_thread_connection() + client = conn.handle + + grant_target = GrantTarget.from_dict(ae_grant_target_dict) + dataset = client.get_dataset( + self.adapter.connections.dataset_from_id(grant_target.render()) + ) + + expected_access_entry = AccessEntry(ae_role, ae_entity_type, ae_entity) + self.assertTrue(expected_access_entry in dataset.access_entries) + + unexpected_access_entry = AccessEntry(ae_role, ae_entity_type, "unexpected@email.com") + self.assertFalse(unexpected_access_entry in dataset.access_entries) From 19735d5416ad6d7d745abf0ce1d45c066ad51362 Mon Sep 17 00:00:00 2001 From: Azhar Dewji Date: Thu, 11 Jun 2020 13:19:05 -0400 Subject: [PATCH 7/8] Added noqa flag to GrantTarget import --- plugins/bigquery/dbt/adapters/bigquery/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/bigquery/dbt/adapters/bigquery/__init__.py b/plugins/bigquery/dbt/adapters/bigquery/__init__.py index dc45b50c393..c85e79b389a 100644 --- a/plugins/bigquery/dbt/adapters/bigquery/__init__.py +++ b/plugins/bigquery/dbt/adapters/bigquery/__init__.py @@ -2,7 +2,7 @@ from dbt.adapters.bigquery.connections import BigQueryCredentials from dbt.adapters.bigquery.relation import BigQueryRelation # noqa from dbt.adapters.bigquery.column import BigQueryColumn # noqa -from dbt.adapters.bigquery.impl import BigQueryAdapter, GrantTarget +from dbt.adapters.bigquery.impl import BigQueryAdapter, GrantTarget # noqa from dbt.adapters.base import AdapterPlugin from dbt.include import bigquery From 4ccfe020a29a5b71e222a07a5609ee1704121e58 Mon Sep 17 00:00:00 2001 From: Azhar Dewji Date: Thu, 11 Jun 2020 13:30:36 -0400 Subject: [PATCH 8/8] Moved bigquery imports into bigquery test --- .../054_adapter_methods_test/test_adapter_methods.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/integration/054_adapter_methods_test/test_adapter_methods.py b/test/integration/054_adapter_methods_test/test_adapter_methods.py index ceabf7efcb2..1fcaf5b1a49 100644 --- a/test/integration/054_adapter_methods_test/test_adapter_methods.py +++ b/test/integration/054_adapter_methods_test/test_adapter_methods.py @@ -1,6 +1,4 @@ from test.integration.base import DBTIntegrationTest, use_profile -from dbt.adapters.bigquery import GrantTarget -from google.cloud.bigquery import AccessEntry import yaml @@ -92,6 +90,9 @@ def project_config(self): @use_profile('bigquery') def test_bigquery_adapter_methods(self): + from dbt.adapters.bigquery import GrantTarget + from google.cloud.bigquery import AccessEntry + self.run_dbt(['compile']) # trigger any compile-time issues self.run_sql_file("seed_bq.sql") self.run_dbt(['seed'])