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

Added comment_clause adapter to support persist_docs #353

Closed
wants to merge 1 commit into from
Closed
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
25 changes: 25 additions & 0 deletions dbt/include/databricks/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,31 @@
{%- endif %}
{%- endmacro -%}

{% macro comment_clause() -%}
{{ return(adapter.dispatch('comment_clause', 'dbt')()) }}
{%- endmacro -%}

{% macro databricks__comment_clause() %}
{%- set raw_persist_docs = config.get('persist_docs', {}) -%}
{%- if raw_persist_docs is mapping -%}
{%- set raw_columns = raw_persist_docs.get('columns', false) -%}
{%- if raw_columns -%}
(
{% for col in model.columns -%}
{{ model.columns[col].name }} comment '{{ model.columns[col].description | replace("'", "\\'") }}'
{{- ", " if not loop.last else "" }}
{% endfor %}
)
{% endif %}
{%- set raw_relation = raw_persist_docs.get('relation', false) -%}
{%- if raw_relation -%}
comment '{{ model.description | replace("'", "\\'") }}'
{% endif %}
{%- elif raw_persist_docs -%}
{{ exceptions.raise_compiler_error("Invalid value provided for 'persist_docs'. Expected dict but got value: " ~ raw_persist_docs) }}
{% endif %}
{%- endmacro -%}


{% macro databricks__create_table_as(temporary, relation, compiled_code, language='sql') -%}
{%- if language == 'sql' -%}
Expand Down