<@U088WCP3B4P> check whether the code works withou...
# ask-elementary-ai
s
@kapa.ai check whether the code works without issues and give example for each tests - name: item_branch__parquet_common_refined4 data_tests: - elementary.volume_anomalies: anomaly_direction: both ignore_small_changes: spike_failure_percent_threshold: 1 drop_failure_percent_threshold: 1 tags: ["elementary", "daily_elementary", "refined4", "common_refined4"] tests: - elementary.volume_anomalies: timestamp_column: "itembranch.creation date" anomaly_direction: both ignore_small_changes: spike_failure_percent_threshold: 3 drop_failure_percent_threshold: 3 tags: ["elementary", "daily_elementary", "refined4", "common_refined4"] columns: - name: "%itembranchskey" quote: true data_tests: - unique: config: severity: error error_if: ">1" warn_if: ">1" - not_null - name: creation_date data_tests: - not_null tests: - elementary.column_anomalies: column_anomalies: - null_count - average tags: ["elementary", "daily_elementary", "refined4", "common_refined4"]
k
A message from kapa.ai
Let's review your code and provide examples for each test, based strictly on the knowledge sources. --- ### 1. Code Review #### Model-level configuration
Copy code
yaml - name: item_branch__parquet_common_refined4     data_tests:       - elementary.volume_anomalies:           anomaly_direction: both           ignore_small_changes:             spike_failure_percent_threshold: 1             drop_failure_percent_threshold: 1           tags: ["elementary", "daily_elementary", "refined4", "common_refined4"]     tests:       - elementary.volume_anomalies:           timestamp_column: "itembranch.creation date"           anomaly_direction: both           ignore_small_changes:             spike_failure_percent_threshold: 3             drop_failure_percent_threshold: 3           tags: ["elementary", "daily_elementary", "refined4", "common_refined4"]
- The use of
elementary.volume_anomalies
is correct. -
anomaly_direction
,
ignore_small_changes
, and
tags
are valid parameters. -
timestamp_column
should be a column name. The value
"itembranch.creation date"
may be problematic if the actual column is named
creation_date
. If the column is named
creation_date
, use just that name (e.g.,
timestamp_column: creation_date
). If it is a nested field, ensure your warehouse supports this syntax. - Both
data_tests
and
tests
are used. The knowledge sources do not mention
data_tests
as a valid key for Elementary or dbt tests—only
tests
is documented. Using
data_tests
may not work as expected unless you have a custom implementation. Stick to
tests
for compatibility with dbt and Elementary[Add anomaly detection tests](https://docs.elementary-data.com/data-tests/add-elementary-tests). #### Column-level configuration
Copy code
yaml     columns:       - name: "%itembranchskey"         quote: true         data_tests:           - unique:               config:                 severity: error                 error_if: ">1"                 warn_if: ">1"           - not_null       - name: creation_date         data_tests:           - not_null         tests:           - elementary.column_anomalies:               column_anomalies:                 - null_count                 - average               tags: ["elementary", "daily_elementary", "refined4", "common_refined4"]
-
elementary.column_anomalies
is correctly configured with
column_anomalies
for
null_count
and `average`[column_anomalies](https://docs.elementary-data.com/data-tests/anomaly-detection-configuration/column-anomalies). - Again,
data_tests
is not a standard key for dbt or Elementary. Use
tests
for all test definitions. --- ### 2. Example for Each Test #### Example: volume_anomalies
Copy code
yaml models:   - name: item_branch__parquet_common_refined4     tests:       - elementary.volume_anomalies:           timestamp_column: creation_date           anomaly_direction: both           ignore_small_changes:             spike_failure_percent_threshold: 3             drop_failure_percent_threshold: 3           tags: ["elementary", "daily_elementary", "refined4", "common_refined4"]
This test monitors row count anomalies per time bucket (e.g., per day) using the
creation_date
column. It will flag both spikes and drops, but only if the change is greater than 3% compared to the training period average[volume_anomalies](https://docs.elementary-data.com/data-tests/anomaly-detection-tests/volume-anomalies#test-configuration). #### Example: column_anomalies
Copy code
yaml models:   - name: item_branch__parquet_common_refined4     columns:       - name: creation_date         tests:           - elementary.column_anomalies:               column_anomalies:                 - null_count                 - average               tags: ["elementary", "daily_elementary", "refined4", "common_refined4"]
This test monitors the
creation_date
column for anomalies in the number of nulls and the average value (if numeric/date type)[column_anomalies](https://docs.elementary-data.com/data-tests/anomaly-detection-tests/column-anomalies#test-configuration). #### Example: not_null and unique (dbt native)
Copy code
yaml models:   - name: item_branch__parquet_common_refined4     columns:       - name: "%itembranchskey"         quote: true         tests:           - unique           - not_null       - name: creation_date         tests:           - not_null
These are standard dbt tests for uniqueness and not-null constraints. --- ### 3. Summary - Replace all
data_tests
with
tests
for compatibility. - **Check your
timestamp_column
value**—use the actual column name. - The rest of your configuration is valid and follows documented patterns for Elementary anomaly detection tests. If you follow these adjustments, your tests should work as expected. If you have a custom implementation for
data_tests
, consult your internal documentation, as this is not standard in dbt or Elementary. For more details, see the official documentation on [adding anomaly detection tests](https://docs.elementary-data.com/data-tests/add-elementary-tests) and [test configuration](https://docs.elementary-data.com/data-tests/anomaly-detection-tests/column-anomalies#test-configuration).