dbt-labs / dbt-core

dbt enables data analysts and engineers to transform their data using the same practices that software engineers use to build applications.

Home Page:https://getdbt.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[bug] deferral for unit test when modifying upstream and doing a partial build

graciegoheen opened this issue · comments

          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 on model_b
  • If I rename a column in model_a, model_b, and the unit test definition, and I build model_a but not model_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 the model_b node entry.

Originally posted by @jtcohen6 in #9199 (comment)