Skip to content

view query updates via alter view wipes column comments #1357

@canbekley

Description

@canbekley

The current v2 view materialization with an enabled view_update_via_alter uses ALTER VIEW to reflect changes of the view based on a changeset. When a query change is detected, the resulting ALTER VIEW <view> AS <query> command will wipe all column comments if provided via column_list via the view DDL. They are currently not being added back in.

Steps To Reproduce

  1. materialize the following seed.csv:
id,msg
1,hello
  1. run the following view model with the schema.yaml:
{{
    config(
        materialized='view',
        view_update_via_alter=True,
        persist_docs={
            "relation": True,
            "columns": True,
        },
    )
}}
select id, msg from {{ ref('seed') }};
models:
  - name: my_first_dbt_model
    columns:
      - name: id
        description: "The primary key for this table"
  1. change the view sql definition and rerun the model, e.g.:
select 1 as id, msg from {{ ref('seed') }}

This will wipe the column comment for id and leave the view in an undocumented state.

Expected behavior

The column comments persist, even after a query update. This could be an additional query that adds all comments back in.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions