[bug] deferral for unit test when modifying upstream and doing a partial build
graciegoheen opened this issue · comments
Grace Goheen commented
One failing test `TestUnitTestDeferState::test_unit_test_defer_state` which will be resolved by https://github.com/dbt-labs/dbt-adapters/pull/94.
At the same time, I got myself into quite a tricky loop trying to debug an edge case with dbt unit tests, until I realized that this PR should actually fix that edge case:
- Say I have
model_a -> model_b
and a unit test defined onmodel_b
- If I rename a column in
model_a
,model_b
, and the unit test definition, and I buildmodel_a
but notmodel_b
in my dev schema, then the unit test will pass without--defer
and yet fail with--defer
. - Why? Because status quo deferral behavior completely rewrites the node in the manifest, meaning that the unit test definition would be using the production version of
model_b.raw_code
rather than the updated development version. - The present PR fixes this by simply adding
model_b.defer_relation
, rather than overwriting themodel_b
node entry.
Originally posted by @jtcohen6 in #9199 (comment)