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

fix: SNOW-59564 remove default data retention in days value #2029

Merged

Conversation

sfc-gh-pbosak
Copy link
Contributor

  • removes default value for data_retention_time_in_days
    Having a default value caused problems when value for data_retention_time_in_days was set with a separate resource.
    Terraform would read the current value set by the dedicated parameter resource, compare it to the default value for the table resource and plan to update it since the two values don't match. This gave the illusion that creating another table somehow interferes with the first one, where in fact any terraform update would give a similar result
  • (BREAKING) renames data_retention_days -> data_retention_time_in_days for consistency
  • marks data_retention_time_in_days as not deprecated

fixes #1938

@sfc-gh-pbosak sfc-gh-pbosak changed the title Snow 859564 remove default data retention in days value fix: SNOW-59564 remove default data retention in days value Aug 23, 2023
@sfc-gh-pbosak sfc-gh-pbosak marked this pull request as ready for review August 23, 2023 11:46
@github-actions
Copy link

Integration tests failure for b725423006ab36c08f55a39c6bb34fc4f4e9087c

@@ -52,7 +52,7 @@ var schemaSchema = map[string]*schema.Schema{
Default: false,
Description: "Specifies a managed schema. Managed access schemas centralize privilege management with the schema owner.",
},
"data_retention_days": {
"data_retention_time_in_days": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not necessary to make this breaking change. Please see: https://developer.hashicorp.com/terraform/plugin/sdkv2/best-practices/deprecations#renaming-an-optional-attribute. We can still leave the old attribute as it is.

@@ -25,7 +25,7 @@ func TestAcc_Table(t *testing.T) {
resource.TestCheckResourceAttr("snowflake_table.test_table", "name", accName),
resource.TestCheckResourceAttr("snowflake_table.test_table", "database", accName),
resource.TestCheckResourceAttr("snowflake_table.test_table", "schema", accName),
resource.TestCheckResourceAttr("snowflake_table.test_table", "data_retention_days", "1"),
resource.TestCheckResourceAttr("snowflake_table.test_table", "data_retention_time_in_days", "1"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any acceptance test showing bad behaviour before and the right one after? I think it would be nice to proceed with bugs by first introducing a test showing the error and then fixing it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its not really bad behavior, its changing the default value of this parameter, as well as changing the name, and adding documentation on how to use this table resource alongside object parameter.

@@ -4,6 +4,7 @@ import (
"database/sql"
"errors"
"fmt"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
File is not gofumpt-ed (gofumpt)

q := builder.ChangeDataRetention(ndr.(int))
if err := snowflake.Exec(db, q); err != nil {
return fmt.Errorf("error changing property on %v", d.Id())
var updateDataRetention = func(key string) error {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
File is not gofumpt-ed (gofumpt)

@github-actions
Copy link

Integration tests failure for c68c82fe40e3237abed4c270c5af455c47f1a990

sfc-gh-swinkler
sfc-gh-swinkler previously approved these changes Sep 7, 2023
@@ -25,7 +25,7 @@ func TestAcc_Table(t *testing.T) {
resource.TestCheckResourceAttr("snowflake_table.test_table", "name", accName),
resource.TestCheckResourceAttr("snowflake_table.test_table", "database", accName),
resource.TestCheckResourceAttr("snowflake_table.test_table", "schema", accName),
resource.TestCheckResourceAttr("snowflake_table.test_table", "data_retention_days", "1"),
resource.TestCheckResourceAttr("snowflake_table.test_table", "data_retention_time_in_days", "1"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its not really bad behavior, its changing the default value of this parameter, as well as changing the name, and adding documentation on how to use this table resource alongside object parameter.

@github-actions
Copy link

Integration tests failure for 6ac72676d8ab523a68d3e9044b4affc4840671ac

@github-actions
Copy link

Integration tests failure for fdc4ec99b698485074b2b38dd7ddb28f45b46a9d

@github-actions
Copy link

Integration tests failure for fdc4ec99b698485074b2b38dd7ddb28f45b46a9d

@github-actions
Copy link

Integration tests failure for 2e843ca4d6679e6fa6862e33f5047dd457810c8a

@github-actions
Copy link

Integration tests failure for 74c81a308569560fc4150fe0582d3bf7a9661406

@github-actions
Copy link

Integration tests success for ad2255c6375b32beb364da2b57c4efddbefba842

@sfc-gh-swinkler sfc-gh-swinkler merged commit 53c20b4 into main Sep 21, 2023
8 checks passed
@sfc-gh-swinkler sfc-gh-swinkler deleted the snow-859564-remove-default-data-retention-in-days-value branch September 21, 2023 08:08
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.

snowflake_object_parameter resource for the key "DATA_RETENTION_TIME_IN_DAYS" is not working as expected
3 participants