Skip to content
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

Backport #2440 to 0.17 #2442

Merged
merged 1 commit into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## dbt 0.17.0 (Release TBD)


### Fixes
- When no columns are documented and persist_docs.columns is True, skip creating comments instead of failing with errors ([#2439](https://github.com/fishtown-analytics/dbt/issues/2439), [#2440](https://github.com/fishtown-analytics/dbt/pull/2440))


## dbt 0.17.0rc1 (May 12, 2020)

### Breaking changes
Expand All @@ -26,7 +31,7 @@
- Track distinct project hashes in anonymous usage metrics for package downloads ([#2351](https://github.com/fishtown-analytics/dbt/issues/2351), [#2429](https://github.com/fishtown-analytics/dbt/pull/2429))

Contributors:
- [@azhard](https://github.com/azhard) ([#2413](https://github.com/fishtown-analytics/dbt/pull/2413), [#2422](https://github.com/fishtown-analytics/dbt/pull/2422))
- [@azhard](https://github.com/azhard) ([#2413](https://github.com/fishtown-analytics/dbt/pull/2413), [#2422](https://github.com/fishtown-analytics/dbt/pull/2422))
- [@mikaelene](https://github.com/mikaelene) [#2414](https://github.com/fishtown-analytics/dbt/pull/2414)
- [@raalsky](https://github.com/Raalsky) ([#2343](https://github.com/fishtown-analytics/dbt/pull/2343))
- [@alf-mindshift](https://github.com/alf-mindshift) ([docs#90](https://github.com/fishtown-analytics/dbt-docs/pull/90))
Expand Down
4 changes: 2 additions & 2 deletions core/dbt/include/global_project/macros/adapters/common.sql
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@
{% endmacro %}

{% macro default__persist_docs(relation, model, for_relation, for_columns) -%}
{% if for_relation and config.persist_relation_docs() %}
{% if for_relation and config.persist_relation_docs() and model.description %}
{% do run_query(alter_relation_comment(relation, model.description)) %}
{% endif %}

{% if for_columns and config.persist_column_docs() %}
{% if for_columns and config.persist_column_docs() and model.columns %}
{% do run_query(alter_column_comment(relation, model.columns)) %}
{% endif %}
{% endmacro %}
Expand Down
2 changes: 1 addition & 1 deletion plugins/bigquery/dbt/include/bigquery/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@

{#-- relation-level macro is not implemented. This is handled in the CTAs statement #}
{% macro bigquery__persist_docs(relation, model, for_relation, for_columns) -%}
{% if for_columns and config.persist_column_docs() %}
{% if for_columns and config.persist_column_docs() and model.columns %}
{% do alter_column_comment(relation, model.columns) %}
{% endif %}
{% endmacro %}
Expand Down
4 changes: 2 additions & 2 deletions plugins/redshift/dbt/include/redshift/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@


{% macro redshift__persist_docs(relation, model, for_relation, for_columns) -%}
{% if for_relation and config.persist_relation_docs() %}
{% if for_relation and config.persist_relation_docs() and model.description %}
{% do run_query(alter_relation_comment(relation, model.description)) %}
{% endif %}

{# Override: do not set column comments for LBVs #}
{% set is_lbv = config.get('materialized') == 'view' and config.get('bind') == false %}
{% if for_columns and config.persist_column_docs() and not is_lbv %}
{% if for_columns and config.persist_column_docs() and model.columns and not is_lbv %}
{% do run_query(alter_column_comment(relation, model.columns)) %}
{% endif %}
{% endmacro %}
Expand Down

This file was deleted.

21 changes: 0 additions & 21 deletions test/integration/059_persist_docs_test/sf_models/schema.yml

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
select 1 as id, 'Alice' as name
13 changes: 8 additions & 5 deletions test/integration/060_persist_docs_tests/test_persist_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,16 @@ def run_has_comments_pglike(self):
with open('target/catalog.json') as fp:
catalog_data = json.load(fp)
assert 'nodes' in catalog_data
assert len(catalog_data['nodes']) == 2
assert len(catalog_data['nodes']) == 3
table_node = catalog_data['nodes']['model.test.table_model']
view_node = self._assert_has_table_comments(table_node)

view_node = catalog_data['nodes']['model.test.view_model']
self._assert_has_view_comments(view_node)

no_docs_node = catalog_data['nodes']['model.test.no_docs_model']
self._assert_has_view_comments(no_docs_node, False, False)

@use_profile('postgres')
def test_postgres_comments(self):
self.run_has_comments_pglike()
Expand Down Expand Up @@ -116,13 +119,16 @@ def test_redshift_late_binding_view(self):
with open('target/catalog.json') as fp:
catalog_data = json.load(fp)
assert 'nodes' in catalog_data
assert len(catalog_data['nodes']) == 2
assert len(catalog_data['nodes']) == 3
table_node = catalog_data['nodes']['model.test.table_model']
view_node = self._assert_has_table_comments(table_node)

view_node = catalog_data['nodes']['model.test.view_model']
self._assert_has_view_comments(view_node, False, False)

no_docs_node = catalog_data['nodes']['model.test.no_docs_model']
self._assert_has_view_comments(no_docs_node, False, False)


class TestPersistDocsSimple(BasePersistDocsTest):
@property
Expand All @@ -135,9 +141,6 @@ def project_config(self):
"relation": True,
"columns": True,
},
'view_model': {
'bind': False,
}
}
}
}
Expand Down