dbt-utils icon indicating copy to clipboard operation
dbt-utils copied to clipboard

feat(unpivot): add quote identifier parameter to handle case sensitive columns

Open error418 opened this issue 1 year ago • 11 comments

resolves #216

This is a:

  • [ ] documentation update
  • [ ] bug fix with no breaking changes
  • [x] new functionality
  • [ ] a breaking change

All pull requests from community contributors should target the main branch (default).

Description & motivation

Added quote_identifiers parameter to unpivot to handle case-sensitive column names. This fixes #216

Checklist

  • [x] This code is associated with an Issue which has been triaged and accepted for development.
  • [x] I have verified that these changes work locally on the following warehouses (Note: it's okay if you do not have access to all warehouses, this helps us understand what has been covered)
    • [x] BigQuery (tested by @Ishankoradia - see PR comments)
    • [x] Postgres
    • [ ] Redshift
    • [ ] Snowflake
  • [x] I followed guidelines to ensure that my changes will work on "non-core" adapters by:
    • [x] dispatching any new macro(s) so non-core adapters can also use them (e.g. the star() source)
    • [x] using the limit_zero() macro in place of the literal string: limit 0
    • [x] using dbt.type_* macros instead of explicit datatypes (e.g. dbt.type_timestamp() instead of TIMESTAMP
  • [x] I have updated the README.md (if applicable)
  • [x] I have added tests & descriptions to my models (and macros if applicable)
  • [x] I have added an entry to CHANGELOG.md

error418 avatar May 09 '23 05:05 error418

rebased to current main and resolved merge conflicts in CHANGELOG.md

error418 avatar May 17 '23 12:05 error418

Anything missing to get this merged?

error418 avatar Jul 03 '23 05:07 error418

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

github-actions[bot] avatar Dec 31 '23 01:12 github-actions[bot]

ping

error418 avatar Dec 31 '23 23:12 error418

Any upates on this? I have encountered a similar scenario where i use date yyyy-mm-dd as the format, it end up evaluating the date string into an arithmic operation. Quoting seems quite useful here.

Shadowsong27 avatar Mar 25 '24 16:03 Shadowsong27

Hi @joellabes and @error418 what are we waiting on for this to be merged ? I have faced a similar issue

Ishankoradia avatar Apr 11 '24 06:04 Ishankoradia

@error418 and @joellabes i have tested the changes for bigquery warehouse also and its work fine.

Ishankoradia avatar Apr 11 '24 08:04 Ishankoradia

hey @error418 @joellabes, facing a similar issue and need to have this merged. can you merge this asap please?

Abhishek-N avatar Apr 11 '24 08:04 Abhishek-N

@Shadowsong27 @Ishankoradia @Abhishek-N at the moment I am waiting for a review by @joellabes (or any maintainer of dbt-utils).

@Ishankoradia thank you for testing the changes for BigQuery

Should there be any remaining issues with this PR I am happy to provide the necessary fixes.

error418 avatar Apr 11 '24 16:04 error418

bump

pnd-mnicolau avatar Apr 30 '24 12:04 pnd-mnicolau

What's missing here? I need this fix to be deployed. Thanks.

alejobs avatar Apr 30 '24 14:04 alejobs

What's missing here? I need this fix to be deployed. Thanks.

MiguelMadero avatar Jun 17 '24 21:06 MiguelMadero

@joellabes could you please provide some information about the status of this pull request?

This is stalling for a while now without any feedback from the maintainers, which sadly becomes a bit frustrating.

Thanks

error418 avatar Jun 23 '24 08:06 error418

Hi all,

This is our highest priority PR to review right now, and I'll be diving deeper into it this week.

After taking an initial look, the heart of the implementation looks good.

The main thing I'd like to follow-up on prior to approving + merging is the testing:

  • It looks like there is special configuration in the CI tests so that Snowflake and Redshift pass

So I'd like to:

  • Make sure that the test is running for Redshift.
  • Align how Snowflake is handled across similar tests. i.e., either standardize on prior art or standardize on the adapter.quote() approach in this PR

dbeatty10 avatar Jun 25 '24 21:06 dbeatty10

@error418 I think I figured out the root cause of the Redshift test failures in CI.

As you noted, the default behavior in Redshift is to lowercase all column names even if a table is created with quoted mixed-case column names.

It looks like the solution is to set enable_case_sensitive_identifier to true. I'm going to try adding that configuration to the CI cluster or workgroup's parameter group and see if that allows this test to pass for Redshift.

dbeatty10 avatar Jun 26 '24 18:06 dbeatty10