Commit 4841279
committed
fix: Split persist docs into column and table comments
The previous version of this macro blended the
`MODIFY COMMENT` command for the table comment
with the `COMMENT COLUMN` commands for the column comments,
inside the same `ALTER TABLE`.
This combined syntax **does not work** with `ON CLUSTER`.
(This was thought to be a clickhouse bug, but that bug is fixed
and the behavior remains.)
The revised macro now sends a separate `ALTER TABLE` for
the table comment `MODIFY COMMENT`, and a separate one for
all the `COMMENT COLUMN` commands.
I've split it up into 2 helper macros that accomplish each
task for maintainability. This also works on non-cluster
setups so there is no need to further complicate it by combining
table and column comment alterations into a single ALTER.
`clickhouse__persist_docs` now runs the relation (table comment)
helper macro if `persist_relations_docs()` is set and descriptions exist
for the relation and the column comment helper macro if
`persist_column_docs()` and columns are defined in the model.
Additionally, the formatting was cleaned up for multiple column
comments so that comments for a different column are not appearing
on the same line. Just makes it easier to read in clickhouse/dbt logs.
Example:
It produced comments like:
```sql
alter table <table>
[ON CLUSTER] modify comment
$dbt_comment_literal_block$<table comment>
$dbt_comment_literal_block$, comment column `col1_name`
$dbt_comment_literal_block$<column comment>
$dbt_comment_lieteral_block$, comment column `col2_name`
...
```
A bit messy, but works on a single node.
Although `ON CLUSTER` is correctly added, this syntax is
incorrect and ONLY produces table and column comments for
the initiator node. Now it does:
```sql
alter table <table>
[ON CLUSTER] modify comment
$dbt_comment_literal_block$ <table comment>
$dbt_comment_literal_block$
alter table <table>
[ON CLUSTER]
comment column `col1_name`
$dbt_comment_literal_block$<column multi
linecomment>$dbt_comment_literal_block$,
comment column `col2_name`
$dbt_comment$ <column comment>$dbt_comment$,
...
```1 parent e4d5aac commit 4841279
File tree
2 files changed
+32
-112
lines changed- dbt/include/clickhouse/macros
- tests/integration/adapter/clickhouse
2 files changed
+32
-112
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
| 13 | + | |
| 14 | + | |
16 | 15 | | |
17 | | - | |
18 | | - | |
| 16 | + | |
19 | 17 | | |
20 | 18 | | |
| 19 | + | |
21 | 20 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
| 21 | + | |
30 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | | - | |
33 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
34 | 49 | | |
35 | | - | |
| 50 | + | |
| 51 | + | |
36 | 52 | | |
37 | 53 | | |
38 | 54 | | |
| |||
Lines changed: 0 additions & 96 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
0 commit comments