Nic
11/12/2025, 10:49 PMNic
11/12/2025, 11:01 PMkapa.ai
11/12/2025, 11:01 PMNic
11/12/2025, 11:02 PMkapa.ai
11/12/2025, 11:02 PMkapa.ai
11/12/2025, 11:02 PMtest_146ea26f29_elementary_collect_metrics...) are created by Elementary during test execution. These tables store intermediate test results and metrics before they're inserted into Elementary's main tables. ## Current behavior and cleanup According to the [GitHub issue #1313](https://github.com/elementary-data/elementary/issues/1313), Elementary does have an automatic cleanup process for these test tables. The cleanup is implemented in the clean_elementary_test_tables macro, which is called during the on-run-end hook. However, based on multiple [Slack discussions](https://slack.com/archives/C02CTC89LAX/p1684349983650899), there was a specific issue with BigQuery where temporary tables with names ending in __dbt_tmp were not being properly cleaned up. This was fixed and merged, though the exact version isn't specified in the knowledge sources. ## Solutions 1. Upgrade Elementary: Make sure you're using the latest version of Elementary, as the automatic cleanup functionality has been implemented and improved over time. 2. Manual cleanup is safe: If tables persist, you can safely delete them after your dbt run completes. As mentioned in [this discussion](https://slack.com/archives/C02CTC89LAX/p1685097367889679), "You can drop these tests tables as soon as the dbt test run is completed, there will be no impact on the report." 3. Custom cleanup hook: If the issue persists, you can implement your own cleanup using an on_run_end hook in your dbt_project.yml to drop tables with __tmp in their names, as suggested in [this thread](https://slack.com/archives/C02CTC89LAX/p1702682903247439). ## Why aren't they temp tables? According to [this explanation](https://slack.com/archives/C02CTC89LAX/p1685097367889679), Elementary needs to create these tables (rather than using INSERT statements directly) to avoid conflicts when multiple tests run in parallel. The tables are created, then a single INSERT query is executed during the on-run-end hook. If you're still experiencing this issue with the latest version, I'd recommend checking if your dbt process is completing successfully, as interrupted runs may prevent the cleanup from executing.Nic
11/12/2025, 11:03 PMNic
11/12/2025, 11:03 PMkapa.ai
11/12/2025, 11:03 PMkapa.ai
11/12/2025, 11:03 PMdbt_project.yml file. Here's an example approach mentioned in [this thread](https://slack.com/archives/C02CTC89LAX/p1706702598567759): Add a drop statement to your own on_run_end hook to remove the temporary tables after each run. ### 2. PySpark script (for Databricks/Spark) If you're using Databricks or a Spark cluster, you can use this script from [this discussion](https://slack.com/archives/C02CTC89LAX/p1702682903247439): python catalog = 'INSERT_HERE' elementary_schema = 'INSERT_HERE' spark.sql("use catalog " + catalog) table_df = spark.sql("show tables in " + elementary_schema) table_list = [row.tableName for row in table_df.select("tableName").collect()] tables_to_keep = [table for table in table_list if '__tmp' not in table] tables_to_drop = list(set(table_list) - set(tables_to_keep)) print("Tables to drop: \n\n" + '\n'.join(tables_to_drop) + '\n') print("Tables to keep: \n\n" + '\n'.join(tables_to_keep)) for table in tables_to_drop: spark.sql("drop table " + catalog + "." + elementary_schema + "." + table + ";") ## Important Notes - According to [this explanation](https://slack.com/archives/C02CTC89LAX/p1685097367889679), you can delete these test tables "as soon as the dbt test command completes (including the on run end), as there is no use to them after the on-run-end hook completes." - Deleting these tables will have no impact on the Elementary report or stored test results, as the data has already been inserted into Elementary's main tables. The knowledge sources indicate that Elementary should be cleaning these up automatically in recent versions, so if you're experiencing persistent accumulation, ensure you're on the latest version and that your dbt runs are completing successfully.Nic
11/12/2025, 11:05 PMNoya Offer
11/13/2025, 1:39 PMNic
11/13/2025, 2:40 PMNic
11/13/2025, 2:40 PMNic
11/16/2025, 7:52 PMNoya Offer
11/19/2025, 8:59 AMYosef Arbiv
11/19/2025, 12:39 PMNic
11/20/2025, 2:37 PM(dbt-models) (tgm-975-…) ~/D/dbt_models > mise run dbt test --select dim_backoffice_organizations
[dbt] $ cd corporate_suite && uv run dbt test --select dim_backoffice_organizations
14:32:14 Running with dbt=1.10.13
14:32:16 Registered adapter: bigquery=1.10.2
14:32:18 Found 842 models, 23 snapshots, 457 data tests, 4 seeds, 4 operations, 132 sources, 2293 exposures, 3 metrics, 2131 macros, 1 semantic model
14:32:18
14:32:18 Concurrency: 30 threads (target='dev')
14:32:18
/Users/nic.tay/Documents/dbt_models/.venv/lib/python3.13/site-packages/google/auth/_default.py:76: UserWarning: Your application has authenticated using end user credentials from Google Cloud SDK without a quota project. You might receive a "quota exceeded" or "API not enabled" error. See the following page for troubleshooting: <https://cloud.google.com/docs/authentication/adc-troubleshooting/user-creds>.
warnings.warn(_CLOUD_SDK_CREDENTIALS_WARNING)
/Users/nic.tay/Documents/dbt_models/.venv/lib/python3.13/site-packages/google/auth/_default.py:76: UserWarning: Your application has authenticated using end user credentials from Google Cloud SDK without a quota project. You might receive a "quota exceeded" or "API not enabled" error. See the following page for troubleshooting: <https://cloud.google.com/docs/authentication/adc-troubleshooting/user-creds>.
warnings.warn(_CLOUD_SDK_CREDENTIALS_WARNING)
/Users/nic.tay/Documents/dbt_models/.venv/lib/python3.13/site-packages/google/auth/_default.py:76: UserWarning: Your application has authenticated using end user credentials from Google Cloud SDK without a quota project. You might receive a "quota exceeded" or "API not enabled" error. See the following page for troubleshooting: <https://cloud.google.com/docs/authentication/adc-troubleshooting/user-creds>.
warnings.warn(_CLOUD_SDK_CREDENTIALS_WARNING)
/Users/nic.tay/Documents/dbt_models/.venv/lib/python3.13/site-packages/google/auth/_default.py:76: UserWarning: Your application has authenticated using end user credentials from Google Cloud SDK without a quota project. You might receive a "quota exceeded" or "API not enabled" error. See the following page for troubleshooting: <https://cloud.google.com/docs/authentication/adc-troubleshooting/user-creds>.
warnings.warn(_CLOUD_SDK_CREDENTIALS_WARNING)
14:32:19 Elementary: Runtime data: {"config": {}, "dbt_version": "1.10.13", "elementary_version": "0.20.1", "database": "prj-bi-data-7692", "schema": "dbt_ntay_elementary"}
14:32:20 1 of 2 START hook: elementary.on-run-start.0 ................................... [RUN]
14:32:20 1 of 2 OK hook: elementary.on-run-start.0 ...................................... [OK in 0.54s]
14:32:20 2 of 2 START hook: zendesk.on-run-start.1 ...................................... [RUN]
14:32:20 2 of 2 OK hook: zendesk.on-run-start.1 ......................................... [OK in 0.00s]
14:32:20
14:32:20 1 of 1 START test elementary_collect_metrics_dim_backoffice_organizations__name_row_count_type_row_count_ [RUN]
14:32:22 1 of 1 PASS elementary_collect_metrics_dim_backoffice_organizations__name_row_count_type_row_count_ [PASS in 2.41s]
14:32:22
14:32:22 1 of 2 START hook: pricehubble.on-run-end.0 .................................... [RUN]
14:32:22 1 of 2 OK hook: pricehubble.on-run-end.0 ....................................... [OK in 0.01s]
14:32:35 2 of 2 START hook: elementary.on-run-end.1 ..................................... [RUN]
14:32:35 2 of 2 OK hook: elementary.on-run-end.1 ........................................ [OK in 13.13s]
14:32:35
14:32:35 Finished running 4 project hooks, 1 test in 0 hours 0 minutes and 17.86 seconds (17.86s).
14:32:36
14:32:36 Completed successfully
14:32:36
14:32:36 Done. PASS=5 WARN=0 ERROR=0 SKIP=0 NO-OP=0 TOTAL=5Yosef Arbiv
11/24/2025, 7:19 AM