Skip to content

Instantly share code, notes, and snippets.

@drewbanin
Created May 23, 2018 18:40
Show Gist options
  • Save drewbanin/da730cc17bbfd86359b1e425b9be6779 to your computer and use it in GitHub Desktop.
Save drewbanin/da730cc17bbfd86359b1e425b9be6779 to your computer and use it in GitHub Desktop.
{% set n = 100 %}
{%- call statement('test_result', fetch_result=True) -%}
-- data test
select 1 as id, 'Drew' as name
union all
select 2 as id, 'Connor' as name
limit {{ n }}
{%- endcall -%}
{%- set res = load_result('test_result')['table'] -%}
{% if (res | length) > 0 %}
{{ log("\nFound " ~ (res | length) ~ " failing records:", info=True) }}
{% set _ = res.print_table() %}
{{ log("\n", info=True) }}
{% for row in res %}
select 'fail' as status {% if not loop.last %} union all {% endif %}
{% endfor %}
{% else %}
select 'pass' as status limit 0
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment