-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add refresh_mode and initialize to dynamic tables (#2437)
This PR contains two commits that add `refresh_mode` and `initialize` parameters to the `snowflake_dynamic_table` resource. `REFRESH_MODE` and `INITIALIZE` are parameters that can only be set at creation time. (I believe these were both added within the last couple months.) They are listed under [required parameters](https://docs.snowflake.com/en/sql-reference/sql/create-dynamic-table#required-parameters) in the documentation, but both have defaults. There are use cases where, for performance or other reasons, users need to be able to override the defaults. This PR adds support for these two options by changing `refresh_mode` from a read-only parameter to a settable optional parameter, and adding `initialize` as a new parameter. Please see the individual commit messages for additional caveats and implementation notes. I am opening this PR because we have ongoing development that is blocked without the ability to set these parameters in Terraform. I realize this repo is in the middle of a major framework update, so please let me know if there's anything I can do to help make these features available without being disruptive to the framework work. ## Test Plan * [x] acceptance tests * [x] testing with our existing stack. We have a stack that includes ~100 dynamic tables, and I have been running `terraform apply` with this code change in place. This should provide decent coverage of use cases.
- Loading branch information
Showing
15 changed files
with
324 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
pkg/resources/testdata/TestAcc_DynamicTable_basic/4/test.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
|
||
resource "snowflake_table" "t" { | ||
database = var.database | ||
schema = var.schema | ||
name = var.table_name | ||
change_tracking = true | ||
column { | ||
name = "id" | ||
type = "NUMBER(38,0)" | ||
} | ||
} | ||
|
||
resource "snowflake_dynamic_table" "dt" { | ||
depends_on = [snowflake_table.t] | ||
name = var.name | ||
database = var.database | ||
schema = var.schema | ||
target_lag { | ||
downstream = true | ||
} | ||
warehouse = var.warehouse | ||
query = var.query | ||
comment = var.comment | ||
refresh_mode = var.refresh_mode | ||
initialize = var.initialize | ||
} |
37 changes: 37 additions & 0 deletions
37
pkg/resources/testdata/TestAcc_DynamicTable_basic/4/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
|
||
variable "name" { | ||
type = string | ||
} | ||
|
||
variable "database" { | ||
type = string | ||
} | ||
|
||
variable "schema" { | ||
type = string | ||
} | ||
|
||
variable "warehouse" { | ||
type = string | ||
} | ||
|
||
variable "query" { | ||
type = string | ||
} | ||
|
||
variable "comment" { | ||
type = string | ||
} | ||
|
||
variable "refresh_mode" { | ||
type = string | ||
} | ||
|
||
variable "initialize" { | ||
type = string | ||
} | ||
|
||
variable "table_name" { | ||
type = string | ||
} |
25 changes: 25 additions & 0 deletions
25
pkg/resources/testdata/TestAcc_DynamicTable_basic/5/test.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
|
||
resource "snowflake_table" "t" { | ||
database = var.database | ||
schema = var.schema | ||
name = var.table_name | ||
change_tracking = true | ||
column { | ||
name = "id" | ||
type = "NUMBER(38,0)" | ||
} | ||
} | ||
|
||
resource "snowflake_dynamic_table" "dt" { | ||
depends_on = [snowflake_table.t] | ||
name = var.name | ||
database = var.database | ||
schema = var.schema | ||
target_lag { | ||
downstream = true | ||
} | ||
warehouse = var.warehouse | ||
query = var.query | ||
comment = var.comment | ||
} |
29 changes: 29 additions & 0 deletions
29
pkg/resources/testdata/TestAcc_DynamicTable_basic/5/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
|
||
variable "name" { | ||
type = string | ||
} | ||
|
||
variable "database" { | ||
type = string | ||
} | ||
|
||
variable "schema" { | ||
type = string | ||
} | ||
|
||
variable "warehouse" { | ||
type = string | ||
} | ||
|
||
variable "query" { | ||
type = string | ||
} | ||
|
||
variable "comment" { | ||
type = string | ||
} | ||
|
||
variable "table_name" { | ||
type = string | ||
} |
Oops, something went wrong.