Skip to content

Commit

Permalink
Fix: avoid double-rendering sql_header in dbt show (#8740)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelleArk authored Sep 28, 2023
1 parent 0c965c8 commit 408a789
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20230928-184856.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: avoid double-rendering sql_header in dbt show
time: 2023-09-28T18:48:56.419428+01:00
custom:
Author: michelleark
Issue: "8739"
2 changes: 0 additions & 2 deletions core/dbt/include/global_project/macros/adapters/show.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{% macro get_show_sql(compiled_code, sql_header, limit) -%}
{%- set sql_header = sql_header -%}
{{ sql_header if sql_header is not none }}
{%- if sql_header -%}
{{ sql_header }}
{%- endif -%}
Expand Down
6 changes: 4 additions & 2 deletions tests/adapter/dbt/tests/adapter/dbt_show/fixtures.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
models__sql_header = """
{% call set_sql_header(config) %}
set session time zone '{{ var("timezone", "Europe/Paris") }}';
with _variables as (
select 1 as my_variable
)
{%- endcall %}
select current_setting('timezone') as timezone
select my_variable from _variables
"""

models__ephemeral_model = """
Expand Down
1 change: 0 additions & 1 deletion tests/adapter/dbt/tests/adapter/dbt_show/test_dbt_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def models(self):
}

def test_sql_header(self, project):
run_dbt(["build", "--vars", "timezone: Asia/Kolkata"])
run_dbt(["show", "--select", "sql_header", "--vars", "timezone: Asia/Kolkata"])


Expand Down

0 comments on commit 408a789

Please sign in to comment.