Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
Also, added more tests
  • Loading branch information
Jacob Beck committed Apr 1, 2020
1 parent 24051ef commit 9823cc6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
10 changes: 6 additions & 4 deletions core/dbt/graph/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,12 @@ def search(self, included_nodes, selector):
search = chain(self.parsed_nodes(included_nodes),
self.source_nodes(included_nodes))
for node, real_node in search:
if (
Path(real_node.root_path) == root and
Path(real_node.original_file_path) in paths
):
if Path(real_node.root_path) != root:
continue
ofp = Path(real_node.original_file_path)
if ofp in paths:
yield node
elif any(parent in paths for parent in ofp.parents):
yield node


Expand Down
17 changes: 13 additions & 4 deletions test/integration/007_graph_selection_tests/test_graph_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ def test__snowflake__specific_model_and_children(self):
self.assertFalse('BASE_USERS' in created_models)
self.assertFalse('EMAILS' in created_models)


@use_profile('postgres')
def test__postgres__specific_model_and_parents(self):
self.run_sql_file("seed.sql")
Expand Down Expand Up @@ -143,13 +142,12 @@ def test__snowflake__specific_model_and_parents(self):
self.assertFalse('BASE_USERS' in created_models)
self.assertFalse('EMAILS' in created_models)


@use_profile('postgres')
def test__postgres__specific_model_with_exclusion(self):
self.run_sql_file("seed.sql")

results = self.run_dbt(
['run', '--models', '+users_rollup', '--exclude', 'users_rollup']
['run', '--models', '+users_rollup', '--exclude', 'models/users_rollup.sql']
)
self.assertEqual(len(results), 1)

Expand Down Expand Up @@ -188,6 +186,17 @@ def test__postgres__locally_qualified_name(self):
self.assertIn('nested_users', created_models)
self.assert_correct_schemas()

results = self.run_dbt(['run', '--models', 'models/test/subdir*'])
self.assertEqual(len(results), 2)

created_models = self.get_models_in_schema()
self.assertNotIn('users_rollup', created_models)
self.assertNotIn('base_users', created_models)
self.assertNotIn('emails', created_models)
self.assertIn('subdir', created_models)
self.assertIn('nested_users', created_models)
self.assert_correct_schemas()

@use_profile('postgres')
def test__postgres__childrens_parents(self):
self.run_sql_file("seed.sql")
Expand Down Expand Up @@ -218,7 +227,7 @@ def test__postgres__more_childrens_parents(self):
@use_profile('snowflake')
def test__snowflake__skip_intermediate(self):
self.run_sql_file("seed.sql")
results = self.run_dbt(['run', '--models', '@users'])
results = self.run_dbt(['run', '--models', '@models/users.sql'])
# base_users, emails, users_rollup, users_rollup_dependency
self.assertEqual(len(results), 4)

Expand Down

0 comments on commit 9823cc6

Please sign in to comment.