Skip to content

Commit

Permalink
Amended run_query macro
Browse files Browse the repository at this point in the history
  • Loading branch information
xemuliam authored Jan 24, 2025
1 parent 8a8aa48 commit 261e516
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions dbt/include/global_project/macros/etc/statement.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,26 @@ The macro override naming method (spark__statement) only works for macros which


{# a user-friendly interface into statements #}
{% macro run_query(sql) %}
{% macro run_query(sql, bulk=True) %}

{%- if bulk -%}
{%- for query in sql.split(';') -%}
{%- if query | trim | length > 0 -%}
{% do return(exec_statement(query)) %}
{%- endif -%}
{%- endfor -%}
{%- else -%}
{% do return(exec_statement(sql)) %}
{%- endif -%}

{% endmacro %}

{% macro exec_statement(sql_statement) %}

{% call statement("run_query_statement", fetch_result=true, auto_begin=false) %}
{{ sql }}
{{ sql_statement }}
{% endcall %}

{% do return(load_result("run_query_statement").table) %}

{% endmacro %}

0 comments on commit 261e516

Please sign in to comment.