Compare commits

...

6 Commits

Author SHA1 Message Date
Jon Natkins
7508788e7e Improve changelog message and contributors addition 2021-05-24 11:44:14 -07:00
Jon Natkins
50906f9808 Merge branch 'develop' of github.com:jnatkins/dbt into dbt-3381 2021-05-22 07:49:01 -07:00
Jon Natkins
ec5ded0694 Update invalid snapshot test with new/improved error message 2021-05-22 07:47:37 -07:00
Jon Natkins
8ee8449dfa Update CHANGELOG.md 2021-05-21 18:02:13 -07:00
Jon Natkins
5677247c64 Add fix details to CHANGELOG 2021-05-21 17:59:55 -07:00
Jon Natkins
7893bb71ef Running a snapshot with missing required configurations results in uncaught Python exception (#3381)
* Running a snapshot with missing required configurations results in uncaught Python exception
2021-05-21 17:53:33 -07:00
4 changed files with 24 additions and 1 deletions

View File

@@ -15,6 +15,7 @@
- Add a better error messages for undefined macros and when there are less packages installed than specified in `packages.yml`. ([#2999](https://github.com/fishtown-analytics/dbt/issues/2999))
- Separate `compiled_path` from `build_path`, and print the former alongside node error messages ([#1985](https://github.com/fishtown-analytics/dbt/issues/1985), [#3327](https://github.com/fishtown-analytics/dbt/pull/3327))
- Fix exception caused when running `dbt debug` with BigQuery connections ([#3314](https://github.com/fishtown-analytics/dbt/issues/3314), [#3351](https://github.com/fishtown-analytics/dbt/pull/3351))
- Raise better error if snapshot is missing required configurations ([#3381](https://github.com/fishtown-analytics/dbt/issues/3381), [#3385](https://github.com/fishtown-analytics/dbt/pull/3385))
### Under the hood
- Added logic for registry requests to raise a timeout error after a response hangs out for 30 seconds and 5 attempts have been made to reach the endpoint ([#3177](https://github.com/fishtown-analytics/dbt/issues/3177), [#3275](https://github.com/fishtown-analytics/dbt/pull/3275))
@@ -28,6 +29,7 @@ Contributors:
- [@majidaldo](https://github.com/majidaldo) ([#3134](https://github.com/fishtown-analytics/dbt/issues/3134))
- [@jaypeedevlin](https://github.com/jaypeedevlin) ([#2999](https://github.com/fishtown-analytics/dbt/issues/2999))
- [@PJGaetan](https://github.com/PJGaetan) ([#3315](https://github.com/fishtown-analytics/dbt/pull/3376))
- [@jnatkins](https://github.com/jnatkins) ([#3385](https://github.com/fishtown-analytics/dbt/pull/3385))
## dbt 0.20.0b1 (May 03, 2021)

View File

@@ -457,6 +457,11 @@ class SnapshotConfig(EmptySnapshotConfig):
@classmethod
def validate(cls, data):
super().validate(data)
if not data.get('strategy') or not data.get('unique_key') or not \
data.get('target_schema'):
raise ValidationError(
"Snapshots must be configured with a 'strategy', 'unique_key', "
"and 'target_schema'.")
if data.get('strategy') == 'check':
if not data.get('check_cols'):
raise ValidationError(

View File

@@ -531,7 +531,7 @@ class TestBadSnapshot(DBTIntegrationTest):
with self.assertRaises(dbt.exceptions.CompilationException) as exc:
self.run_dbt(['compile'], expect_pass=False)
self.assertIn('Compilation Error in model ref_snapshot', str(exc.exception))
self.assertIn('Snapshots must be configured with a \'strategy\'', str(exc.exception))
class TestCheckCols(TestSimpleSnapshotFiles):

View File

@@ -1343,6 +1343,22 @@ def test_invalid_missing_check_cols(basic_check_snapshot_config_dict):
del wrong_fields['check_cols']
with pytest.raises(ValidationError, match=r"A snapshot configured with the check strategy"):
SnapshotConfig.validate(wrong_fields)
def test_missing_snapshot_configs(basic_check_snapshot_config_dict):
wrong_fields = basic_check_snapshot_config_dict
del wrong_fields['strategy']
with pytest.raises(ValidationError, match=r"Snapshots must be configured with a 'strategy'"):
SnapshotConfig.validate(wrong_fields)
wrong_fields['strategy'] = 'timestamp'
del wrong_fields['unique_key']
with pytest.raises(ValidationError, match=r"Snapshots must be configured with a 'strategy'"):
SnapshotConfig.validate(wrong_fields)
wrong_fields['unique_key'] = 'id'
del wrong_fields['target_schema']
with pytest.raises(ValidationError, match=r"Snapshots must be configured with a 'strategy'"):
SnapshotConfig.validate(wrong_fields)
def test_invalid_check_value(basic_check_snapshot_config_dict):