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

clean subgraph before identifying boundary in split operation #144

Merged
merged 3 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 2 additions & 3 deletions dbt_meshify/storage/dbt_project_editors.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ def _get_subproject_boundary_models(self) -> Set[str]:
"""
nodes = set(filter(lambda x: not x.startswith("source"), self.subproject.resources)) # type: ignore
parent_project_name = self.subproject.parent_project.name # type: ignore
interface = ResourceGrouper.identify_interface(
graph=self.subproject.graph.graph, selected_bunch=nodes
)
cleaned_graph = ResourceGrouper.clean_subgraph(self.subproject.graph.graph)
interface = ResourceGrouper.identify_interface(graph=cleaned_graph, selected_bunch=nodes)
boundary_models = set(
filter(
lambda x: (x.startswith("model") and x.split(".")[1] == parent_project_name),
Expand Down
10 changes: 10 additions & 0 deletions test-projects/split/split_proj/models/marts/__models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,13 @@ models:
description: A boolean indicating if this order included any food items.
- name: is_drink_order
description: A boolean indicating if this order included any drink items.


- name: leaf_node
description: A leaf node model that is not referenced by any other model.
columns:
- name: order_id
description: The unique key of the leaf node.
tests:
- not_null
- unique
1 change: 1 addition & 0 deletions test-projects/split/split_proj/models/marts/leaf_node.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
select 1 as order_id
30 changes: 30 additions & 0 deletions tests/integration/test_split_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,33 @@ def test_split_project_cycle(self):
assert result.exit_code == 1

teardown_test_project(dest_project_path)

def test_split_public_leaf_nodes(self, project):
"""
asserts that the split command will split out a model that is a leaf node mark it as public
"""
setup_test_project(src_project_path, dest_project_path)
runner = CliRunner()
result = runner.invoke(
cli,
[
"split",
"my_new_project",
"--project-path",
dest_project_path,
"--select",
"+leaf_node",
],
)

assert result.exit_code == 0
assert (
Path(dest_project_path) / "my_new_project" / "models" / "marts" / "leaf_node.sql"
).exists()
# this is lazy, but this should be the only model in that yml file
assert (
"access: public"
in (
Path(dest_project_path) / "my_new_project" / "models" / "marts" / "__models.yml"
).read_text()
)