Justin Pimentel
07/01/2025, 10:54 PMkapa.ai
07/01/2025, 10:54 PMkapa.ai
07/01/2025, 10:54 PMJustin Pimentel
07/02/2025, 12:22 AMJustin Pimentel
07/02/2025, 12:22 AMkapa.ai
07/02/2025, 12:22 AMkapa.ai
07/02/2025, 12:23 AMorder_match_rate_daily.sql) that calculates, for each day, the percentage of order IDs in TableA that have a match in TableB. For example: sql with daily_matches as ( select a.order_date, count(a.order_id) as total_orders, count(b.order_id) as matched_orders from {{ ref('TableA') }} a left join {{ ref('TableB') }} b on a.order_id = b.order_id group by a.order_date ) select order_date, matched_orders * 1.0 / total_orders as match_rate from daily_matches Materialize this as a table or view in your dbt project. 2. Add an Elementary Anomaly Detection Test Use the elementary.column_anomalies test on the match_rate column in your new model. This will allow Elementary to monitor the match rate over time and alert you to anomalies. Example in your `schema.yml`: yaml models: - name: order_match_rate_daily columns: - name: match_rate tests: - elementary.column_anomalies: column_anomalies: [mean] # or use default to monitor for spikes/drops timestamp_column: order_date This setup will let Elementary track the match rate daily and detect unexpected changes or drops, alerting you when anomalies occur. You can further tune the anomaly detection parameters as needed. References: This approach is based on guidance for monitoring custom metrics and using anomaly detection on them in Elementary. You can find more details and configuration options in the documentation for [column_anomalies](https://docs.elementary-data.com/data-tests/anomaly-detection-tests/column-anomalies#test-configuration) and in the discussion about monitoring custom metrics and ratios [here](https://slack.com/archives/C02CTC89LAX/p1677193288425909). If you need to monitor a more complex metric, you can use the elementary.collect_metrics test, which is designed for custom metric collection and anomaly detection as well [Metrics collection and anomaly detection](https://docs.elementary-data.com/features/anomaly-detection/metrics).Justin Pimentel
07/02/2025, 1:44 PMkapa.ai
07/02/2025, 1:44 PMkapa.ai
07/02/2025, 1:45 PMtimestamp_column set at the model level under config: elementary: does not always propagate down to the elementary.column_anomalies test. This means that Elementary may not recognize it as the timestamp column when running anomaly detection, which matches the behavior you're seeing. Recommended Solution: Explicitly set the timestamp_column inside the test configuration itself, not just at the model level. For example: yaml version: 2 models: - name: onsite_transaction_match_rate description: > Calculates the match rate between f_orders and br_session_orders for US-Ecom orders. columns: - name: match_rate_percent tests: - elementary.column_anomalies: column_anomalies: - average timestamp_column: est_order_completed_at time_bucket: period: day count: 1 tags: ["elementary", "onsite"] Why? This is a documented behavior: > The timestamp_column does not propagate down to the column_anomalies test. If you move the timestamp_column under the test config, then the timestamp_column config variable is passed into the test [Slack forum](https://slack.com/archives/C02CTC89LAX/p1706795086121929). Summary: - Move timestamp_column into the test block for elementary.column_anomalies. - This should resolve the issue with Elementary not recognizing the timestamp column. Let me know if you need further help!Justin Pimentel
07/02/2025, 2:13 PMkapa.ai
07/02/2025, 2:13 PMkapa.ai
07/02/2025, 2:13 PMcolumn_anomalies) to that metric in the materialized model. This approach is confirmed in community discussions and support responses, where users are advised to create custom models for such metrics and then use Elementary’s anomaly detection on those models [Anomaly detection on custom metrics](https://slack.com/archives/C02CTC89LAX/p1677193288425909). Elementary does support all dbt tests, so you can write a custom dbt test for referential integrity, and Elementary will capture and report on its results. However, for ongoing anomaly detection or match rate monitoring, materializing the metric in a model and then testing it is the suggested workflow. In summary: - There is no native Elementary test specifically for match rates or referential integrity. - You should materialize a model with your metric and then use Elementary’s anomaly detection tests on it. If you need to monitor referential integrity as a pass/fail test (not as a metric), you can use a custom dbt test, and Elementary will report on its results, but for match rate trends and anomaly detection, materializing a model is required.Justin Pimentel
07/02/2025, 3:19 PMkapa.ai
07/02/2025, 3:19 PMkapa.ai
07/02/2025, 3:19 PMelementary_test_results table (and potentially other related tables, depending on your use case). You can identify the rows to delete by filtering on columns such as the test name, test unique ID, or other identifying fields. For example, you might run a SQL statement like: sql DELETE FROM elementary_test_results WHERE test_name = 'your_test_name'; Or, if you have the test unique ID: sql DELETE FROM elementary_test_results WHERE test_unique_id = 'your_test_unique_id'; This approach is confirmed in multiple community discussions, where users are advised to delete rows directly from elementary_test_results to remove unwanted or outdated test results. This is the standard method for clearing specific test results, as there is no built-in CLI or automated feature for this in Elementary at this time [see example](https://slack.com/archives/C02CTC89LAX/p1687167849673609), [another example](https://slack.com/archives/C02CTC89LAX/p1665667454203099). Note: - Be careful when deleting data directly from Elementary tables, especially in production environments. - If your test results are also present in other tables (such as data_monitoring_metrics for metrics/anomalies), you may want to clear those as well using similar filters. Let me know if you need help crafting a specific query!Justin Pimentel
07/02/2025, 4:09 PMkapa.ai
07/02/2025, 4:09 PMkapa.ai
07/02/2025, 4:09 PMnull_percent and missing_percent is: - null_percent monitors the percentage of only null values in a column out of the total number of rows. - missing_percent monitors the percentage of empty values (such as '', strings with only spaces, or nulls) in a column out of the total number of rows. So, missing_percent is broader and includes both empty strings and nulls, while null_percent only counts nulls. This distinction is especially relevant for string columns, where empty strings and nulls are both possible but have different meanings in your data quality context [Slack forum explanation](https://slack.com/archives/C02CTC89LAX/p1656075987045489).Justin Pimentel
07/02/2025, 5:25 PMkapa.ai
07/02/2025, 5:25 PMkapa.ai
07/02/2025, 5:25 PMnull_percent is above 10%, you should use a standard dbt test (such as a custom SQL test or a dbt-utils test) with a threshold condition, since Elementary’s anomaly detection tests are designed to detect significant changes over time rather than enforce static thresholds. Elementary’s anomaly detection (column_anomalies or all_columns_anomalies) will alert you if the null_percent is anomalous compared to historical values, but it does not natively support static threshold-based failure (e.g., "fail if above 10%") [see discussion](https://slack.com/archives/C02CTC89LAX/p1693358780626649). Recommended approach: - Use a custom dbt test or dbt-utils test to enforce a static threshold. - Use Elementary’s anomaly detection to catch unexpected changes or spikes in null_percent over time. Example of a custom dbt test for a static threshold: sql -- tests/null_percent_below_10.sql SELECT * FROM {{ ref('your_model') }} WHERE (your_column IS NULL)::int GROUP BY 1 HAVING COUNT(*) * 1.0 / (SELECT COUNT(*) FROM {{ ref('your_model') }}) > 0.10 Then, add this test in your schema.yml for the relevant column. Summary: - Use a custom dbt test for static thresholds. - Use Elementary anomaly detection for trend-based alerts. If you need help with the exact SQL or YAML, let me know!Justin Pimentel
07/08/2025, 2:47 PMkapa.ai
07/08/2025, 2:47 PMkapa.ai
07/08/2025, 2:47 PMdbt run-operation elementary.generate_elementary_cli_profile). 3. Copy the generated profile to the machine where you will run the Elementary CLI. 4. Run the edr commands from that machine to generate reports. Elementary Cloud is an option if you want a managed solution, but it is not required for generating EDR reports with dbt Cloud [dbt cloud integration guide](https://docs.elementary-data.com/oss/integrations/dbt), [Slack discussion](https://slack.com/archives/C02CTC89LAX/p1672946793881909), [another Slack discussion](https://slack.com/archives/C02CTC89LAX/p1678066213782359).