dbt-unit-testing: `ref` and `source` overrides not working when importing models from another project
Hello !
I found a bug in the ref()
(and potentially also in source()
) macro override. Here’s the setup to reproduce :
- Create a dbt project
project_a
in which you createmodel_a
- Then, create a dbt project
project_b
in which :- you create
model_b
that usesmodel_a
- you add the dependency to
dbt-unit-testing
inpackages.yml
- you add the macro override for
ref()
andsource()
- you create
- In
project_a
importproject_b
as a package, depending on your setup, it will look like :packages: - local: "../../../project_b"
Now, if you try to perform a dbt ls
command from project_a
, you’ll have the following error :
Compilation Error
Model 'model.project_b.model_b' (models/model_b.sql) depends on a node named 'model_a' in package or project 'project_b' which was not found
But if you remove the macro override for ref()
it will work just fine.
-> The issue is that now it simply performs a look-up in the project in which the model is defined and not in the project that imports the model which contains the model in this case
About this issue
- Original URL
- State: closed
- Created 7 months ago
- Reactions: 1
- Comments: 18 (6 by maintainers)
Hi @rantibi, your test file is in
common
or inmy_project
? And in which are you running thedbt test
command?It seems to have worked indeed thank’s!
Oh ok, now it’s clear, thank you! 🙂
Let me try to find a way to fix this, not sure if it’s possible, we’ll see.
Thank you again for your report.
This seems to work, but not sure if 100% correct :