Skip to content

Commit

Permalink
lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jcieslak committed Feb 20, 2024
1 parent 6993279 commit 46c33fe
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion docs/resources/database.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ resource "snowflake_database" "from_share" {
### Optional

- `comment` (String)
- `data_retention_time_in_days` (Number) Number of days for which Snowflake retains historical data for performing Time Travel actions (SELECT, CLONE, UNDROP) on the object. A value of 0 effectively disables Time Travel for the specified database, schema, or table. For more information, see Understanding & Using Time Travel.
- `data_retention_time_in_days` (Number) Number of days for which Snowflake retains historical data for performing Time Travel actions (SELECT, CLONE, UNDROP) on the object. A value of 0 effectively disables Time Travel for the specified database. Default value for this field is set to -1, which is a fallback to use Snowflake default. For more information, see Understanding & Using Time Travel.
- `from_database` (String) Specify a database to create a clone from.
- `from_replica` (String) Specify a fully-qualified path to a database to create a replica from. A fully qualified path follows the format of "<organization_name>"."<account_name>"."<db_name>". An example would be: "myorg1"."account1"."db1"
- `from_share` (Map of String) Specify a provider and a share in this map to create a database from a share.
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ resource "snowflake_table" "table" {
- `cluster_by` (List of String) A list of one or more table columns/expressions to be used as clustering key(s) for the table
- `comment` (String) Specifies a comment for the table.
- `data_retention_days` (Number, Deprecated) Specifies the retention period for the table so that Time Travel actions (SELECT, CLONE, UNDROP) can be performed on historical data in the table. Default value is 1, if you wish to inherit the parent schema setting then pass in the schema attribute to this argument.
- `data_retention_time_in_days` (Number) Specifies the retention period for the table so that Time Travel actions (SELECT, CLONE, UNDROP) can be performed on historical data in the table. Default value is 1, if you wish to inherit the parent schema setting then pass in the schema attribute to this argument.
- `data_retention_time_in_days` (Number) Number of days for which Snowflake retains historical data for performing Time Travel actions (SELECT, CLONE, UNDROP) on the object. A value of 0 effectively disables Time Travel for the specified table. Default value for this field is set to -1, which is a fallback to use Snowflake default. For more information, see Understanding & Using Time Travel.
- `primary_key` (Block List, Max: 1, Deprecated) Definitions of primary key constraint to create on table (see [below for nested schema](#nestedblock--primary_key))
- `tag` (Block List, Deprecated) Definitions of a tag to associate with the resource. (see [below for nested schema](#nestedblock--tag))

Expand Down
3 changes: 2 additions & 1 deletion pkg/resources/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"context"
"database/sql"
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"slices"
"strconv"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
Expand Down
6 changes: 3 additions & 3 deletions pkg/resources/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ func CreateTable(d *schema.ResourceData, meta interface{}) error {
if v := d.Get("data_retention_time_in_days"); v.(int) != -1 {
createRequest.WithDataRetentionTimeInDays(sdk.Int(v.(int)))
}
//else if v, ok := d.GetOk("data_retention_days"); ok { // TODO: I would remove it
// else if v, ok := d.GetOk("data_retention_days"); ok { // TODO: I would remove it
// createRequest.WithDataRetentionTimeInDays(sdk.Int(v.(int)))
//}

Expand Down Expand Up @@ -666,7 +666,7 @@ func ReadTable(d *schema.ResourceData, meta interface{}) error {
if v := d.Get("data_retention_time_in_days"); v.(int) != -1 || int64(table.RetentionTime) != schemaRetentionTime {
dataRetentionKey = "data_retention_time_in_days"
}
//else if _, ok := d.GetOk("data_retention_days"); ok { // TODO: I would remove it
// else if _, ok := d.GetOk("data_retention_days"); ok { // TODO: I would remove it
// dataRetentionKey = "data_retention_days"
//}
if dataRetentionKey != "" {
Expand Down Expand Up @@ -724,7 +724,7 @@ func UpdateTable(d *schema.ResourceData, meta interface{}) error {
setRequest.WithChangeTracking(sdk.Bool(changeTracking))
}

//if d.HasChange("data_retention_days") { // TODO: I would remove it
// if d.HasChange("data_retention_days") { // TODO: I would remove it
// dataRetentionDays := d.Get("data_retention_days").(int)
// runSetStatement = true
// setRequest.WithDataRetentionTimeInDays(sdk.Int(dataRetentionDays))
Expand Down
7 changes: 4 additions & 3 deletions pkg/resources/table_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"context"
"database/sql"
"fmt"
"github.com/hashicorp/terraform-plugin-testing/config"
"github.com/hashicorp/terraform-plugin-testing/plancheck"
"github.com/stretchr/testify/require"
"strconv"
"strings"
"testing"

"github.com/hashicorp/terraform-plugin-testing/config"
"github.com/hashicorp/terraform-plugin-testing/plancheck"
"github.com/stretchr/testify/require"

acc "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ resource "snowflake_account_parameter" "test" {
}

resource "snowflake_database" "test" {
name = var.database
name = var.database
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
resource "snowflake_schema" "test" {
database = var.database
name = var.schema
database = var.database
name = var.schema
data_retention_days = var.schema_data_retention_time
}

resource "snowflake_table" "test" {
depends_on = [snowflake_schema.test]
database = var.database
schema = var.schema
name = var.table
depends_on = [snowflake_schema.test]
database = var.database
schema = var.schema
name = var.table
data_retention_time_in_days = var.table_data_retention_time

column {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
resource "snowflake_schema" "test" {
database = var.database
name = var.schema
database = var.database
name = var.schema
data_retention_days = var.schema_data_retention_time
}

resource "snowflake_table" "test" {
depends_on = [snowflake_schema.test]
database = var.database
database = var.database
schema = var.schema
name = var.table
name = var.table

column {
name = "id"
Expand Down

0 comments on commit 46c33fe

Please sign in to comment.