From f58e3389d4cd859938b585d07b6da7e53a1de0ce Mon Sep 17 00:00:00 2001 From: Jacob Beck Date: Tue, 28 Jul 2020 12:57:59 -0600 Subject: [PATCH] add logging, add tests, update changelog --- CHANGELOG.md | 1 + core/dbt/contracts/graph/manifest.py | 10 +- core/dbt/contracts/util.py | 2 +- .../test_docs_generate.py | 26 ++++ .../changed_models/ephemeral_model.sql | 2 + .../changed_models/schema.yml | 9 ++ .../changed_models/table_model.sql | 2 + .../changed_models/view_model.sql | 1 + .../changed_models_bad/ephemeral_model.sql | 2 + .../changed_models_bad/schema.yml | 9 ++ .../changed_models_bad/table_model.sql | 2 + .../changed_models_bad/view_model.sql | 1 + .../062_defer_state_test/data/seed.csv | 3 + .../models/ephemeral_model.sql | 2 + .../062_defer_state_test/models/schema.yml | 9 ++ .../models/table_model.sql | 2 + .../models/view_model.sql | 1 + .../snapshots/my_snapshot.sql | 14 ++ .../062_defer_state_test/test_defer_state.py | 126 ++++++++++++++++++ test/integration/base.py | 1 + test/unit/test_contracts_graph_compiled.py | 11 ++ test/unit/test_contracts_graph_parsed.py | 12 ++ test/unit/test_manifest.py | 1 + 23 files changed, 247 insertions(+), 2 deletions(-) create mode 100644 test/integration/062_defer_state_test/changed_models/ephemeral_model.sql create mode 100644 test/integration/062_defer_state_test/changed_models/schema.yml create mode 100644 test/integration/062_defer_state_test/changed_models/table_model.sql create mode 100644 test/integration/062_defer_state_test/changed_models/view_model.sql create mode 100644 test/integration/062_defer_state_test/changed_models_bad/ephemeral_model.sql create mode 100644 test/integration/062_defer_state_test/changed_models_bad/schema.yml create mode 100644 test/integration/062_defer_state_test/changed_models_bad/table_model.sql create mode 100644 test/integration/062_defer_state_test/changed_models_bad/view_model.sql create mode 100644 test/integration/062_defer_state_test/data/seed.csv create mode 100644 test/integration/062_defer_state_test/models/ephemeral_model.sql create mode 100644 test/integration/062_defer_state_test/models/schema.yml create mode 100644 test/integration/062_defer_state_test/models/table_model.sql create mode 100644 test/integration/062_defer_state_test/models/view_model.sql create mode 100644 test/integration/062_defer_state_test/snapshots/my_snapshot.sql create mode 100644 test/integration/062_defer_state_test/test_defer_state.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 3261d4c6c17..b5353a1780f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - Adapter plugins can once again override plugins defined in core ([#2548](https://github.com/fishtown-analytics/dbt/issues/2548), [#2590](https://github.com/fishtown-analytics/dbt/pull/2590)) - Added `--selector` argument and support for `selectors.yml` file to define selection mechanisms. ([#2172](https://github.com/fishtown-analytics/dbt/issues/2172), [#2640](https://github.com/fishtown-analytics/dbt/pull/2640)) - Compile assets as part of docs generate ([#2072](https://github.com/fishtown-analytics/dbt/issues/2072), [#2623](https://github.com/fishtown-analytics/dbt/pull/2623)) +- Added `--defer` and `--state` flags to `dbt run`, to defer to a previously generated manifest for unselected nodes in a run. ([#2527](https://github.com/fishtown-analytics/dbt/issues/2527), [#2656](https://github.com/fishtown-analytics/dbt/pull/2656)) Contributors: - [@brunomurino](https://github.com/brunomurino) ([#2437](https://github.com/fishtown-analytics/dbt/pull/2581)) diff --git a/core/dbt/contracts/graph/manifest.py b/core/dbt/contracts/graph/manifest.py index 83f28dd7ff0..e9f55d54cad 100644 --- a/core/dbt/contracts/graph/manifest.py +++ b/core/dbt/contracts/graph/manifest.py @@ -4,7 +4,7 @@ import os from dataclasses import dataclass, field from datetime import datetime -from itertools import chain +from itertools import chain, islice from multiprocessing.synchronize import Lock from typing import ( Dict, List, Optional, Union, Mapping, MutableMapping, Any, Set, Tuple, @@ -1022,14 +1022,22 @@ def merge_from_artifact( Only non-ephemeral refable nodes are examined. """ refables = set(NodeType.refable()) + merged = set() for unique_id, node in other.nodes.items(): if ( node.resource_type in refables and not node.is_ephemeral and unique_id not in selected ): + merged.add(unique_id) self.nodes[unique_id] = node + # log up to 5 items + sample = list(islice(merged, 5)) + logger.debug( + f'Merged {len(merged)} items from state (sample: {sample})' + ) + @dataclass class WritableManifest(JsonSchemaMixin, Writable, Readable): diff --git a/core/dbt/contracts/util.py b/core/dbt/contracts/util.py index 8597fab880c..764ee1cd08e 100644 --- a/core/dbt/contracts/util.py +++ b/core/dbt/contracts/util.py @@ -89,4 +89,4 @@ def read(cls, path: str): f'Could not read {cls.__name__} at "{path}" as JSON: {exc}' ) from exc - return cls.from_dict(data) + return cls.from_dict(data) # type: ignore diff --git a/test/integration/029_docs_generate_tests/test_docs_generate.py b/test/integration/029_docs_generate_tests/test_docs_generate.py index bc7a79f0d61..82e2fc8a91d 100644 --- a/test/integration/029_docs_generate_tests/test_docs_generate.py +++ b/test/integration/029_docs_generate_tests/test_docs_generate.py @@ -966,6 +966,7 @@ def expected_seeded_manifest(self, model_database=None): 'config': model_config, 'schema': my_schema_name, 'database': model_database, + 'deferred': False, 'alias': 'model', 'description': 'The test model', 'columns': { @@ -1032,6 +1033,7 @@ def expected_seeded_manifest(self, model_database=None): 'config': second_config, 'schema': self.alternate_schema, 'database': self.default_database, + 'deferred': False, 'alias': 'second_model', 'description': 'The second test model', 'columns': { @@ -1115,6 +1117,7 @@ def expected_seeded_manifest(self, model_database=None): 'schema': my_schema_name, 'database': self.default_database, 'alias': 'seed', + 'deferred': False, 'description': 'The test seed', 'columns': { 'id': { @@ -1183,6 +1186,7 @@ def expected_seeded_manifest(self, model_database=None): 'macros': ['macro.dbt.test_not_null'], 'nodes': ['model.test.model'], }, + 'deferred': False, 'description': '', 'fqn': ['test', 'schema_test', 'not_null_model_id'], 'name': 'not_null_model_id', @@ -1237,6 +1241,7 @@ def expected_seeded_manifest(self, model_database=None): 'macros': ['macro.test.test_nothing'], 'nodes': ['model.test.model'], }, + 'deferred': False, 'description': '', 'fqn': ['test', 'schema_test', 'test_nothing_model_'], 'name': 'test_nothing_model_', @@ -1290,6 +1295,7 @@ def expected_seeded_manifest(self, model_database=None): 'macros': ['macro.dbt.test_unique'], 'nodes': ['model.test.model'], }, + 'deferred': False, 'description': '', 'fqn': ['test', 'schema_test', 'unique_model_id'], 'name': 'unique_model_id', @@ -1386,6 +1392,7 @@ def expected_postgres_references_manifest(self, model_database=None): 'macros': [], 'nodes': ['source.test.my_source.my_table'] }, + 'deferred': False, 'description': '', 'docs': {'show': True}, 'fqn': ['test', 'ephemeral_copy'], @@ -1448,6 +1455,7 @@ def expected_postgres_references_manifest(self, model_database=None): 'macros': [], 'nodes': ['model.test.ephemeral_copy'] }, + 'deferred': False, 'description': 'A summmary table of the ephemeral copy of the seed data', 'docs': {'show': True}, 'fqn': ['test', 'ephemeral_summary'], @@ -1512,6 +1520,7 @@ def expected_postgres_references_manifest(self, model_database=None): 'macros': [], 'nodes': ['model.test.ephemeral_summary'] }, + 'deferred': False, 'description': 'A view of the summary of the ephemeral copy of the seed data', 'docs': {'show': True}, 'fqn': ['test', 'view_summary'], @@ -1594,6 +1603,7 @@ def expected_postgres_references_manifest(self, model_database=None): }, 'sources': [], 'depends_on': {'macros': [], 'nodes': []}, + 'deferred': False, 'description': 'The test seed', 'docs': {'show': True}, 'fqn': ['test', 'seed'], @@ -1879,6 +1889,7 @@ def expected_bigquery_complex_manifest(self): 'tags': [], }, }, + 'deferred': False, 'description': 'A clustered and partitioned copy of the test model', 'patch_path': self.dir('bq_models/schema.yml'), 'docs': {'show': True}, @@ -1958,6 +1969,7 @@ def expected_bigquery_complex_manifest(self): 'tags': [], }, }, + 'deferred': False, 'description': 'A clustered and partitioned copy of the test model, clustered on multiple columns', 'patch_path': self.dir('bq_models/schema.yml'), 'docs': {'show': True}, @@ -2038,6 +2050,7 @@ def expected_bigquery_complex_manifest(self): 'tags': [], }, }, + 'deferred': False, 'description': 'The test model', 'patch_path': self.dir('bq_models/schema.yml'), 'docs': {'show': True}, @@ -2083,6 +2096,7 @@ def expected_bigquery_complex_manifest(self): 'meta': {}, 'unique_id': 'model.test.nested_table', 'columns': {}, + 'deferred': False, 'description': '', 'docs': {'show': True}, 'compiled': True, @@ -2164,6 +2178,7 @@ def expected_bigquery_complex_manifest(self): 'tags': [], }, }, + 'deferred': False, 'description': 'The test seed', 'docs': {'show': True}, 'compiled': True, @@ -2268,6 +2283,7 @@ def expected_redshift_incremental_view_manifest(self): 'schema': my_schema_name, 'database': self.default_database, 'alias': 'model', + 'deferred': False, 'description': 'The test model', 'columns': { 'id': { @@ -2387,6 +2403,7 @@ def expected_redshift_incremental_view_manifest(self): 'tags': [], }, }, + 'deferred': False, 'description': 'The test seed', 'docs': {'show': True}, 'compiled': True, @@ -2559,6 +2576,7 @@ def expected_run_results(self, quote_schema=True, quote_model=False, 'macros': [], 'nodes': ['seed.test.seed'] }, + 'deferred': False, 'description': 'The test model', 'docs': {'show': False}, 'extra_ctes': [], @@ -2640,6 +2658,7 @@ def expected_run_results(self, quote_schema=True, quote_model=False, 'macros': [], 'nodes': ['seed.test.seed'] }, + 'deferred': False, 'description': 'The second test model', 'docs': {'show': False}, 'extra_ctes': [], @@ -2728,6 +2747,7 @@ def expected_run_results(self, quote_schema=True, quote_model=False, }, 'sources': [], 'depends_on': {'macros': [], 'nodes': []}, + 'deferred': False, 'description': 'The test seed', 'docs': {'show': True}, 'extra_ctes': [], @@ -2784,6 +2804,7 @@ def expected_run_results(self, quote_schema=True, quote_model=False, 'macros': ['macro.dbt.test_not_null'], 'nodes': ['model.test.model'], }, + 'deferred': False, 'description': '', 'docs': {'show': True}, 'extra_ctes': [], @@ -2848,6 +2869,7 @@ def expected_run_results(self, quote_schema=True, quote_model=False, 'macros': ['macro.test.test_nothing'], 'nodes': ['model.test.model'], }, + 'deferred': False, 'description': '', 'docs': {'show': True}, 'extra_ctes': [], @@ -2911,6 +2933,7 @@ def expected_run_results(self, quote_schema=True, quote_model=False, 'macros': ['macro.dbt.test_unique'], 'nodes': ['model.test.model'], }, + 'deferred': False, 'description': '', 'docs': {'show': True}, 'extra_ctes': [], @@ -3016,6 +3039,7 @@ def expected_postgres_references_run_results(self): 'nodes': ['model.test.ephemeral_copy'], 'macros': [] }, + 'deferred': False, 'description': ( 'A summmary table of the ephemeral copy of the seed data' ), @@ -3097,6 +3121,7 @@ def expected_postgres_references_run_results(self): 'nodes': ['model.test.ephemeral_summary'], 'macros': [] }, + 'deferred': False, 'description': ( 'A view of the summary of the ephemeral copy of the ' 'seed data' @@ -3192,6 +3217,7 @@ def expected_postgres_references_run_results(self): }, 'sources': [], 'depends_on': {'macros': [], 'nodes': []}, + 'deferred': False, 'description': 'The test seed', 'docs': {'show': True}, 'extra_ctes': [], diff --git a/test/integration/062_defer_state_test/changed_models/ephemeral_model.sql b/test/integration/062_defer_state_test/changed_models/ephemeral_model.sql new file mode 100644 index 00000000000..2f976e3a9b5 --- /dev/null +++ b/test/integration/062_defer_state_test/changed_models/ephemeral_model.sql @@ -0,0 +1,2 @@ +{{ config(materialized='ephemeral') }} +select * from {{ ref('view_model') }} diff --git a/test/integration/062_defer_state_test/changed_models/schema.yml b/test/integration/062_defer_state_test/changed_models/schema.yml new file mode 100644 index 00000000000..1ec506d3d19 --- /dev/null +++ b/test/integration/062_defer_state_test/changed_models/schema.yml @@ -0,0 +1,9 @@ +version: 2 +models: + - name: view_model + columns: + - name: id + tests: + - unique + - not_null + - name: name diff --git a/test/integration/062_defer_state_test/changed_models/table_model.sql b/test/integration/062_defer_state_test/changed_models/table_model.sql new file mode 100644 index 00000000000..07fa333386f --- /dev/null +++ b/test/integration/062_defer_state_test/changed_models/table_model.sql @@ -0,0 +1,2 @@ +{{ config(materialized='table') }} +select * from {{ ref('ephemeral_model') }} diff --git a/test/integration/062_defer_state_test/changed_models/view_model.sql b/test/integration/062_defer_state_test/changed_models/view_model.sql new file mode 100644 index 00000000000..bddbbb23cc2 --- /dev/null +++ b/test/integration/062_defer_state_test/changed_models/view_model.sql @@ -0,0 +1 @@ +select * from no.such.table diff --git a/test/integration/062_defer_state_test/changed_models_bad/ephemeral_model.sql b/test/integration/062_defer_state_test/changed_models_bad/ephemeral_model.sql new file mode 100644 index 00000000000..5155dfa475e --- /dev/null +++ b/test/integration/062_defer_state_test/changed_models_bad/ephemeral_model.sql @@ -0,0 +1,2 @@ +{{ config(materialized='ephemeral') }} +select * from no.such.table diff --git a/test/integration/062_defer_state_test/changed_models_bad/schema.yml b/test/integration/062_defer_state_test/changed_models_bad/schema.yml new file mode 100644 index 00000000000..1ec506d3d19 --- /dev/null +++ b/test/integration/062_defer_state_test/changed_models_bad/schema.yml @@ -0,0 +1,9 @@ +version: 2 +models: + - name: view_model + columns: + - name: id + tests: + - unique + - not_null + - name: name diff --git a/test/integration/062_defer_state_test/changed_models_bad/table_model.sql b/test/integration/062_defer_state_test/changed_models_bad/table_model.sql new file mode 100644 index 00000000000..07fa333386f --- /dev/null +++ b/test/integration/062_defer_state_test/changed_models_bad/table_model.sql @@ -0,0 +1,2 @@ +{{ config(materialized='table') }} +select * from {{ ref('ephemeral_model') }} diff --git a/test/integration/062_defer_state_test/changed_models_bad/view_model.sql b/test/integration/062_defer_state_test/changed_models_bad/view_model.sql new file mode 100644 index 00000000000..bddbbb23cc2 --- /dev/null +++ b/test/integration/062_defer_state_test/changed_models_bad/view_model.sql @@ -0,0 +1 @@ +select * from no.such.table diff --git a/test/integration/062_defer_state_test/data/seed.csv b/test/integration/062_defer_state_test/data/seed.csv new file mode 100644 index 00000000000..1a728c8ab74 --- /dev/null +++ b/test/integration/062_defer_state_test/data/seed.csv @@ -0,0 +1,3 @@ +id,name +1,Alice +2,Bob diff --git a/test/integration/062_defer_state_test/models/ephemeral_model.sql b/test/integration/062_defer_state_test/models/ephemeral_model.sql new file mode 100644 index 00000000000..2f976e3a9b5 --- /dev/null +++ b/test/integration/062_defer_state_test/models/ephemeral_model.sql @@ -0,0 +1,2 @@ +{{ config(materialized='ephemeral') }} +select * from {{ ref('view_model') }} diff --git a/test/integration/062_defer_state_test/models/schema.yml b/test/integration/062_defer_state_test/models/schema.yml new file mode 100644 index 00000000000..1ec506d3d19 --- /dev/null +++ b/test/integration/062_defer_state_test/models/schema.yml @@ -0,0 +1,9 @@ +version: 2 +models: + - name: view_model + columns: + - name: id + tests: + - unique + - not_null + - name: name diff --git a/test/integration/062_defer_state_test/models/table_model.sql b/test/integration/062_defer_state_test/models/table_model.sql new file mode 100644 index 00000000000..07fa333386f --- /dev/null +++ b/test/integration/062_defer_state_test/models/table_model.sql @@ -0,0 +1,2 @@ +{{ config(materialized='table') }} +select * from {{ ref('ephemeral_model') }} diff --git a/test/integration/062_defer_state_test/models/view_model.sql b/test/integration/062_defer_state_test/models/view_model.sql new file mode 100644 index 00000000000..4b91aa0f2fa --- /dev/null +++ b/test/integration/062_defer_state_test/models/view_model.sql @@ -0,0 +1 @@ +select * from {{ ref('seed') }} diff --git a/test/integration/062_defer_state_test/snapshots/my_snapshot.sql b/test/integration/062_defer_state_test/snapshots/my_snapshot.sql new file mode 100644 index 00000000000..6a7d2b31bfa --- /dev/null +++ b/test/integration/062_defer_state_test/snapshots/my_snapshot.sql @@ -0,0 +1,14 @@ +{% snapshot my_cool_snapshot %} + + {{ + config( + target_database=database, + target_schema=schema, + unique_key='id', + strategy='check', + check_cols=['id'], + ) + }} + select * from {{ ref('view_model') }} + +{% endsnapshot %} diff --git a/test/integration/062_defer_state_test/test_defer_state.py b/test/integration/062_defer_state_test/test_defer_state.py new file mode 100644 index 00000000000..717b0adac85 --- /dev/null +++ b/test/integration/062_defer_state_test/test_defer_state.py @@ -0,0 +1,126 @@ +from test.integration.base import DBTIntegrationTest, use_profile +import copy +import os +import shutil + +import pytest + +class TestDeferState(DBTIntegrationTest): + @property + def schema(self): + return "defer_state_062" + + @property + def models(self): + return "models" + + def setUp(self): + self.other_schema = None + super().setUp() + self._created_schemas.add(self.other_schema) + + @property + def project_config(self): + return { + 'config-version': 2, + 'seeds': { + 'test': { + 'quote_columns': True, + } + } + } + + def get_profile(self, adapter_type): + if self.other_schema is None: + self.other_schema = self.unique_schema() + '_other' + if self.adapter_type == 'snowflake': + self.other_schema = self.other_schema.upper() + profile = super().get_profile(adapter_type) + default_name = profile['test']['target'] + profile['test']['outputs']['otherschema'] = copy.deepcopy(profile['test']['outputs'][default_name]) + profile['test']['outputs']['otherschema']['schema'] = self.other_schema + return profile + + def copy_state(self): + assert not os.path.exists('state') + os.makedirs('state') + shutil.copyfile('target/manifest.json', 'state/manifest.json') + + def run_and_defer(self): + results = self.run_dbt(['seed']) + assert len(results) == 1 + results = self.run_dbt(['run']) + assert len(results) == 2 + + # copy files over from the happy times when we had a good target + self.copy_state() + + # no state, still fails + self.run_dbt(['run', '--target', 'otherschema'], expect_pass=False) + + # with state it should work though + results = self.run_dbt(['run', '-m', 'view_model', '--state', 'state', '--defer', '--target', 'otherschema']) + assert self.other_schema not in results[0].node.injected_sql + assert self.unique_schema() in results[0].node.injected_sql + assert len(results) == 1 + + def run_switchdirs_defer(self): + results = self.run_dbt(['seed']) + assert len(results) == 1 + results = self.run_dbt(['run']) + assert len(results) == 2 + + # copy files over from the happy times when we had a good target + self.copy_state() + + self.use_default_project({'source-paths': ['changed_models']}) + # the sql here is just wrong, so it should fail + self.run_dbt( + ['run', '-m', 'view_model', '--state', 'state', '--defer', '--target', 'otherschema'], + expect_pass=False, + ) + # but this should work since we just use the old happy model + self.run_dbt( + ['run', '-m', 'table_model', '--state', 'state', '--defer', '--target', 'otherschema'], + expect_pass=True, + ) + + self.use_default_project({'source-paths': ['changed_models_bad']}) + # this should fail because the table model refs a broken ephemeral + # model, which it should see + self.run_dbt( + ['run', '-m', 'table_model', '--state', 'state', '--defer', '--target', 'otherschema'], + expect_pass=False, + ) + + @use_profile('postgres') + def test_postgres_state_changetarget(self): + self.run_and_defer() + # these should work without --defer! + self.run_dbt(['test']) + self.run_dbt(['snapshot']) + # make sure these commands don't work with --defer + with pytest.raises(SystemExit): + self.run_dbt(['seed', '--defer']) + + with pytest.raises(SystemExit): + self.run_dbt(['test', '--defer']) + with pytest.raises(SystemExit): + self.run_dbt(['snapshot', '--defer']) + + @use_profile('postgres') + def test_postgres_stat_changedir(self): + self.run_switchdirs_defer() + + @use_profile('snowflake') + def test_snowflake_state_changetarget(self): + self.run_and_defer() + + @use_profile('redshift') + def test_redshift_state_changetarget(self): + self.run_and_defer() + + @use_profile('bigquery') + def test_bigquery_state_changetarget(self): + self.run_and_defer() + diff --git a/test/integration/base.py b/test/integration/base.py index 5065f1c1d09..c912133cf82 100644 --- a/test/integration/base.py +++ b/test/integration/base.py @@ -60,6 +60,7 @@ class FakeArgs: def __init__(self): self.threads = 1 self.data = False + self.defer = False self.schema = True self.full_refresh = False self.models = None diff --git a/test/unit/test_contracts_graph_compiled.py b/test/unit/test_contracts_graph_compiled.py index 4dc16616bff..b40aa563ee7 100644 --- a/test/unit/test_contracts_graph_compiled.py +++ b/test/unit/test_contracts_graph_compiled.py @@ -28,6 +28,7 @@ def _minimum(self): 'database': 'test_db', 'schema': 'test_schema', 'alias': 'bar', + 'compiled': False, } def test_basic_uncompiled(self): @@ -45,6 +46,7 @@ def test_basic_uncompiled(self): 'sources': [], 'depends_on': {'macros': [], 'nodes': []}, 'database': 'test_db', + 'deferred': False, 'description': '', 'schema': 'test_schema', 'alias': 'bar', @@ -80,6 +82,7 @@ def test_basic_uncompiled(self): refs=[], sources=[], depends_on=DependsOn(), + deferred=False, description='', database='test_db', schema='test_schema', @@ -116,6 +119,7 @@ def test_basic_compiled(self): 'sources': [], 'depends_on': {'macros': [], 'nodes': []}, 'database': 'test_db', + 'deferred': True, 'description': '', 'schema': 'test_schema', 'alias': 'bar', @@ -153,6 +157,7 @@ def test_basic_compiled(self): refs=[], sources=[], depends_on=DependsOn(), + deferred=True, description='', database='test_db', schema='test_schema', @@ -204,6 +209,7 @@ def _minimum(self): 'name': 'foo', 'kwargs': {}, }, + 'compiled': False, } def test_basic_uncompiled(self): @@ -237,6 +243,7 @@ def test_basic_uncompiled(self): 'vars': {}, 'severity': 'ERROR', }, + 'deferred': False, 'docs': {'show': True}, 'columns': {}, 'meta': {}, @@ -260,6 +267,7 @@ def test_basic_uncompiled(self): fqn=['test', 'models', 'foo'], refs=[], sources=[], + deferred=False, depends_on=DependsOn(), description='', database='test_db', @@ -297,6 +305,7 @@ def test_basic_compiled(self): 'refs': [], 'sources': [], 'depends_on': {'macros': [], 'nodes': []}, + 'deferred': False, 'database': 'test_db', 'description': '', 'schema': 'test_schema', @@ -314,6 +323,7 @@ def test_basic_compiled(self): 'vars': {}, 'severity': 'warn', }, + 'docs': {'show': True}, 'columns': {}, 'meta': {}, @@ -341,6 +351,7 @@ def test_basic_compiled(self): refs=[], sources=[], depends_on=DependsOn(), + deferred=False, description='', database='test_db', schema='test_schema', diff --git a/test/unit/test_contracts_graph_parsed.py b/test/unit/test_contracts_graph_parsed.py index 6324a3e4639..7716512b541 100644 --- a/test/unit/test_contracts_graph_parsed.py +++ b/test/unit/test_contracts_graph_parsed.py @@ -109,6 +109,7 @@ def _model_ok(self): 'tags': [], 'vars': {}, }, + 'deferred': False, 'docs': {'show': True}, 'columns': {}, 'meta': {}, @@ -176,6 +177,7 @@ def test_complex(self): 'sources': [], 'depends_on': {'macros': [], 'nodes': ['model.test.bar']}, 'database': 'test_db', + 'deferred': True, 'description': 'My parsed node', 'schema': 'test_schema', 'alias': 'bar', @@ -216,6 +218,7 @@ def test_complex(self): refs=[], sources=[], depends_on=DependsOn(nodes=['model.test.bar']), + deferred=True, description='My parsed node', database='test_db', schema='test_schema', @@ -297,6 +300,7 @@ def test_patch_ok(self): 'sources': [], 'depends_on': {'macros': [], 'nodes': []}, 'database': 'test_db', + 'deferred': False, 'description': 'The foo model', 'schema': 'test_schema', 'alias': 'bar', @@ -406,6 +410,7 @@ def _hook_ok(self): 'sources': [], 'depends_on': {'macros': [], 'nodes': []}, 'database': 'test_db', + 'deferred': False, 'description': '', 'schema': 'test_schema', 'alias': 'bar', @@ -443,6 +448,7 @@ def test_ok(self): sources=[], depends_on=DependsOn(), description='', + deferred=False, database='test_db', schema='test_schema', alias='bar', @@ -487,6 +493,7 @@ def test_complex(self): 'refs': [], 'sources': [], 'depends_on': {'macros': [], 'nodes': ['model.test.bar']}, + 'deferred': False, 'database': 'test_db', 'description': 'My parsed node', 'schema': 'test_schema', @@ -530,6 +537,7 @@ def test_complex(self): sources=[], depends_on=DependsOn(nodes=['model.test.bar']), description='My parsed node', + deferred=False, database='test_db', schema='test_schema', alias='bar', @@ -594,6 +602,7 @@ def _complex(self): 'sources': [], 'depends_on': {'macros': [], 'nodes': ['model.test.bar']}, 'database': 'test_db', + 'deferred': False, 'description': 'My parsed node', 'schema': 'test_schema', 'alias': 'bar', @@ -642,6 +651,7 @@ def test_ok(self): 'refs': [], 'sources': [], 'depends_on': {'macros': [], 'nodes': []}, + 'deferred': False, 'database': 'test_db', 'description': '', 'schema': 'test_schema', @@ -924,6 +934,7 @@ def _ts_ok(self): 'refs': [], 'sources': [], 'depends_on': {'macros': [], 'nodes': []}, + 'deferred': False, 'database': 'test_db', 'description': '', 'schema': 'test_schema', @@ -1034,6 +1045,7 @@ def test_check_ok(self): 'sources': [], 'depends_on': {'macros': [], 'nodes': []}, 'database': 'test_db', + 'deferred': False, 'description': '', 'schema': 'test_schema', 'alias': 'bar', diff --git a/test/unit/test_manifest.py b/test/unit/test_manifest.py index e7d25489ed4..9acc26a9edf 100644 --- a/test/unit/test_manifest.py +++ b/test/unit/test_manifest.py @@ -30,6 +30,7 @@ 'depends_on', 'database', 'schema', 'name', 'resource_type', 'package_name', 'root_path', 'path', 'original_file_path', 'raw_sql', 'description', 'columns', 'fqn', 'build_path', 'patch_path', 'docs', + 'deferred', }) REQUIRED_COMPILED_NODE_KEYS = frozenset(REQUIRED_PARSED_NODE_KEYS | {