# Accessing "state" from Jinja context

**URL:** <https://discourse.getdbt.com/t/accessing-state-from-jinja-context/6735>\
**Category:** Help\
**Created:** [February 9, 2023, 12:13pm UTC](https://discourse.getdbt.com/t/accessing-state-from-jinja-context/6735 "2023-02-09T12:13:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pelotas](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/pelotas/32/1853_2.png) [@pelotas](https://discourse.getdbt.com/u/pelotas)\
**Post date:** [February 9, 2023, 12:13pm UTC](https://discourse.getdbt.com/t/accessing-state-from-jinja-context/6735/1 "2023-02-09T12:13:41Z")

</div>

Hello,

We’re trying to develop a QA test that compares a table in the QA environment with the corresponding table in the Prod environment. The goal here is to check, for example, if some rows are missing from the QA version when we know they should be there (because they are in Prod and we know Prod is correct).

So the question is: when we run `dbt build -s my_table --target qa` , is it possible to reference the version of `my_table` that lives in Prod? I’ve tried passing the state from the prod manifest (e.g., `dbt build -s my_table --target qa --defer --state /path/to/prod/manifest`), but upon inspection of the `graph` context var, all values of the `my_table` node point to the QA database/schema, not the prod one.

Am I missing something here? Is it bad practice to do this comparison between QA and Prod in this way?

Thanks!

---

<div class="post-metadata">

**Author:** ![joellabes](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/joellabes/32/3980_2.png) [@joellabes](https://discourse.getdbt.com/u/joellabes)\
**Post date:** [February 13, 2023, 3:46am UTC](https://discourse.getdbt.com/t/accessing-state-from-jinja-context/6735/2 "2023-02-13T03:46:39Z")

</div>

As of 1.4.0, there is a new `--favor-state` flag which I think will do what you want. ~~It doesn’t look like it got documented, but check out the issue for it: [[CT-470] [Feature] Add option for --defer to favor using --state node even if node exists in current target · Issue #5016 · dbt-labs/dbt-core · GitHub](https://github.com/dbt-labs/dbt-core/issues/5016)~~

Documented here: [https://docs.getdbt.com/reference/node-selection/defer#favor-state](https://docs.getdbt.com/reference/node-selection/defer#favor-state)
