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 #5087

Closed
1 task done
mirnawong1 opened this issue Mar 15, 2024 · 0 comments · Fixed by #5138
Closed
1 task done

Clarify statement blocks macro #5087

mirnawong1 opened this issue Mar 15, 2024 · 0 comments · Fixed by #5138
Assignees
Labels
content Improvements or additions to content improvement Use this when an area of the docs needs improvement as it's currently unclear

Comments

@mirnawong1
Copy link
Contributor

mirnawong1 commented Mar 15, 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

@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') }}

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

https://docs.getdbt.com/reference/dbt-jinja-functions/statement-blocks

Additional information

No response

@mirnawong1 mirnawong1 added content Improvements or additions to content improvement Use this when an area of the docs needs improvement as it's currently unclear labels Mar 15, 2024
@mirnawong1 mirnawong1 self-assigned this Mar 15, 2024
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
Development

Successfully merging a pull request may close this issue.

1 participant