Skip to content

Commit

Permalink
Merge pull request #661 from elementary-data/ele-2470-temp-tables-are…
Browse files Browse the repository at this point in the history
…-not-being-deleted

ELE-2470 temp tables are not being deleted
  • Loading branch information
IDoneShaveIt authored Feb 13, 2024
2 parents f154cfb + 294f9ab commit 9ee79f8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
10 changes: 10 additions & 0 deletions macros/edr/system/hooks/on_run_end.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,15 @@
{% if not elementary.get_config_var('disable_dbt_invocation_autoupload') %}
{% do elementary.upload_dbt_invocation() %}
{% endif %}

{#
Elementary temp tables are not really temp and should be cleaned on the end of the run.
We want to make sure we clean the temp tables even if elementary on run end hooks are disabled.

IMPORTANT! - This must be running last because other hooks are relaying on the temp tables.
#}
{% if elementary.get_config_var("clean_elementary_temp_tables") %}
{% do elementary.clean_elementary_temp_tables() %}
{% endif %}
{% endif %}
{% endmacro %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% macro clean_elementary_temp_tables() %}
{% do elementary.clean_elementary_test_tables() %}
{% endmacro %}
3 changes: 0 additions & 3 deletions macros/edr/tests/on_run_end/handle_tests_results.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
{% set database_name, schema_name = elementary.get_package_database_and_schema('elementary') %}
{% do elementary.insert_data_monitoring_metrics(database_name, schema_name, test_metrics_tables) %}
{% do elementary.insert_schema_columns_snapshot(database_name, schema_name, test_columns_snapshot_tables) %}
{% if elementary.get_config_var("clean_elementary_temp_tables") %}
{% do elementary.clean_elementary_test_tables() %}
{% endif %}
{% if test_result_rows %}
{% set test_result_rows_relation = elementary.get_elementary_relation('test_result_rows') %}
{% do elementary.insert_rows(test_result_rows_relation, test_result_rows, should_commit=True) %}
Expand Down

0 comments on commit 9ee79f8

Please sign in to comment.