Hi, I am trying to run generic test in dbt with e...
# ask-elementary-ai
d
Hi, I am trying to run generic test in dbt with elementary. When I use {{ model }} keyword within my test, it doesn’t use the actual table name but rather produces a long string. What is the workaround this ?
k
A message from kapa.ai
Based on the knowledge sources, I can see this is a known issue with Elementary tests when using custom macros that override the default behavior of model references. The issue occurs because Elementary's tests expect the
model
argument to be a relation type (database object), but in some cases it's being converted to a string. This happens particularly when there's a custom implementation of macros like
get_where_subquery
in your dbt project. From the knowledge sources, there are a few potential solutions: 1. If you're using a custom
get_where_subquery
macro, this might be causing the issue as noted in [this community discussion](https://slack.com/archives/C02CTC89LAX/p1657009818301009). Elementary tests might not work properly with custom implementations that return strings instead of relations. 2. For singular tests, you can use the
override_primary_test_model_id
config parameter to specify which model the test is associated with, as mentioned in [the Elementary documentation](https://docs.elementary-data.com/cloud/guides/troubleshoot#how-do-i-set-up-the-table-name-of-my-singular-test%3F). 3. If you're using custom schema/alias naming through overridden macros like
generate_alias_name
or
generate_schema_name
, you might need to modify these macros to handle Elementary models differently, as suggested in [this community thread](https://slack.com/archives/C02CTC89LAX/p1669049623458239). The most direct workaround would be to modify your custom macros to handle Elementary tests differently, or to use
dbt.load_relation()
instead of directly referencing the model in your test. If you could share more details about your specific implementation, I might be able to provide more targeted advice based on the knowledge sources. I'm here to help you troubleshoot this issue with Elementary Data!