Skip to content
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

Fix dynamic models with contract enabled #1369

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

carolinabtt
Copy link

resolves #1002

Problem

When a model is Contract Enforced and the sql statement contains the _dbt_max_partition variable, dbt does not declare the variable before creating the cte.

This results in the following error:

  • Unrecognized name: _dbt_max_partition at ..

Solution

This PR fixes the bigquery__get_empty_subquery_sql macro, by checking 2 conditions:

  1. if the model is contact enforced
  2. if the model contains _dbt_max_partition variable

If the conditions are met, the _dbt_max_partition is declared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant