Skip to content
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

add is_incremental as additional example of when you will need to force dependencies #5547

Closed
1 task
graciegoheen opened this issue May 22, 2024 · 2 comments · Fixed by #5550
Closed
1 task
Labels
content Improvements or additions to content improvement Use this when an area of the docs needs improvement as it's currently unclear

Comments

@graciegoheen
Copy link
Collaborator

graciegoheen commented May 22, 2024

Contributions

  • I have read the contribution docs, and understand what's expected of me.

Link to the page on docs.getdbt.com requiring updates

https://docs.getdbt.com/reference/dbt-jinja-functions/ref#forcing-dependencies

What part(s) of the page would you like to see updated?

We already have an example for when you need to force dependencies - a model that only has a macro.

Let's also add an example for when references are wrapped in the is_incremental() macro - see slack thread.

Dependencies nested in the is_incremental macro will not show up in lineage, so will need to force dependencies in that case.

Example

If you have an incremental model that includes a snippet like below, then you will not be able to see the source('raw', 'orders') upstream dependency in the lineage.

{% if is_incremental() %}
select * from {{ source('raw', 'orders') }}
{% endif %}

This is because the is_incremental macro will always return false at parse time, so anything buried inside that will not be available to parsing, so will not be added to depends_on.

So in this case, you'd need to do force a dependency outside of the is_incremental() conditional like this instead:

 -- depends_on: {{ source('raw', 'orders') }}

{% if is_incremental() %}
select * from {{ source('raw', 'orders') }}
{% endif %}
@graciegoheen graciegoheen added content Improvements or additions to content improvement Use this when an area of the docs needs improvement as it's currently unclear labels May 22, 2024
@runleonarun
Copy link
Collaborator

Thanks @graciegoheen! Anything you think we should add to the is_incremental macro docs?

runleonarun pushed a commit that referenced this issue May 22, 2024
@graciegoheen
Copy link
Collaborator Author

No I think this is enough!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Improvements or additions to content improvement Use this when an area of the docs needs improvement as it's currently unclear
Projects
None yet
2 participants