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

[CT-3071] [Bug] failed to resolve schema version #8544

Closed
2 tasks done
qrtt1 opened this issue Sep 4, 2023 · 2 comments · Fixed by #8551 · May be fixed by #10437
Closed
2 tasks done

[CT-3071] [Bug] failed to resolve schema version #8544

qrtt1 opened this issue Sep 4, 2023 · 2 comments · Fixed by #8551 · May be fixed by #10437
Assignees
Labels
backport 1.6.latest bug Something isn't working Highest Severity critical bug that must be resolved immediately
Milestone

Comments

@qrtt1
Copy link

qrtt1 commented Sep 4, 2023

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

The latest get_manifest_schema_version will get wrong versions and drop the metrics data:

https://github.com/dbt-labs/dbt-core/blob/v1.6.1/core/dbt/contracts/graph/manifest.py

def get_manifest_schema_version(dct: dict) -> int:
    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])

This input will get 0

https://schemas.getdbt.com/dbt/manifest/v10.json

And it will make scheam upgrader to drop metrics data
https://github.com/dbt-labs/dbt-core/blob/v1.6.1/core/dbt/contracts/graph/manifest_upgrade.py#L65-L69

def upgrade_manifest_json(manifest: dict, manifest_schema_version: int) -> dict:
    # this should remain 9 while the check in `upgrade_schema_version` may change
    if manifest_schema_version <= 9:
        drop_v9_and_prior_metrics(manifest=manifest)
   ...

Expected Behavior

The metrics data should be kept

Steps To Reproduce

  1. use the dbt 1.6 project with metrics (https://github.com/InfuseAI/jaffle-sl-template)
  2. create the state directory dbt parse --target-path baseline
  3. modify some metrics criteria
  4. select modified and nothing selected dbt list -s 'state:modified' --state baseline
image

Relevant log output

No response

Environment

- OS: OSX
- Python: 3.10.6
- dbt:


Core:
  - installed: 1.6.1
  - latest:    1.6.1 - Up to date!

Plugins:
  - snowflake: 1.6.1 - Update available!
  - duckdb:    1.6.0 - Up to date!

  At least one plugin is out of date or incompatible with dbt-core.
  You can find instructions for upgrading here:
  https://docs.getdbt.com/docs/installation


### Which database adapter are you using with dbt?

other (mention it in "Additional Context")

### Additional Context

_No response_
@qrtt1 qrtt1 added bug Something isn't working triage labels Sep 4, 2023
@github-actions github-actions bot changed the title [Bug] failed to resolve schema version [CT-3071] [Bug] failed to resolve schema version Sep 4, 2023
@jtcohen6 jtcohen6 added this to the v1.6.x milestone Sep 4, 2023
@jtcohen6
Copy link
Contributor

jtcohen6 commented Sep 5, 2023

@qrtt1 Thanks for opening! This is definitely a bug, and one we should resolve quickly, since it will affect anyone who's upgrading to v1.6.

This is a naive fix:

import re
...
def get_manifest_schema_version(dct: dict) -> int:
    schema_version = dct.get("metadata", {}).get("dbt_schema_version", None)
    if not schema_version:
        raise ValueError("Manifest doesn't have schema version")
    match_str = "v([0-9]+)"
    return int(re.search(match_str, schema_version).groups()[0])
>>> schema_version = "https://schemas.getdbt.com/dbt/manifest/v10.json"
>>> match_str = "v([0-9]+)"
>>> int(re.search(match_str, schema_version).groups()[0])
10

We should also figure out why this errant behavior wasn't being caught in our test for manifest version upgrades / backward compatibility: https://github.com/dbt-labs/dbt-core/blob/main/tests/functional/artifacts/test_previous_version_state.py

@aranke
Copy link
Member

aranke commented Sep 5, 2023

I'm able to replicate this issue and updated the test case to fail: #8551.

I'll now work on updating the code to make the test case pass.

@graciegoheen graciegoheen added the Highest Severity critical bug that must be resolved immediately label Sep 6, 2023
aranke added a commit that referenced this issue Sep 6, 2023
* Fix #8544: Parse the correct schema version from manifest

* add changie

* add comment
emmyoop added a commit that referenced this issue Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.6.latest bug Something isn't working Highest Severity critical bug that must be resolved immediately
Projects
None yet
4 participants