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

respect-snowflake-quoting.sql #923

Closed
wants to merge 4 commits into from
Closed

respect-snowflake-quoting.sql #923

wants to merge 4 commits into from

Conversation

ludwig-solita
Copy link

@ludwig-solita ludwig-solita commented Mar 6, 2024

Problem

Quoting isn't respected when altering Snowflake tables with non-ansi-sql compliant names. This throws an error when syncing columns in incremental models. I didn't create a new issue since this already seems to recognize the problem
dbt-labs/dbt-adapters#250

image
image
image

Solution

Instead of just using column.name for the alter statements I've added the adapter.quote to properly respect the quoting configuration in yaml-files

Checklist

  • I have read the contributing guide and understand what's expected of me

  • I have run this code in development and it appears to resolve the stated issue
    image

  • This PR includes tests, or tests are not required/relevant for this PR
    It's a quite minor change.

  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX
    It does affect the adapter. I've had discussions with @ernestoongaro regarding the problem.

Quoting isn't respected when altering Snowflake tables with non-ansi-compliant names

https://github.com/dbt-labs/dbt-core/issues/8080
Copy link

cla-bot bot commented Mar 6, 2024

Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA.

In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, please reach out through a comment on this PR.

CLA has not been signed by users: @ludwig-solita

@ludwig-solita
Copy link
Author

CLA is now signed

@VersusFacit
Copy link
Contributor

VersusFacit commented Mar 9, 2024

@cla-bot check

@cla-bot cla-bot bot added the cla:yes label Mar 9, 2024
Copy link

cla-bot bot commented Mar 9, 2024

The cla-bot has been summoned, and re-checked this pull request!

@VersusFacit
Copy link
Contributor

VersusFacit commented Mar 9, 2024

Thanks for submitting the PR. Got some tests failures to work out before we can review and merge. But quoting issues are always important to be accounted for. It feels like there are always more Snowflake edge cases to account for 😄

Also, make sure that you adapt your example of the failure into a test so we can track this going forward 🖖

@ludwig-solita
Copy link
Author

ludwig-solita commented Mar 9, 2024

@VersusFacit - Your welcome :)

Yeah I agree, there are a few quirks. I think quoting shouldn't have been allowed in the first place. How are the tests written? It's my first contribution to this project. The below code would esentially be the test.

Configure project.yml to use quoting for identifiers

quoting:
  identifier: true

Create the table with CTAS

{{
    config(
        materialized="incremental",
        on_schema_change='sync_all_columns'
    )
}}
SELECT 'Hello world!' as original_column

Add new columns

{{
    config(
        materialized="incremental",
        on_schema_change='sync_all_columns'
    )
}}
SELECT 'Hello world!' as original_column
,'Greetings. I come from a non-ansi compliant planet' as "NoN AnSi CoMpLiAnT CoLuMn"
,'Greetings. I come from an ansi compliant planet' as ANSI_COMPLIANT_COLUMN

Copy link

cla-bot bot commented Mar 10, 2024

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: ludwig-sewall.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email [email protected]
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

@cla-bot cla-bot bot removed the cla:yes label Mar 10, 2024
This reverts commit f28a7a6, reversing
changes made to a9859bd.
Copy link

cla-bot bot commented Mar 10, 2024

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: ludwig-sewall, [email protected].
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email [email protected]
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

@ludwig-solita ludwig-solita closed this by deleting the head repository Mar 15, 2024
@ludwig-solita ludwig-solita mentioned this pull request Mar 15, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants