Skip to content

Commit 5eaf015

Browse files
authored
Fix: dbt manifest can have null macro dependencies that translate into 'None' (#5367)
1 parent c1291d4 commit 5eaf015

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

sqlmesh/dbt/manifest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ def _macro_references(
661661
return result
662662

663663
for macro_node_id in node.depends_on.macros:
664-
if not macro_node_id:
664+
if not macro_node_id or macro_node_id == "None":
665665
continue
666666

667667
macro_node = manifest.macros[macro_node_id]

tests/dbt/test_manifest.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,3 +304,23 @@ def test_convert_jinja_test_to_macro():
304304
{%- endmacro -%}"""
305305

306306
assert _convert_jinja_test_to_macro(macro_input) == macro_input
307+
308+
309+
@pytest.mark.xdist_group("dbt_manifest")
310+
def test_macro_depenency_none_str():
311+
project_path = Path("tests/fixtures/dbt/sushi_test")
312+
profile = Profile.load(DbtContext(project_path))
313+
helper = ManifestHelper(
314+
project_path,
315+
project_path,
316+
"sushi",
317+
profile.target,
318+
model_defaults=ModelDefaultsConfig(start="2020-01-01"),
319+
)
320+
node = helper._manifest.nodes["model.customers.customer_revenue_by_day"]
321+
node.depends_on.macros.append("None")
322+
323+
from sqlmesh.dbt.manifest import _macro_references
324+
325+
# "None" macro shouldn't raise a KeyError
326+
_macro_references(helper._manifest, node)

0 commit comments

Comments
 (0)