Skip to content

Commit

Permalink
Perf improvements and debug logs (#622)
Browse files Browse the repository at this point in the history
* Perf improvements and debug logs

* Perf improvements and debug logs

* Removed test status check before calling original test materialization

* Update macros/edr/materializations/test/test.sql

---------

Co-authored-by: Itamar Hartstein <[email protected]>
  • Loading branch information
oravi and haritamar authored Nov 29, 2023
1 parent bf6d9ab commit ec6b540
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions macros/edr/materializations/test/test.sql
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,27 @@
{% do return(materialization_macro()) %}
{% endif %}

{% set test_unique_id = model.get('unique_id') %}
{% do elementary.debug_log(test_unique_id ~ ": starting test materialization hook") %}
{% if elementary.get_config_var("tests_use_temp_tables") %}
{% set temp_table_sql = elementary.create_test_result_temp_table() %}
{% do context.update({"sql": temp_table_sql}) %}
{% do elementary.debug_log(test_unique_id ~ ": created test temp table") %}
{% endif %}

{% set flattened_test = elementary.flatten_test(model) %}
{% do elementary.debug_log(test_unique_id ~ ": flattened test node") %}
{% set test_type_handler = elementary.get_test_type_handler(flattened_test) %}
{% set result = test_type_handler(flattened_test, materialization_macro) %}
{% do elementary.debug_log(test_unique_id ~ ": handler called by test type - " ~ elementary.get_test_type(flattened_test)) %}
{% if elementary.get_config_var("calculate_failed_count") %}
{% set failed_row_count = elementary.get_failed_row_count(flattened_test) %}
{% if failed_row_count is not none %}
{% do elementary.get_cache("elementary_test_failed_row_counts").update({model.unique_id: failed_row_count}) %}
{% do elementary.debug_log(test_unique_id ~ ": calculated failed row count") %}
{% endif %}
{% endif %}
{% do elementary.debug_log(test_unique_id ~ ": finished test materialization hook") %}
{% do return(result) %}
{% endmacro %}

Expand Down

0 comments on commit ec6b540

Please sign in to comment.