Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate_model_yaml: Argument for Quoted Identifiers #175

Open
RBABI-Team opened this issue May 17, 2024 · 0 comments
Open

generate_model_yaml: Argument for Quoted Identifiers #175

RBABI-Team opened this issue May 17, 2024 · 0 comments
Labels
enhancement New feature or request triage

Comments

@RBABI-Team
Copy link

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

@RBABI-Team RBABI-Team added enhancement New feature or request triage labels May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage
Projects
None yet
Development

No branches or pull requests

1 participant