terraform-provider-snowflake icon indicating copy to clipboard operation
terraform-provider-snowflake copied to clipboard

snowflake_schema errors when comment is changed to null (empty string)

Open Bryan-Meier opened this issue 1 year ago • 1 comments

Terraform CLI and Provider Versions

Terraform v1.5.5 snowflake-labs/snowflake v0.87.0

Terraform Configuration

resource "snowflake_schema" "sf_schema" {
  for_each = local.database_schemas

  database            = each.value.database_name
  name                = each.value.schema_name
  comment             = each.value.schema_comment
  is_transient        = each.value.is_transient
  is_managed          = each.value.is_managed
  data_retention_days = each.value.data_retention_days

  depends_on = [
    snowflake_database.sf_database
  ]
}

Expected Behavior

When a schema has a comment that was set previously, the comment should be able to be removed from the schema in a later apply since comments are not a requirement by Snowflake. This used to work in a previous version of the provider. I would expect that when a comment is changed from an existing comment to an empty string, the apply should run without error.

Actual Behavior

If a comment exists on the schema from a previous apply and in a subsequent apply you try to remove it by setting the comment value to an empty string, it's throwing the following error:

│ Error: error updating schema comment on SOME_DB|SOME_SCHEMA err = [schemas.go:195] at least one of SchemaSet fields [DataRetentionTimeInDays MaxDataExtensionTimeInDays DefaultDDLCollation Comment] must be set │ │ with snowflake_schema.sf_schema["SOME_DB|SOME_SCHEMA"], │ on main.tf line 143, in resource "snowflake_schema" "sf_schema": │ 143: resource "snowflake_schema" "sf_schema" {

Steps to Reproduce

  1. Set a comment on a schema
  2. Apply the comment
  3. Remove the comment on the same schema
  4. Apply the removal

How much impact is this issue causing?

High

Logs

No response

Additional Information

When we went to upgrade from v0.71.0 to 0.87.0 and were met with error above. We are basically making sure we don't remove any comments at this point.

Bryan-Meier avatar Mar 07 '24 19:03 Bryan-Meier

Hey @Bryan-Meier. Thanks for reporting the issue.

This is an easy one, we should be able to add it to one of the other changes. We should have a fix with the next release.

sfc-gh-asawicki avatar Mar 08 '24 09:03 sfc-gh-asawicki

Hey @Bryan-Meier. Fix released in v0.88.0.

Please check and close the issue if the problem is solved for you.

sfc-gh-asawicki avatar Apr 09 '24 15:04 sfc-gh-asawicki

I will check it out. Thank you!

Bryan-Meier avatar Apr 09 '24 16:04 Bryan-Meier

Problem fixed. Thank you @sfc-gh-asawicki!!

Bryan-Meier avatar Apr 10 '24 00:04 Bryan-Meier