-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Unit Test fails when using a versioned model as an input #10528
Comments
EDIT: ignore this comment below; it worked for me when a tried it again today (2024-08-29). With dbt-core 1.8.3, even specifying it in both places didn't work for me. See below for details.
select *
from {{ ref('stg_orders', v=2) }}
unit_tests:
- name: test_10528
model: fct_orders
given:
- input: ref('stg_orders', v=2)
format: dict
rows:
- {id: 2}
expect:
rows:
- {id: 2}
models:
- name: stg_orders
versions:
- v: 1
columns:
- include: all
exclude: [added_column]
- v: 2
columns:
- include: all
latest_version: 2
select 1 as id
select 1 as id, 2 as added_column |
The reprex below has two cases:
The first is a simplification of the example given in this bug report.
|
Is this a new bug in dbt-core?
Current Behavior
Unit tests fail if an input reference is a versioned model and the version is not explicitly defined in both the model AND the unit test.
Expected Behavior
The unit test should default to the latest version specified in the yml config for the input versioned model.
Steps To Reproduce
stg_tpch_orders
, with versions1
and2
) and second model (e.g.customer_tier
) that references that versioned model, and a unit test on that second model (customer_tier
) that references that versioned model as an inputdbt build --select customer_tier
customer_tier
model does not reference a specific version, the unit test will always fail, regardless if a version is specified or not. For this scenario, see code below.customer_tier
model does reference a specific version, the unit test will fail if no version is specified. The unit test does work if you explicitly specifyref('stg_tpch_orders', v =2)
in both placesCode for reference
schema.yml for stg_tpch_orders
customer_tier.sql
unit test:
Relevant log output
Environment
Which database adapter are you using with dbt?
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: