Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #8544: Parse the correct schema version from manifest #8551

Merged
merged 4 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20230906-162427.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Parse the correct schema version from manifest
time: 2023-09-06T16:24:27.849069+01:00
custom:
Author: aranke
Issue: "8544"
3 changes: 2 additions & 1 deletion core/dbt/contracts/graph/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,8 @@
schema_version = dct.get("metadata", {}).get("dbt_schema_version", None)
if not schema_version:
raise ValueError("Manifest doesn't have schema version")
return int(schema_version.split(".")[-2][-1])

return int(schema_version.split("/")[-1].split(".")[0][1:])

Check warning on line 1532 in core/dbt/contracts/graph/manifest.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/contracts/graph/manifest.py#L1532

Added line #L1532 was not covered by tests
aranke marked this conversation as resolved.
Show resolved Hide resolved


def _check_duplicates(value: BaseNode, src: Mapping[str, BaseNode]):
Expand Down
19 changes: 16 additions & 3 deletions tests/functional/artifacts/test_previous_version_state.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import pytest
import json
import os
import shutil
from dbt.tests.util import run_dbt, get_manifest

import pytest

from dbt.contracts.graph.manifest import WritableManifest, get_manifest_schema_version
from dbt.exceptions import IncompatibleSchemaError
from dbt.contracts.graph.manifest import WritableManifest
from dbt.tests.util import run_dbt, get_manifest

# This project must have one of each kind of node type, plus disabled versions, for
# test coverage to be complete.
Expand Down Expand Up @@ -352,3 +355,13 @@ def test_nonbackwards_compatible_versions(self, project):
# schema versions 1, 2, 3 are all not forward compatible
for schema_version in range(1, 4):
self.compare_previous_state(project, schema_version, False, 0)

def test_get_manifest_schema_version(self, project):
for schema_version in range(1, self.CURRENT_EXPECTED_MANIFEST_VERSION):
manifest_path = os.path.join(
project.test_data_dir, f"state/v{schema_version}/manifest.json"
)
manifest = json.load(open(manifest_path))

manifest_version = get_manifest_schema_version(manifest)
assert manifest_version == schema_version