<@U088WCP3B4P> I'd like to set a volume_anomalies ...
# ask-elementary-ai
k
@kapa.ai I'd like to set a volume_anomalies test to warn if the anomaly values greater than 1 and error if greater than 3. Is it possible to do in one test and what would that syntax look like?
k
A message from kapa.ai
Currently, it is not possible to configure a single elementary.volume_anomalies test to have both a "warn" and "error" threshold based on different anomaly values (e.g., warn if >1, error if >3). The Elementary anomaly detection tests do not support separate thresholds for warning and error severities within a single test configuration. The recommended workaround is to define two separate tests with different
anomaly_sensitivity
values and set their
severity
accordingly:
Copy code
yaml tests:   - elementary.volume_anomalies:       anomaly_sensitivity: 1       config:         severity: warn   - elementary.volume_anomalies:       anomaly_sensitivity: 3       config:         severity: error
This way, the test with lower sensitivity (more sensitive, so more likely to warn) will trigger a warning, and the test with higher sensitivity will trigger an error for more significant anomalies. However, you cannot set both behaviors in a single test at this time. There is an open feature request to support this kind of configuration, but it is not yet available in the current version of Elementary [Github Issue: Add option to configure warn sensitivity](https://github.com/elementary-data/elementary/issues/1172) [Slack discussion](https://slack.com/archives/C02CTC89LAX/p1693358780626649). If this feature is important for your workflow, you may want to follow or contribute to the open issue for updates.
k
@kapa.ai Also, I'd like to reference an elementary table in a macro. Is there a macro that I can call that returns the relation object or just full string of the table path when I pass it an elementary table name?
k
A message from kapa.ai
Yes, there is a macro in Elementary that you can use to get the database and schema for the Elementary package tables:
elementary.get_package_database_and_schema
. You can use this macro in your own macro to construct the full relation object or string for an Elementary table. Here’s an example of how you might use it in a macro:
Copy code
jinja {% set database_name, schema_name = elementary.get_package_database_and_schema('elementary') %} {% set target_relation = adapter.get_relation(     database=database_name,     schema=schema_name,     identifier='your_elementary_table_name' ) %}
This will give you the relation object for the specified Elementary table. You can then use
target_relation
as needed in your macro. This approach is confirmed in troubleshooting discussions where users needed to reference Elementary tables dynamically in macros [Slack discussion](https://slack.com/archives/C02CTC89LAX/p1670326107972819). If you just need the full string path, you can use the values of
database_name
,
schema_name
, and your table name to construct it as
database_name.schema_name.table_name
. Let me know if you need a more specific example!