Skip to content

Commit

Permalink
[Fix] Typo in statically parsed ref unpacking (#7365)
Browse files Browse the repository at this point in the history
test statically parsed two-argument ref

(cherry picked from commit 0891aef)
  • Loading branch information
MichelleArk authored and github-actions[bot] committed May 9, 2023
1 parent 70c98a5 commit d25e8b1
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20230414-163642.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: fix typo in unpacking statically parsed ref
time: 2023-04-14T16:36:42.279838-04:00
custom:
Author: MichelleArk
Issue: "7364"
2 changes: 1 addition & 1 deletion core/dbt/parser/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def populate(self, node: ModelNode, config: ContextConfig, statically_parsed: Di
if len(ref) == 1:
package, name = None, ref[0]
else:
package, name = ref[0], refs[1]
package, name = ref

refs.append(RefArgs(package=package, name=name))

Expand Down
31 changes: 31 additions & 0 deletions test/unit/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,37 @@ def test__two_models_simple_ref(self):
],
)

def test__two_models_package_ref(self):
self.use_models(
{
"model_one": "select * from events",
"model_two": "select * from {{ref('test_models_compile', 'model_one')}}",
}
)

config = self.get_config()
manifest = self.load_manifest(config)
compiler = self.get_compiler(config)
linker = compiler.compile(manifest)

self.assertCountEqual(
linker.nodes(),
[
"model.test_models_compile.model_one",
"model.test_models_compile.model_two",
],
)

self.assertCountEqual(
linker.edges(),
[
(
"model.test_models_compile.model_one",
"model.test_models_compile.model_two",
)
],
)

def test__model_materializations(self):
self.use_models(
{
Expand Down

0 comments on commit d25e8b1

Please sign in to comment.