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

Clarify statement blocks macro need ref #5138

Merged
merged 27 commits into from
Mar 28, 2024
Merged

Clarify statement blocks macro need ref #5138

merged 27 commits into from
Mar 28, 2024

Conversation

mirnawong1
Copy link
Contributor

@Tonayya raised that the example code for statement blocks here doesn't actually work. We should fix this up so users don't get confused:

So if you actually run this:

{%- call statement('states', fetch_result=True) -%}

select distinct state from {{ ref('users') }}

{%- endcall -%}
dbt won't know how to resolve the reference so it needs to be specified somewhere. So this can either be done using -- depends_on or doing a ref() function outside the statement block:

Option A:
-- depends_on: {{ ref('abc') }}

{% call statement('st') %}

select * from {{ ref('abc') }}

{% endcall %}

select 2 as id
Option B:
{%- call statement('st') -%}

select * from {{ ref('abc') }}

{%- endcall -%}

select id * 2 as id from {{ ref('abc') }}

Resolves #5087

@mirnawong1 mirnawong1 requested a review from a team as a code owner March 22, 2024 13:53
Copy link

vercel bot commented Mar 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-getdbt-com ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 27, 2024 9:14pm

@github-actions github-actions bot added content Improvements or additions to content Docs team Authored by the Docs team @dbt Labs size: small This change will take 1 to 2 days to address labels Mar 22, 2024
@mirnawong1
Copy link
Contributor Author

thanks so much @joellabes ! folded in you suggs and the preview looks good i think!

@mirnawong1
Copy link
Contributor Author

if you're ok with it, will merge it this week!

@mirnawong1 mirnawong1 merged commit 3965bb7 into current Mar 28, 2024
8 checks passed
@mirnawong1 mirnawong1 deleted the statement-blocks branch March 28, 2024 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto update content Improvements or additions to content Docs team Authored by the Docs team @dbt Labs size: small This change will take 1 to 2 days to address
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clarify statement blocks macro
2 participants