Skip to content

Commit

Permalink
Use common columns for incremental schema changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kayrnt committed Nov 7, 2021
1 parent a8934ef commit 2bfde1e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
N/A

### Fixes
N/A
- When on_schema_change is set, pass common columns as dest_columns in incremental merge macros ([#4144](https://github.com/dbt-labs/dbt-core/issues/4144))

### Under the hood
- Add optional profile parameters for atypical local connection setups ([#21](https://github.com/dbt-labs/dbt-snowflake/issues/21), [#36](https://github.com/dbt-labs/dbt-snowflake/pull/36))
Expand All @@ -19,6 +19,7 @@ N/A

### Contributors
- [@NiallRees](https://github.com/NiallRees) ([#32](https://github.com/dbt-labs/dbt-snowflake/pull/32))
- [@Kayrnt](https://github.com/Kayrnt) ([38](https://github.com/dbt-labs/dbt-snowflake/pull/38))

## dbt-snowflake v1.0.0b1 (October 11, 2021)

Expand Down
5 changes: 3 additions & 2 deletions dbt/include/snowflake/macros/materializations/incremental.sql
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@
{% do adapter.expand_target_column_types(
from_relation=tmp_relation,
to_relation=target_relation) %}
{% do process_schema_changes(on_schema_change, tmp_relation, existing_relation) %}
{% set dest_columns = adapter.get_columns_in_relation(existing_relation) %}
{% set schema_changes_dict = process_schema_changes(on_schema_change, tmp_relation, existing_relation) %}
{#-- Destination columns is the intersection of source and target table --#}
{% set dest_columns = schema_changes_dict.get('in_target_and_source', existing_columns) %}
{% set build_sql = dbt_snowflake_get_incremental_sql(strategy, tmp_relation, target_relation, unique_key, dest_columns) %}

{% endif %}
Expand Down

0 comments on commit 2bfde1e

Please sign in to comment.