Created
October 2, 2017 23:48
-
-
Save drewbanin/65f1136cc8569a320a42ed342ea1c370 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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