Skip to content

Commit

Permalink
Consider granularity, which was added in dbt 1.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
syou6162 committed Dec 10, 2024
1 parent f8c8585 commit d6ae2ad
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/test_column_level_knowledge_propagator.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# %%
import json
import os
from pathlib import Path

import dbt.version
import pytest
from dbt.contracts.graph.manifest import Manifest
from packaging.version import Version

from dbt_osmosis.core.column_level_knowledge_propagator import (
ColumnLevelKnowledgePropagator,
_build_node_ancestor_tree,
_inherit_column_level_knowledge,
)

dbt_version = Version(dbt.version.get_installed_version().to_version_string())


def load_manifest() -> Manifest:
manifest_path = Path(__file__).parent.parent / "demo_duckdb/target/manifest.json"
Expand All @@ -21,9 +23,6 @@ def load_manifest() -> Manifest:
return Manifest.from_dict(manifest_dict)


# %%


def test_build_node_ancestor_tree():
manifest = load_manifest()
target_node = manifest.nodes["model.jaffle_shop_duckdb.customers"]
Expand Down Expand Up @@ -127,12 +126,13 @@ def test_inherit_column_level_knowledge():
"quote": None,
},
}
if dbt_version >= Version("1.9.0"):
for key in expect.keys():
expect[key]["granularity"] = None

target_node = manifest.nodes["model.jaffle_shop_duckdb.customers"]
family_tree = _build_node_ancestor_tree(manifest, target_node)
placeholders = [""]
actual = _inherit_column_level_knowledge(manifest, family_tree, placeholders)
print(expect)
print(actual)
assert _inherit_column_level_knowledge(manifest, family_tree, placeholders) == expect


Expand Down

0 comments on commit d6ae2ad

Please sign in to comment.