From 5664422a5e07702fd132f95491a70eb677283d28 Mon Sep 17 00:00:00 2001 From: Jeremy Cohen Date: Mon, 5 Aug 2024 16:47:57 -0400 Subject: [PATCH] Add unit test --- tests/unit/graph/test_selector.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/unit/graph/test_selector.py b/tests/unit/graph/test_selector.py index 48b3c78436c..2d3dfd1a8cd 100644 --- a/tests/unit/graph/test_selector.py +++ b/tests/unit/graph/test_selector.py @@ -297,3 +297,25 @@ def test_dependency_list(self, runtime_config: RuntimeConfig): queue.get(block=False) queue.mark_done(got.unique_id) assert queue.empty() + + def test_select_downstream_of_empty_model(self, runtime_config: RuntimeConfig): + # empty model + model_one = make_model(pkg="other", name="model_one", code="") + # non-empty model + model_two = make_model( + pkg="pkg", + name="model_two", + code="""select * from {{ref('model_one')}}""", + refs=[model_one], + ) + models = [model_one, model_two] + manifest = make_manifest(nodes=models) + + # Get the graph + compiler = dbt.compilation.Compiler(runtime_config) + graph = compiler.compile(manifest) + + # Ensure that model_two is selected as downstream of model_one + selector = NodeSelector(graph, manifest) + spec = graph_selector.SelectionCriteria.from_single_spec("model_one+") + assert selector.get_selected(spec) == {"model.pkg.model_two"}