-
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
Package project yml configs overriding root project configs #3698
Comments
@fivetran-jamie Thanks for the really detailed write-up! Sorry for the delay getting back to you. I've been able to reproduce the bug, it's just a real head-scratcher to figure out what's going on here. I do think the peculiarities of the source freshness task have something to do with this one. Unlike other tasks, which generate a runtime context, compile SQL, and then execute that compiled SQL within a materialization, the freshness task jumps straight to the finish: find and execute a certain macro using a There are two things working right:
However:
I dropped a debugger in here: macro_context.update(context_override)
if 'collect_freshness' in macro.unique_id:
import ipdb; ipdb.set_trace()
macro_function = Macro
Generator(macro, macro_context) When I just wrap the macro in ipdb> from dbt.clients.jinja import get_rendered
ipdb> get_rendered("{{ fivetran_utils.collect_freshness('zendesk.ticket_form_history') }}", macro_context)
'| column | data_type |\n| -------------- | --------- |\n| max_loaded_at | DateTime |\n| snapshotted_at | DateTime |\n' But when I follow the actual codepath, and execute the macro using
When I try to just get the rendered variable value on its own, it doesn't appear to be accessible (??), but at least it shows me the correct value ( ipdb> get_rendered("{{ var('using_ticket_form_history') }}", macro_context)
*** dbt.exceptions.CompilationException: Compilation Error in macro collect_freshness (macros/collect_freshness.sql)
Required var 'using_ticket_form_history' not found in config:
Vars supplied to collect_freshness = {
"zendesk_source": {
"using_ticket_form_history": false
}
} I want to confirm whether I'm arriving at the right distinction: @gshank I think you know the most about rendering contexts today, so I'd be curious to hear if what I've laid out above seems like the right thread to pull on, or if I've totally missed the boat. |
I took another look at this one, just to see if anything new has clicked. I think this is not specific to the execution of source freshness, as opposed to what I said above. After all, in As a separate matter, I do think there's a better way to achieve this functionality, rather than overriding the - name: ticket_form_history
description: Ticket forms allow an admin to define a subset of ticket fields for display to both agents and end users.
freshness: "{{ ({} if var('using_ticket_form_history', true) else none) | as_native }}" This prevents the freshness check from running at all for this table when Ultimately, I'd like to see us do unto sources as we've done unto other resource types (#3662):
|
I am also running into what I think is the same issue when developing packages. Using the jaffle shop example on this branch. Customers model enabled using the
Generic tests on customers model are also enabled using
With this setup, given |
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please remove the stale label or comment on the issue, or it will be closed in 7 days. |
Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest; add a comment to notify the maintainers. |
@jtcohen6 I understand this was closed for inactivity but do you know was there a planned resoltuion for this? I am seeing the same issue with variable priority - a variable defined in a package yaml is being prioritised over the project yaml overwrite when that variable is called from within a schema yaml within the package? |
Describe the bug
A clear and concise description of what the bug is. What command did you run? What happened?
I installed this branch of the zendesk_source package in my root project. This branch uses the custom collect_freshness macro we built in order to disable (or rather, automatically pass) freshness tests for source tables that the user has elected to disable (note: the
source
entity itself is not configured/disabled, but rather the staging models drawing from these source tables are disabled). When variables (such asusing_ticket_form_history
) are defined in the package's owndbt_project.yml
file, the package-provided value overrides any value provided in the root project file. I am unable to disable/pass freshness tests (usingdbt source snapshot-freshness --select zendesk.ticket_form_history
) by setting the appropriate variable tofalse
in my root project (but if i change the package-defined variable tofalse
, it passes).Note: I am only seeing this conflict with freshness tests. When i provide
using_ticket_form_history
in my root project (false
in my project yml andtrue
in the package yml) and executedbt run
, the respective staging models that are appropriately disabled by the variable. So perhaps this has to do with thecollect_freshness
macro being a part of dbt core rather than utils or anything?Steps To Reproduce
In as much detail as possible, please provide steps to reproduce the issue. Sample data that triggers the issue, example model code, etc is all very helpful here.
bug/disable-freshness
branch of thezendesk_source
packagedbt_modules/zendesk_source/dbt_project.yml
Run
dbt source snapshot-freshness --select zendesk.ticket_form_history
Expected: freshness test should pass, since we have chosen to disable/automatically pass freshness tests for this table
Actual: freshness test fails (presuming you do not have this table or just have stale data)
Change
using_ticket_form_history
to false indbt_modules/zendesk_source/dbt_project.yml
Run
dbt source snapshot-freshness --select zendesk.ticket_form_history
This passes, which makes it seem like dbt is indeed grabbing the variable value from the package yml
Removing the variable from the package project yml allows me to disable freshness tests from my root project yml, but a good deal of our packages have these default-set variables in their
dbt_project.yml
files, so just trying to figure out if we need to remove those in order for this solution to continue to work.Expected behavior
A clear and concise description of what you expected to happen.
(see bold text in steps to reproduce ^)
Screenshots and log output
If applicable, add screenshots or log output to help explain your problem.
System information
Which database are you using dbt with?
The output of
dbt --version
:The operating system you're using:
MacOS
The output of
python --version
:Python 3.8.9
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: