Skip to content

Commit a677000

Browse files
authored
Fix: make sure builtin dbt macros can be referenced with the 'context.' prefix (#5308)
1 parent a6468f5 commit a677000

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

sqlmesh/dbt/builtin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ def create_builtin_globals(
545545

546546
builtin_globals["run_started_at"] = jinja_globals.get("execution_dt") or now()
547547
builtin_globals["dbt"] = AttributeDict(builtin_globals)
548+
builtin_globals["context"] = builtin_globals["dbt"]
548549

549550
return {**builtin_globals, **jinja_globals}
550551

tests/dbt/test_transformation.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,6 +1435,13 @@ def test_flags(sushi_test_project: Project):
14351435
assert context.render("{{ flags.WHICH }}") == "parse"
14361436

14371437

1438+
@pytest.mark.xdist_group("dbt_manifest")
1439+
def test_context_namespace(sushi_test_project: Project):
1440+
context = sushi_test_project.context
1441+
1442+
assert context.render("{{ context.flags.FULL_REFRESH }}") == "None"
1443+
1444+
14381445
@pytest.mark.xdist_group("dbt_manifest")
14391446
def test_relation(sushi_test_project: Project):
14401447
context = sushi_test_project.context

0 commit comments

Comments
 (0)