Open aranke opened 11 months ago
@aranke verified a fix for Postgres in https://github.com/dbt-labs/dbt-core/pull/8768 and then created this backlog ticket for Redshift.
I think the fix for dbt-postgres
was too large in scope, leading to other issues:
The original fix (https://github.com/dbt-labs/dbt-core/issues/8022) was modified slightly in https://github.com/dbt-labs/dbt-core/pull/8889 to still enforce the contract.
Most of the content below is copy-pasted from @amardatar within https://github.com/dbt-labs/dbt-core/issues/8022
Is this a new bug in dbt-redshift?
Current Behavior
When running an incremental model with contract enforced and a foreign key, the model will fail on subsequent updates.
Expected Behavior
The update should succeed without an error.
Steps To Reproduce
First run a statement like:
Then, given a
schema.yml
file:And a SQL file:
dbt will succeed on the first run, and subsequently fail with the error:
As per the error returned, the issue appears to be that while rendering a temporary table as part of the update, dbt will also render the foreign key constraint (which is not valid in the context of a temporary table). This leads to the above failure.
Relevant log output
No response
Environment