Skip to content

Arguments for case-sensitive / quoted identifiers in generate_model_yamlΒ #175

@RBABI-Team

Description

@RBABI-Team

Describe the feature

Adapter: dbt-Snowflake v1.7.4
dbt-codegen Version: 0.12.1

We have a number of legacy models in dbt that are leveraging quoted identifiers to preserve casing for downstream use cases, however dbt-codegen does not appear to preserve the case sensitivity when running the generate_model_yaml output.

Example:

models/marts/order_data.sql:

select
      "OrderID",
      "OrderDate",
      "OrderQuantity"
from {{ ref('upstream_order_data') }}

However, when I compile the following script:

{{ codegen.generate_model_yaml(
    model_names=['order_data']
) }}

It compiles to:

version: 2

models:
  - name: order_data
    description: ""
    columns:
      - name: orderid
        data_type: number
        description: ""
      - name: orderdate
        data_type: date
        description: ""
      - name: orderquantity
        data_type: number
        description: ""

Which does not allow dbt documentation/explorer to recognize the field names in the table. It would be great if we had something like the following:

{{ codegen.generate_model_yaml(
    model_names=['order_data'],
   quote_identifiers=true
) }}

Which would preserve the case of the field names and result in something like:

version: 2

models:
  - name: order_data
    description: ""
    columns:
      - name: OrderID
        quote: true
        data_type: number
        description: ""
      - name: OrderDate
        quote: true
        data_type: date
        description: ""
      - name: OrderQuantity
        quote: true
        data_type: number
        description: ""

Changing the project.yml quoting configurations appears to have no effect on this behavior.

Describe alternatives you've considered

Our hope is to eventually stop utilizing quoted identifiers all together, but we need to clean up some downstream dependencies first. For now we've been using the macro as a starting point and manually update as needed.

Additional context

This is obviously very likely Snowflake-specific, but occurs globally in our environment

Who will this benefit?

Any Snowflake users that are currently leveraging quoted identifiers downstream.

Are you interested in contributing this feature?

We'd love to help in any way we can, but could use some guidance on what an ideal solution would be

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions