Defer is sometimes using development schemas instead of only using production objects

Hey @osvaldo-illescas!

By default, defer will only choose the production version of a model based on two criteria:

  • if the model is not in your selection command
  • if a copy of the model does not already exist in your user schema

Based on the first criterion, you might see this behaviour if you had a DAG that looked like this, and you ran dbt run -s int_model third_model:

But that’s an unlikely selection command. The more likely cause is the second criterion: you have built user_intermediate.int_model in the past but not your fact_model.

To force dbt to always use the production model

You can pass the --favor-state flag, like this: dbt run -s third_model --favor-state and dbt will choose the production version instead, even if the model exists in your development environment. Defer | dbt Developer Hub