Skip to content

Instantly share code, notes, and snippets.

@drewbanin
Created October 2, 2017 23:48
Show Gist options
  • Save drewbanin/65f1136cc8569a320a42ed342ea1c370 to your computer and use it in GitHub Desktop.
Save drewbanin/65f1136cc8569a320a42ed342ea1c370 to your computer and use it in GitHub Desktop.
-- pseudocode:
```
{% set table_comment = "here is a comment about my table" %}
{% set column_comments = {
"column_1": "column 1 comment is...",
"column_2": "column 2 comment is...",
}
%}
{{
config({
"post-hook": add_comments(this, table_comment, column_comments)
})
}}
...model sql...
```
This would require a macro like:
```
{% macro add_comments(this, table_comment, column_comments %}
COMMENT ON TABLE {{ this }} IS '{{ table_comment | replace("'", "") }}';
{% for column, column_comment in column_comments.items() %}
COMMENT ON COLUMN {{ this }}.{{ column }} IS '{{ column_comment | replace("'", "") }}'";
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment