Skip to content

Commit

Permalink
[sc-29648] Use init_virtual_view to get or create the source model …
Browse files Browse the repository at this point in the history
…in `depends_on`
  • Loading branch information
usefulalgorithm committed Oct 31, 2024
1 parent 962839d commit ff10f19
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
19 changes: 16 additions & 3 deletions metaphor/dbt/cloud/parser/common.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import json
from typing import Dict, List, Union
from typing import Callable, Dict, List, Union

from metaphor.common.entity_id import EntityId
from metaphor.common.utils import dedup_lists, unique_list
from metaphor.dbt.util import build_system_tags, get_virtual_view_id
from metaphor.dbt.util import (
build_system_tags,
get_model_name_from_unique_id,
get_snapshot_name_from_unique_id,
get_virtual_view_id,
init_virtual_view,
)
from metaphor.models.metadata_change_event import (
Dataset,
DbtMacro,
Expand Down Expand Up @@ -35,10 +41,17 @@ def parse_depends_on(
or None
)

def get_source_model_name(n: str) -> Callable[[str], str]:
if n.startswith("model."):
return get_model_name_from_unique_id
if n.startswith("snapshot."):
return get_snapshot_name_from_unique_id
assert False

Check warning on line 49 in metaphor/dbt/cloud/parser/common.py

View check run for this annotation

Codecov / codecov/patch

metaphor/dbt/cloud/parser/common.py#L45-L49

Added lines #L45 - L49 were not covered by tests

target.source_models = (
unique_list(
[
get_virtual_view_id(virtual_views[n].logical_id) # type: ignore
get_virtual_view_id(init_virtual_view(virtual_views, n, get_source_model_name).logical_id) # type: ignore
for n in depends_on
if n.startswith("model.") or n.startswith("snapshot.")
]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "metaphor-connectors"
version = "0.14.140"
version = "0.14.141"
license = "Apache-2.0"
description = "A collection of Python-based 'connectors' that extract metadata from various sources to ingest into the Metaphor app."
authors = ["Metaphor <[email protected]>"]
Expand Down

0 comments on commit ff10f19

Please sign in to comment.