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

Amendment for run_query macro #656

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,22 @@ 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=False) %}
{%- 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) %}
Expand Down
Loading