Skip to content

persist_docs not working for materialized views with append set to False #581

In review

Description

@abjune-sewerai

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
  1. 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.

Activity

  1. added
    bug
    on Dec 17, 2025
  2. gedaliakliger commented on Nov 17, 2026

    @gedaliakliger

    I could not reproduce this on main (e563957, dbt-clickhouse 1.10.3) with ClickHouse 26.3. A refreshable materialized view without append, with persist_docs on for relation and columns, kept its table and column comments after dbt run and again after SYSTEM REFRESH VIEW had replaced the target table, with catchup both true and false. I tested with a MergeTree target, not the ReplacingMergeTree from the report, and I did not try older ClickHouse versions.

  3. koletzilla commented on Nov 18, 2026

    @koletzilla
    Contributor

    This is no longer reproducible on main with the default catchup: True (fixed as a side effect of #750, not released yet). It still reproduces with catchup: False when the query takes more than a moment to run: the first refresh replaces the target table after dbt has added the comments, so they are lost.

    Keeping the issue open to track that case.

  4. gedaliakliger commented on Nov 18, 2026

    @gedaliakliger

    The catchup: False case is covered by #811. It persists the docs before the refreshable view is created, so the first refresh builds the replacement table with the comments in place. The new test uses catchup=False with a slow query; it passes on that branch and fails on main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions