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

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

Open
RBABI-Team opened this issue May 17, 2024 · 2 comments
Open
Labels
case_sensitivity Issues related to case-sensitivity behavior 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
Copy link

This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days.

@github-actions github-actions bot added the Stale label Nov 14, 2024
@dbeatty10 dbeatty10 added the case_sensitivity Issues related to case-sensitivity behavior label Nov 20, 2024
@dbeatty10 dbeatty10 changed the title generate_model_yaml: Argument for Quoted Identifiers Arguments for case-sensitive / quoted identifiers in generate_model_yaml Nov 20, 2024
@dbeatty10 dbeatty10 removed the Stale label Nov 20, 2024
@tanakou0226
Copy link

@dbeatty10

I am also facing a similar issue when dealing with a Snowflake table that has columns with Japanese names. As the RBABI-Team mentioned, having a quote_identifiers parameter would be greatly helpful.

Is this issue currently being addressed? If not, could I take care of it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
case_sensitivity Issues related to case-sensitivity behavior enhancement New feature or request triage
Projects
None yet
Development

No branches or pull requests

3 participants