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

Unsetting a database tag fails #1256

Closed
christophkreutzer opened this issue Oct 6, 2022 · 1 comment
Closed

Unsetting a database tag fails #1256

christophkreutzer opened this issue Oct 6, 2022 · 1 comment
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@christophkreutzer
Copy link
Contributor

Provider Version

0.46.0 (latest as of report)

Terraform Version

1.2.2

Describe the bug

Unsetting a database tag (removing tag { } from snowflake_database resource) fails with "Syntax error: unexpected '='."

In Snowflake Query History, you can see the following statement generated:

ALTER DATABASE "TESTDB" UNSET TAG "ACCOUNTING_NUMBER" = "12345"

This is in two ways wrong:

  • The tag is not addressed with a fully qualified name, only with the tag object name
  • UNSET TAG should have no value given

Expected behavior

The database tag is removed.

Code samples and commands

Before:

resource "snowflake_database" "snowflake_db" {
  for_each = { for s in local.snowflake_db : s.name => s }

  name                        = each.value.name
  data_retention_time_in_days = each.value.data_retention_time_in_days

  tag {
    name     = "ACCOUNTING_NUMBER"
    value    = var.accounting_number
    database = var.tag_database
    schema   = var.tag_schema
  }
}

After:

resource "snowflake_database" "snowflake_db" {
  for_each = { for s in local.snowflake_db : s.name => s }

  name                        = each.value.name
  data_retention_time_in_days = each.value.data_retention_time_in_days
}

Diff:

-  tag {
-    name     = "ACCOUNTING_NUMBER"
-    value    = var.accounting_number
-    database = var.tag_database
-    schema   = var.tag_schema
-  }

Additional context

We're trying to move to the new snowflake_tag_association resource (introduced in #1187), but the plan execution fails at least once (seems like the tfstate is updated during a plan - like in #863), which is hindering at best.

@christophkreutzer christophkreutzer added the bug Used to mark issues with provider's incorrect behavior label Oct 6, 2022
christophkreutzer added a commit to christophkreutzer/terraform-provider-snowflake that referenced this issue Oct 6, 2022
* Fixed addressing the tag with a fully qualified identifier
* fixed UNSET by removing value in statement
(see https://docs.snowflake.com/en/sql-reference/sql/alter-database.html#syntax)
sfc-gh-swinkler pushed a commit that referenced this issue Oct 10, 2022
* Fixed addressing the tag with a fully qualified identifier
* fixed UNSET by removing value in statement
(see https://docs.snowflake.com/en/sql-reference/sql/alter-database.html#syntax)
@christophkreutzer
Copy link
Contributor Author

Closed by #1257

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

1 participant