Skip to content

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

@abjune-sewerai

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions