ref uses most recently referenced project rather than current #1504
Labels
bug
Something isn't working
good_first_issue
Straightforward + self-contained changes, good for new contributors!
Milestone
Issue
The expected behavior for a reference with no specified project like
{{ref('model_one')}}
is that it will refer to the model "model_one" in the current project. However this is not the case when a ref earlier in the model specifies a project of its own. For instance were I to define a model in a project named "A" with these contents:SELECT * FROM {{ref('B', 'model_one')}}, {{ref('model_two')}}
, and then rundbt docs generate
both model_one and model_two will be searched for in project "B", and dbt will throw an error (in this case, model_two is in the "A" project).I believe this is due to the variable target_model_package being assigned in the outer loop of method process_refs. https://github.com/fishtown-analytics/dbt/blob/master/core/dbt/parser/util.py#L163-L169 This causes each ref within a node to use the target_model_package of the previous ref as its default target_model_package, rather than None as I believe was intended.
While based on my reading of the docs and code I don't believe this is the intended behavior, if it is I would argue it should be changed. Having the order in which refs occur change the model they point at could for instance cause a stylistic change like refactoring a query to move part of it into a CTE to have a functional impact.
If this is indeed an issue I'd like to volunteer to make a PR for it!
Issue description
Profile type "redshift"
Results
System information
The output of
dbt --version
:The operating system you're running on:
Mac OS Mojave 10.14
The python version you're using (probably the output of
python --version
)Python 3.6.2
Steps to reproduce
3.delete the default example models in the models folder
packages:
"""
The text was updated successfully, but these errors were encountered: