Skip to content

Commit

Permalink
Speed up Snowflake column comments, while still avoiding errors (#3543)
Browse files Browse the repository at this point in the history
* Have our cake and eat it quickly, too

* Update changelog
  • Loading branch information
jtcohen6 authored Jul 7, 2021
1 parent 4906515 commit 85627aa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Contributors:

## dbt 0.20.0 (Release TBD)

### Fixes

- Avoid slowdown in column-level `persist_docs` on Snowflake, while preserving the error-avoidance from [#3149](https:/fishtown-analytics/dbt/issues/3149) ([#3541](https:/fishtown-analytics/dbt/issues/3541), [#3543](https:/fishtown-analytics/dbt/pull/3543))

## dbt 0.20.0rc2 (June 30, 2021)

### Fixes
Expand Down
6 changes: 4 additions & 2 deletions plugins/snowflake/dbt/include/snowflake/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,10 @@


{% macro snowflake__alter_column_comment(relation, column_dict) -%}
{% for column_name in column_dict %}
comment if exists on column {{ relation }}.{{ adapter.quote(column_name) if column_dict[column_name]['quote'] else column_name }} is $${{ column_dict[column_name]['description'] | replace('$', '[$]') }}$$;
{% set existing_columns = adapter.get_columns_in_relation(relation) | map(attribute="name") | list %}
alter {{ relation.type }} {{ relation }} alter
{% for column_name in column_dict if (column_name in existing_columns) or (column_name|upper in existing_columns) %}
{{ adapter.quote(column_name) if column_dict[column_name]['quote'] else column_name }} COMMENT $${{ column_dict[column_name]['description'] | replace('$', '[$]') }}$$ {{ ',' if not loop.last else ';' }}
{% endfor %}
{% endmacro %}

Expand Down

0 comments on commit 85627aa

Please sign in to comment.