The issue I am having is, whenever I build my custom tests, I get an error. After inspecting the target code, it looks like the FROM is never being populated.
I even tried using code from the documentation and that fails to build as well. I am curious if this is a bug or if am I missing something obvious.
Here is the test code:
{% test Currency(model, column_name) %}
SELECT *
FROM {{ model }}
WHERE NOT REGEXP_LIKE({{ column_name }}, '^[0-9]+(\.[0-9]{1,2})?$')
{% endtest %}
All it does is figure out if the value is a valid currency.
The compiled code looks like this:
select
count(*) as failures,
count(*) != 0 as should_warn,
count(*) != 0 as should_error
from (
) dbt_internal_test
The error message is:
Database Error in test Currency (tests\Currency.sql)
001003 (42000): SQL compilation error:
syntax error line 8 at position 4 unexpected ')'.
compiled Code at target\run\ea_data_analytics\tests\Currency.sql
Makes sense why it fails, but, why does it refuse to replace the {{model}} . Also, where has my logic gone? It makes sense that it should appear in the FROM as an embedded query but does not. Is this a bug? Or did I miss something.