Skip to content

Commit

Permalink
Add columns
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jmichalak committed Aug 28, 2024
1 parent ac69c2d commit a00c018
Show file tree
Hide file tree
Showing 10 changed files with 328 additions and 82 deletions.
1 change: 1 addition & 0 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ New fields:
- `is_temporary`
- `data_metric_schedule`
- `data_metric_function`
- `column`
- added `show_output` field that holds the response from SHOW VIEWS.
- added `describe_output` field that holds the response from DESCRIBE VIEW. Note that one needs to grant sufficient privileges e.g. with [grant_ownership](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/grant_ownership) on the tables used in this view. Otherwise, this field is not filled.

Expand Down
21 changes: 19 additions & 2 deletions examples/resources/snowflake_view/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ resource "snowflake_view" "view" {
select * from foo;
SQL
}
# resource with attached policies and data metric functions
# resource with attached policies, columns and data metric functions
resource "snowflake_view" "test" {
database = "database"
schema = "schema"
Expand All @@ -27,6 +27,23 @@ resource "snowflake_view" "test" {
is_secure = "true"
change_tracking = "true"
is_temporary = "true"
column {
column_name = "id"
comment = "column comment"

}
column {
column_name = "address"
projection_policy {
policy_name = "projection_policy"
}

masking_policy {
policy_name = "masking_policy"
using = ["address"]
}

}
row_access_policy {
policy_name = "row_access_policy"
on = ["id"]
Expand All @@ -43,6 +60,6 @@ resource "snowflake_view" "test" {
using_cron = "15 * * * * UTC"
}
statement = <<-SQL
SELECT id FROM TABLE;
SELECT id, address FROM TABLE;
SQL
}
16 changes: 16 additions & 0 deletions pkg/resources/testdata/TestAcc_View/complete/test.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ resource "snowflake_view" "test" {
copy_grants = var.copy_grants
change_tracking = var.change_tracking
is_temporary = var.is_temporary
columns {
column_name = var.column1_name
comment = var.column1_comment

}
columns {
column_name = var.column2_name
projection_policy {
policy_name = var.column2_projection_policy
}

masking_policy {
policy_name = var.column2_masking_policy
using = var.column2_masking_policy_using
}
}
data_metric_function {
function_name = var.data_metric_function
on = var.data_metric_function_on
Expand Down
23 changes: 23 additions & 0 deletions pkg/resources/testdata/TestAcc_View/complete/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,26 @@ variable "data_metric_function" {
variable "data_metric_function_on" {
type = list(string)
}

variable "column1_name" {
type = string
}

variable "column1_comment" {
type = string
}
variable "column2_name" {
type = string
}

variable "column2_masking_policy" {
type = string
}

variable "column2_masking_policy_using" {
type = list(string)
}

variable "column2_projection_policy" {
type = string
}
Loading

0 comments on commit a00c018

Please sign in to comment.