Skip to content

Escape column names with special characters when persisting descriptions as comments #427

Open
@erik-amundson-anthro

Description

@erik-amundson-anthro

Is your feature request related to a problem? Please describe.

I would like to be able to persist my DBT column descriptions as column comments, but for column with special characters the connector fails with persist_docs.columns = true in the project configuration.

For example, this model:

  - name: cell_recipe
    description: Cell recipe information
    columns:
      - name: "standing_vacuum_pressure_1 (kPa)"
        description: Standing vacuum 1 pressure
        data_type: float64
        quote: true
      - name: "standing_vacuum_time_1 (s)"
        description: Standing vacuum 1 time under vacuum
        data_type: int64
        quote: true

creates this query

alter table `common`.`cell_recipe` modify comment ?, comment column standing_vacuum_pressure_1 (kPa) ?, comment column standing_vacuum_time_1 (s) ?

Interestingly, the table name is automatically escaped.

Describe the solution you'd like

I would like to be able to auto-populate column comments using the dbt persist_docs feature.

Describe alternatives you've considered

I've tried the following:

  • Adding quote: true to the column specifications (no effect)
  • Adding double quotes to escape the column name manually (no effect)
  • Adding backticks to escape the column name (causes error)

I could also potentially write my own comment generation as a post-hook but it would be a lot of work to duplicate all the descriptions and keep them up to date.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions