Skip to content

Commit

Permalink
Added athena support for upload_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HingeAntoine committed Oct 2, 2024
1 parent fb6207e commit a13230a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
28 changes: 28 additions & 0 deletions macros/upload_individual_datasets/upload_tests.sql
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,34 @@
{% endif %}
{% endmacro -%}

{% macro athena__get_tests_dml_sql(tests) -%}
{% if tests != [] %}
{% set test_values %}
values
{% for test in tests -%}
(
'{{ invocation_id }}', {# command_invocation_id #}
'{{ test.unique_id }}', {# node_id #}
CAST('{{ run_started_at }}' AS timestamp), {# run_started_at #}
'{{ test.name }}', {# name #}
'{{ tojson(test.depends_on.nodes) }}', {# depends_on_nodes #}
'{{ test.package_name }}', {# package_name #}
'{{ test.original_file_path | replace('\\', '\\\\') }}', {# test_path #}
'{{ tojson(test.tags) }}', {# tags #}
{% if var('dbt_artifacts_exclude_all_results', false) %}
null
{% else %}
'{{ adapter.dispatch('parse_json', 'dbt_artifacts')(tojson(test) | replace("\\", "\\\\") | replace("'","''")) }}' {# all_fields #}
{% endif %}
)
{%- if not loop.last %},{%- endif %}
{%- endfor %}
{% endset %}
{{ test_values }}
{% else %} {{ return("") }}
{% endif %}
{%- endmacro %}
{% macro bigquery__get_tests_dml_sql(tests) -%}
{% if tests != [] %}
{% set test_values %}
Expand Down
2 changes: 0 additions & 2 deletions macros/upload_results/insert_into_metadata_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
{{ content }}
{% endset %}

{% do log(insert_into_table_query, true) %}

{% do run_query(insert_into_table_query) %}

{%- endmacro %}
Expand Down
2 changes: 1 addition & 1 deletion macros/upload_results/upload_results.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{% set objects = dbt_artifacts.get_dataset_content(dataset) %}

{# Upload in chunks to reduce the query size #}
{% if dataset == 'models' %}
{% if dataset in ('models', 'tests') %}
{% set upload_limit = 50 if target.type in ('athena', 'bigquery') else 100 %}
{% else %}
{% set upload_limit = 300 if target.type in ('athena', 'bigquery') else 5000 %}
Expand Down

0 comments on commit a13230a

Please sign in to comment.