[X] I have searched the existing issues, and I could not find an existing issue for this bug
Current Behavior
When running a unit test for a model that contains a Jinja math operation on a variable, a compilation error occurs
Example operation
select {{ var('foo', 10 ) * 1}} as result
Error:
Compilation Error in unit_test test_unit_test (models\staging\test.yml)
'var' is undefined. This can happen when calling a macro that does not exist. Check for typos and/or install package dependencies with "dbt deps".
Running the unit test on a Jinja variable without the math operation works successfully. Ex: select {{ var('foo', 10 ) }} as result
Expected Behavior
Expected behavior would be to compile unit test and executing the math operation on the variable.
Steps To Reproduce
In any dbt project, create a model called test with the following SQL:
select {{ var('foo', 10 ) * 1}} as result
In that model's .yml file, create a unit test as follows (the 'input' is not used, but required):
version: 2
unit_tests:
name: test_unit_test
model: test
given:
input: ref('stg_ga4__events')
format: csv
rows: |
event_key
A
expect:
format: csv
rows: |
result
10
3. Run the unit test `dbt test -s test_unit_test`
Relevant log output
(python312env) C:\GitHub\velir-ga4-test-project>dbt test -s test_unit_test
22:04:52 Running with dbt=1.8.2
22:04:53 Registered adapter: bigquery=1.8.1
22:04:54 Found 59 models, 28 data tests, 1 seed, 1 source, 604 macros, 11 unit tests
22:04:54
22:04:55 Concurrency: 4 threads (target='dev')
22:04:55
22:04:55 1 of 1 START unit_test test::test_unit_test .................................... [RUN]
22:04:55 1 of 1 ERROR test::test_unit_test .............................................. [ERROR in 0.01s]
22:04:55
22:04:55 Finished running 1 unit test in 0 hours 0 minutes and 1.22 seconds (1.22s).
22:04:55
22:04:55 Completed with 1 error and 0 warnings:
22:04:55
22:04:55 Compilation Error in unit_test test_unit_test (models\staging\test.yml)
'var' is undefined. This can happen when calling a macro that does not exist. Check for typos and/or install package dependencies with "dbt deps".
22:04:55
22:04:55 Done. PASS=0 WARN=0 ERROR=1 SKIP=0 TOTAL=1
Is this a new bug in dbt-core?
Current Behavior
When running a unit test for a model that contains a Jinja math operation on a variable, a compilation error occurs
Example operation
Error:
Running the unit test on a Jinja variable without the math operation works successfully. Ex:
select {{ var('foo', 10 ) }} as result
Expected Behavior
Expected behavior would be to compile unit test and executing the math operation on the variable.
Steps To Reproduce
test
with the following SQL:unit_tests:
Relevant log output
Environment
Which database adapter are you using with dbt?
bigquery
Additional Context
No response