-
Notifications
You must be signed in to change notification settings - Fork 40
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
When using incremental tables, the column data types are invalidly updated #269
Conversation
Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide. |
dbt/include/global_project/macros/materializations/models/incremental/incremental.sql
Outdated
Show resolved
Hide resolved
@gshank I read through the original issue and I'm not clear on how this resolves that issue. If I understand this change correctly, it looks like we're doing this:
I don't see how 1. would affect anything. And 2. removes adjusting columns entirely for contract-enforced models instead of correcting the type. From this PR, it seems like there's an assumption that models with a contract will never change. Is that true? What happens if the user deliberately adds a column, and updates the contract to reflect the new column? Is that something we don't support? |
I removed the repr only because it caused a lot of confusion when debugging, because it wasn't adequately displaying the contents of the class and the default worked better. It's not related to the fix. The problem that this fixes is that the intermediate tables have different data types than the actual incremental table, and that is causing the actual incremental table to have the data types updated from valid (contract enforced) data types to data types that do not match the contract. It's not totally clear to me what the point of "expand_column_data_types" is supposed to be, so I tried to limit the change to just what was necessary to fix this bug. |
That's what I suspected, and I'm fine with that.
I see how this is happening too, and agree that it shouldn't be.
After further discussion, restricting data type changes on existing columns on contract-enforced models feels intuitive. |
resolves #276
Original issue in dbt-labs/dbt-core#10362
Problem
In dbt-postgres, contract changes were applied to temporary tables, causing original tables to be changed to match.
Solution
If a contract exists, do not modify the columns of incremental tables.
Checklist