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

Respect the limit config when storing test failures #376

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{%- materialization test, default -%}

{% set relations = [] %}
{% set limit = config.get('limit') %}

{% set main_sql %}
{{ sql }}
{{ "limit " ~ limit if limit != none }}
{% endset %}

{% if should_store_failures() %}

Expand All @@ -26,32 +32,29 @@
{% endif %}

{% call statement(auto_begin=True) %}
{{ get_create_sql(target_relation, sql) }}
{{ get_create_sql(target_relation, main_sql) }}
{% endcall %}

{% do relations.append(target_relation) %}

{# Since the test failures have already been saved to the database, reuse that result rather than querying again #}
{% set main_sql %}
select *
from {{ target_relation }}
{% endset %}

{{ adapter.commit() }}

{% else %}

{% set main_sql = sql %}

{% endif %}

{% set limit = config.get('limit') %}
{% set fail_calc = config.get('fail_calc') %}
{% set warn_if = config.get('warn_if') %}
{% set error_if = config.get('error_if') %}

{% call statement('main', fetch_result=True) -%}

{{ get_test_sql(main_sql, fail_calc, warn_if, error_if, limit)}}
{# Since the limit has already been applied above, no need to apply it again! #}
{{ get_test_sql(main_sql, fail_calc, warn_if, error_if, limit=none)}}

{%- endcall %}

Expand Down
Loading