ClickHouse / ClickHouse/dbt-clickhouse

persist_docs not working for materialized views with append set to False

Open
#581 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
362
Forks
177
Avg merge
2d 10h
Merged PRs (30d)
8

Description

### Describe the bug
When creating a materialized view model, setting persist_docs to true in dbt_project.yml should add comments to the created table in Clickhouse. For materialized view models created with append = True, this works fine. However, when append = False then the table is recreated with the materialized view refresh, and doesn't keep the column descriptions.

### Steps to reproduce
1. Set persist_docs: true in the project yaml file
2. Create a materialized view test_model.sql, with settings like the following:
```
{{
config(
materialized='materialized_view',
engine='ReplacingMergeTree()',
order_by=('col1'),
refreshable={
'interval': 'EVERY 1 DAY',
'append': False
},
settings={"allow_nullable_key": 1}
)
}}

--mv:begin
SELECT
now()::DateTime64 AS col1,
today()::Date AS col2
--mv:end
```
3. Create a schema file like:
```
version: 2
models:
- name: test_model
description: A test model
columns:
- name: col1
type: DateTime64
description: The first column
- name: col2
type: Date
description: The second column
```

### Expected behaviour
The column descriptions should propagate to the Clickhouse column Comment field.

I tried setting schema specifically for the materialized view so that when it recreated the table that would get passed on, but it looks like materialized view schemas aren't pushed through at all.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with persist_docs in dbt_project.yml, the materialized_view model in test_model.sql, and its schema file. Trace how append=False recreates the ClickHouse table during materialized view refresh and compare it with append=True; done means the recreated table retains the column descriptions in its Comment fields.

Written by the indexing model from the issue text.

Assessment

Tech stack
clickhouse, python
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.