Skip to content

Fix: Handle view materialization alterations #610

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

axellpadilla
Copy link

This commit addresses the following:

  • Modifies the create view macro to use alter view when the view already exists, preventing errors during re-materialization and non-dbt grants deletion.
  • Updates the view materialization logic to correctly handle scenarios where a table with the same name exists. It now renames the existing table to a backup before creating the view.
  • Adds a test case to verify that materializing an existing view updates its definition correctly, including column changes.
  • Fixed that the existing relation backup renaming was on a wrong order, upstream core is also that way.

All tests passing.

This commit addresses the following:

- Modifies the `create view` macro to use `alter view` when the view already exists, preventing errors during re-materialization.
- Updates the view materialization logic to correctly handle scenarios where a table with the same name exists. It now renames the existing table to a backup before creating the view.
- Adds a test case to verify that materializing an existing view updates its definition correctly, including column changes.
@axellpadilla axellpadilla changed the title Fix: Handle view alterations and existing table replacements Fix: Handle view materialization alterations May 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant