From bcf8240e48abfd6ca7a8d423ded19f102b8eb865 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Fri, 14 Apr 2023 16:34:22 -0400 Subject: [PATCH 1/3] test statically parsed two-argument ref --- core/dbt/parser/models.py | 2 +- test/unit/test_graph.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/core/dbt/parser/models.py b/core/dbt/parser/models.py index 85fb233588a..2cd6d848231 100644 --- a/core/dbt/parser/models.py +++ b/core/dbt/parser/models.py @@ -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[0], ref[1] refs.append(RefArgs(package=package, name=name)) diff --git a/test/unit/test_graph.py b/test/unit/test_graph.py index 47f09aed873..5bee5613236 100644 --- a/test/unit/test_graph.py +++ b/test/unit/test_graph.py @@ -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( { From 1a251f27bd55b94a70fd168d5734001e66b34e05 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Fri, 14 Apr 2023 16:36:47 -0400 Subject: [PATCH 2/3] changelog entry --- .changes/unreleased/Fixes-20230414-163642.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Fixes-20230414-163642.yaml diff --git a/.changes/unreleased/Fixes-20230414-163642.yaml b/.changes/unreleased/Fixes-20230414-163642.yaml new file mode 100644 index 00000000000..7ba3cc58201 --- /dev/null +++ b/.changes/unreleased/Fixes-20230414-163642.yaml @@ -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" From 90bee644c4f4d2fde74b12b4fb47d0de36de98c4 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Mon, 17 Apr 2023 09:37:50 -0400 Subject: [PATCH 3/3] unpack tuple --- core/dbt/parser/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/dbt/parser/models.py b/core/dbt/parser/models.py index 2cd6d848231..1cd8c85579a 100644 --- a/core/dbt/parser/models.py +++ b/core/dbt/parser/models.py @@ -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], ref[1] + package, name = ref refs.append(RefArgs(package=package, name=name))