-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CT-3068] [Bug] relative node paths incl. "../../../" in dbt_project.yml completely destroy repository #8541
Comments
Before you recommend us to use packages instead of relative paths:
|
@jaklan Thanks for opening. To better understand the use case, in the example you've provided, are the "common" models:
That will help me in understanding whether your primary goal is to (a) split up a single monolithic project, or (b) to reuse model templates across multiple regions/instances. Today,
The alternative pattern, which you mention in your comment, is to use "local" packages: # projects/emea/germany/packages.yml
packages:
- local: "../../common/dbt"
- local: "../../../../common/dbt" Here's what I'm thinking: In an ideal world, both of these patterns would work. But we would prioritize and strongly recommend using Your point about the documentation saying, "Local packages should only be used for specific situations" — I think we should just update our docs! Multi-project monorepos are another legit use case for local packages. I think the pattern I like the most is running dbt from the root of your monorepo, and installing the appropriate packages based on what you need at a given point in time: # packages.yml (root)
packages:
- local: common/dbt
- local: projects/emea/common/dbt
- local: projects/emea/germany/dbt Proposed next stepsIn rough order of priority:
|
Hi @jtcohen6! @jaklan asked me to answer your query:
I'd say the latter, "template" models. There are some models that technically could be built once and then referenced downstream by each affiliate, but this adds complexity from a maintainability perspective as we can have both a model that uses a country var macro as well as one that doesn't coming from the same source system (which we organize by in our staging layers). I suppose the answer is technically both (and I'm sure there are others that implement this pattern), but in practice for us it's only the latter. |
Context: dbt-labs/dbt-core#8541 (comment) ## What are you changing in this pull request and why? There are multiple legitimate use cases for 'local' packages, beyond the one that's currently documented — especially as we see more multi-project setups.
I see the fix was merged. Will this be coming in the next release? |
Is this a new bug in dbt-core?
Current Behavior
Defining node (model, seed etc.) paths in
dbt_project.yml
as the relative ones can completely destroy your repository as the compiled nodes doesn't stay intarget/compiled/
directory, but they are moved up in the file hierarchy:../
would be located intarget/<dbt project name>/
(instead oftarget/compiled/<dbt project name>/
)../../
would be located directly intarget/
../../../
and deeper would be moved outsidetarget/
directory and become the parts of the actual git repository!Expected Behavior
All the compiled nodes should stay in
target/compiled
directory, no matter if the node paths are relative or not.Potential solution: instead of recreating the directory structure of specified nodes, that structure should be reflected in single directory name, e.g.
../../../../common/dbt/models
after compilation should go totarget/compiled/<dbt project name>/..-..-..-..-common-dbt-models
(or anything similar as that approach would make the directory hidden on Unix-like operating systems).Steps To Reproduce
We use
dbt
in monorepo. Our structure looks like:dbt_project.yml
for Germany looks then:When you run
dbt compile
, 3 things happen:projects/emea/germany/dbt/target/compiled/<German dbt project name>/models
which is fine
projects/emea/germany/dbt/target/common/dbt/models
(🚨)which is not fine, because the models are located 2 levels higher, outside
compiled
sub-directory - but they still fit inside thetarget
oneprojects/emea/germany/common/dbt/models
(🚨🚨🚨)which is a complete disaster - models are moved 4 levels higher, so they leave
target
directory and become the parts of the actual repository!Relevant log output
No response
Environment
Which database adapter are you using with dbt?
redshift
Additional Context
No response
The text was updated successfully, but these errors were encountered: