The problem I’m having
incremental model is currently choosing columns that have not yet been selected.
I have manually created a model named model_1 in my data warehouse, with columns col1, col2, and col3. Now, I’ve implemented an incremental model for model_1 using a merge strategy. The query for model_1 is:
SELECT COL1, COL3 FROM {{this}}
During the merge process, it includes col2 in the merge statement, causing the model to fail due to the absence of COL2 in the temporary view (model_1__dbt__temp) generated internally by dbt. Since I’ve specified only col1 and col3 in the query, dbt should update/insert values for only col1 and col3.
The context of why I’m trying to do this
I need to insert/update only few set of columns as part of enhancements after building an incremental model. I don’t want to delete the unused columns from target table. I want dbt to update/insert only the selected columns in the model select query.
What I’ve already tried
I also tried merge_exclude_columns
but it excludes columns to update. It also should exclude columns from inserting.