diff --git a/.changes/unreleased/Fixes-20230810-233738.yaml b/.changes/unreleased/Fixes-20230810-233738.yaml new file mode 100644 index 00000000..62aeea20 --- /dev/null +++ b/.changes/unreleased/Fixes-20230810-233738.yaml @@ -0,0 +1,7 @@ +kind: Fixes +body: Only set the comment when persist_docs.relation is set +time: 2023-08-10T23:37:38.828664+02:00 +custom: + Author: Fokko + Issue: "317" + PR: "343" diff --git a/dbt/include/trino/macros/adapters.sql b/dbt/include/trino/macros/adapters.sql index 32362349..2228934e 100644 --- a/dbt/include/trino/macros/adapters.sql +++ b/dbt/include/trino/macros/adapters.sql @@ -89,8 +89,12 @@ {%- endmacro -%} {% macro comment(comment) %} - {%- if comment is not none and comment|length > 0 -%} - comment '{{ comment | replace("'", "''") }}' + {%- set persist_docs = model['config'].get('persist_docs') -%} + {%- if persist_docs -%} + {%- set persist_relation = persist_docs.get('relation') -%} + {%- if persist_relation and comment is not none and comment|length > 0 -%} + comment '{{ comment | replace("'", "''") }}' + {%- endif -%} {%- endif -%} {%- endmacro -%}