The problem I’m having: I am upgrading out dbt installation from 1.8 to the newest version. Our project takes quite long to parse so the v2 parser seems like a good idea. When running test --use-v2-parser, I get this error on my generic data tests:
14:14:51 Database Error in test date_format_validation (tests/dbt/generic/date_format_validation.sql)
[PARSE_SYNTAX_ERROR] Syntax error at or near ')'. SQLSTATE: 42601 (line 15, pos 4)
== SQL ==
/* {"app": "dbt", "dbt_version": "1.12.6", "dbt_databricks_version": "1.13.0", "databricks_sql_connector_version": "4.4.0", "profile_name": "MYCOMPANY", "target_name": "t", "invocation_id": "[REDACTED]", "node_id": "test.MYCOMPANY.date_format_validation"} */
select
count(*) as failures,
count(*) != 0 as should_warn,
count(*) != 0 as should_error
from (
) dbt_internal_test
This is one my my data tests uncompiled:
{% test date_format_validation(model, column_name) %}
{{ config(severity='warn') }}
with validation as (
select
{{ column_name }} as correct_date_format
from {{ model }}
),
validation_errors as (
select
correct_date_format
from validation
where correct_date_format NOT LIKE '__-__-____'
)
select *
from validation_errors
{% endtest %}
However the compiled version simply becomes only the code in the error. I can add some code below the endtest block and then that gets added to the run code. So this test passes with the where clause and fails without:
select
count(*) as failures,
count(*) != 0 as should_warn,
count(*) != 0 as should_error
from (
select "hallo" from myschema.mytable where 1=0
) dbt_internal_test
Simply removing the datatest files leads to models crashing because they cannot invoke the test.
When using the v1 parser I don’t get this issue, but I would not be surprised if it turns out that is because the data tests were not enforced at all.
I am wondering if anyone encountered something similar and whether I am doing something wrong. Maybe from the beginning (but v1 just fails silently due to ignoring unknown keywords), maybe due to a change in v2.