Commit bf4fe20
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 555886a commit bf4fe20
1 file changed
+32
-16
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 | | |
| |||
0 commit comments