Skip to content

Commit

Permalink
Improve checking of schema version for pre-1.0.0 manifests (#4497)
Browse files Browse the repository at this point in the history
* [#4470] Improve checking of schema version for pre-1.0.0 manifests

* Check exception code instead of message in test

automatic commit by git-black, original commits:
  067b861
  • Loading branch information
gshank authored and iknox-fa committed Feb 8, 2022
1 parent e36e214 commit 4bd0687
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions core/dbt/contracts/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,13 @@ def read_and_check_versions(cls, path: str):
# Check metadata version. There is a class variable 'dbt_schema_version', but
# that doesn't show up in artifacts, where it only exists in the 'metadata'
# dictionary.
if hasattr(cls, 'dbt_schema_version'):
if 'metadata' in data and 'dbt_schema_version' in data['metadata']:
previous_schema_version = data['metadata']['dbt_schema_version']
if hasattr(cls, "dbt_schema_version"):
if "metadata" in data and "dbt_schema_version" in data["metadata"]:
previous_schema_version = data["metadata"]["dbt_schema_version"]
# cls.dbt_schema_version is a SchemaVersion object
if str(cls.dbt_schema_version) != previous_schema_version:
raise IncompatibleSchemaException(
expected=str(cls.dbt_schema_version),
found=previous_schema_version
expected=str(cls.dbt_schema_version), found=previous_schema_version
)

return cls.from_dict(data) # type: ignore
Expand Down

0 comments on commit 4bd0687

Please sign in to comment.