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

Warehouse creation fails due to quoted identifiers in the SHOW PARAMETERS IN WAREHOUSE query. #844

Closed
sshah90 opened this issue Feb 2, 2022 · 5 comments
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@sshah90
Copy link

sshah90 commented Feb 2, 2022

Provider & Terraform Version

❯ terraform version
Terraform v1.1.4
on darwin_amd64

  • provider registry.terraform.io/chanzuckerberg/snowflake v0.25.36
  • provider registry.terraform.io/hashicorp/random v3.0.1

Describe the bug
I am trying to create a warehouse using snowflake_warehouse resource which fails during terraform apply command with Warehouse 'TEST' does not exist or not authorized.

It does create a warehouse in Snowflake but it's not able to update terraform state files while running SHOW PARAMETERS IN WAREHOUSE test.

Query History from Snowflake side:

Screen Shot 2022-02-02 at 5 09 01 PM

All other queries do have quotes but not with warehouse one.

Expected behavior

terraform apply command should create a warehouse and successfully exit.

Code samples and commands

resource "snowflake_warehouse" "warehouse" {
    for_each       = var.warehouses
    name           = each.key
    comment        = each.value.comment
    warehouse_size = each.value.size
}

variable file :

warehouses = {
    test = {
      comment = "test warehouse"
      size    = "X-Small"
    }
}

Additional context

After debugging, I found this discussion and given suggestion works fine but it stores all object names as the upper case so in the next run it forces changes on other resources like schema or role.

example:

Screen Shot 2022-02-02 at 5 26 06 PM

@sshah90 sshah90 added the bug Used to mark issues with provider's incorrect behavior label Feb 2, 2022
@sshah90
Copy link
Author

sshah90 commented Feb 3, 2022

looks like PR #745 introduced show parameter query in the warehouse resource.

@sonmezonur any thoughts?

@sonmezonur
Copy link
Contributor

@sshah90 Hello. As far as I understand, provider creates warehouses using case-sensitive names (since it surrounded names with double quotes). I have not faced this issue since we only use UpperCase characters while naming our warehouses (only want case-insensitive warehouses). If you surround warehouse name with double quotes, it will probably work. Just need to change this line in the codebase:

https://github.com/chanzuckerberg/terraform-provider-snowflake/blob/d83c499910c0f2b6348191a93f917e450b9e69b2/pkg/snowflake/warehouse.go#L43

to

 return fmt.Sprintf("SHOW PARAMETERS IN WAREHOUSE %q", wb.Builder.name) 

@sonmezonur
Copy link
Contributor

Did you try to change your variable file to:

warehouses = {
    TEST = {
      comment = "test warehouse"
      size    = "X-Small"
    }
}

If you don't have any special reason for using case-sensitive warehouses, I recommend trying uppercase characters in your warehouse setup.

@sshah90
Copy link
Author

sshah90 commented Feb 3, 2022

Hi Sonmezonur, thanks for the suggestion.

With upper case, it works fine. Ideally, it should work with case-insensitive naming standards as the provider allows that with other resouces.

@sfc-gh-asawicki
Copy link
Collaborator

We are closing this issue as part of a cleanup described in announcement. If you believe that the issue is still valid in v0.89.0, please open a new ticket.

@sfc-gh-asawicki sfc-gh-asawicki closed this as not planned Won't fix, can't repro, duplicate, stale Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to mark issues with provider's incorrect behavior
Projects
None yet
Development

No branches or pull requests

3 participants