terraform-provider-snowflake: [Bug]: column block-list is changing in every plan (upgrade to v0.95.0 not possible
Terraform CLI Version
1.9.1
Terraform Provider Version
v0.95.0
Terraform Configuration
terraform {
required_version = "~> 1.9.0"
required_providers {
snowflake = {
source = "Snowflake-Labs/snowflake"
version = "~> 0.95.0"
}
}
}
provider "snowflake" {
role = "SYSADMIN"
}
# DATABASE
resource "snowflake_database" "this" {
name = "TEST_DATABASE"
}
# SCHEMA
resource "snowflake_schema" "this" {
database = snowflake_database.this.name
name = "TEST_SCHEMA"
is_transient = "false"
#with_managed_access = "false"
data_retention_time_in_days = 1
}
# TABLES
resource "snowflake_table" "table_1" {
database = snowflake_database.this.name
schema = snowflake_schema.this.name
name = "TEST_TABLE_V1"
data_retention_time_in_days = 1
change_tracking = false
column {
name = "ID"
type = "NUMBER(11,2)"
nullable = false
}
column {
name = "NAME"
type = "VARCHAR(30)"
nullable = true
}
}
resource "snowflake_view" "this" {
database = snowflake_database.this.name
schema = snowflake_schema.this.name
name = "TEST_VIEW"
statement = <<-SQL
SELECT ID, NAME FROM TEST_DATABASE.TEST_SCHEMA.TEST_TABLE_V1;
SQL
is_secure = false
depends_on = [
snowflake_database.this,
snowflake_schema.this,
snowflake_table.table_1
]
}
Category
category:resource
Object type(s)
data_source:views
Expected Behavior
The following terraform configurations should be able to execute a terraform apply without any error and after a successful apply of this code there should not be any open changes left when a new terraform plan is executed after the successful apply
Actual Behavior
After a successful apply when a terraform plan is executed there is always a change for the view object for the column list. Even is the column list is not touched in the code this behaviour leads to an update/replacement of all views in every terraform plan executed.
This is the change/update which shows up after every successful apply in the next terraform plan when using this terraform version and view resources.
Steps to Reproduce
- terraform apply
- terraform plan
- terraform apply
- terraform plan
How much impact is this issue causing?
High
Logs
No response
Additional Information
We are not able to upgrade to version 0.95.0 because of this issue right now and for us it would be important because we need the hotfix for table data types which is implemented in the 0.95.0 release
Would you like to implement a fix?
- Yeah, I’ll take it 😎
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 26 (8 by maintainers)
Commits related to this issue
- fix: Fix views permadiff (#3079) <!-- Feel free to delete comments as you fill this in --> - fix permadiff when columns are not specified - adjust row access policy signature in describe_output and... — committed to snowflakedb/terraform-provider-snowflake by sfc-gh-jmichalak 2 years ago
- fix: Fix views permadiff (#3079) <!-- Feel free to delete comments as you fill this in --> - fix permadiff when columns are not specified - adjust row access policy signature in describe_output and... — committed to snowflakedb/terraform-provider-snowflake by sfc-gh-jmichalak 2 years ago
- fix: Fix parsing text in view, check parenthesis in ParseSchemaObjectIdentifierWithArguments (#3102) <!-- Feel free to delete comments as you fill this in --> <!-- summary of changes --> ## Tes... — committed to snowflakedb/terraform-provider-snowflake by sfc-gh-jmichalak 2 years ago
- feat: Stream on external table resource (#3122) <!-- Feel free to delete comments as you fill this in --> - add snowflake_stream_on_external_table resource - adjust copy grants documentation - adj... — committed to snowflakedb/terraform-provider-snowflake by sfc-gh-jmichalak 2 years ago
I think we can release the fix ~after Wednesday next week.
Thanks for the quick feedback! As the fix was confirmed by a few users, I’m closing this issue. If this happens again, please create a new one.
Thanks @sfc-gh-jmichalak !
Fixed for us as well - we appreciate the fast turn-around!
Confirmed this fixed it for us - thank you!
Hi @liamjamesfoley
Thanks for the detailed logs. This is indeed an error on our side (both of the cases). It happens because the old column list is still populated during CREATE OR REPLACE, which gets called when the statement is changed. This causes incorrect column definition in this SQL statement. This column list should be empty because it’s not specified in the config.
The workaround here is to manually define the
columnlist in the Terraform so that the names in the config match the names in the statement (please take care of proper quoting: in the statement, you use unquoted columns, so I believe in the column config they should be upper case). The other way is to get rid of the old state: remove the resource from the state and import it back. This should ensure that thecolumnsin the state are correct.Currently, I’m working on fixing this behavior.
Hi all, we’ve released v0.96.0, which includes the fix and acceptance test for the column list in views. Please upgrade with the migration guide.
This will be released today or tomorrow.
Hey @sfc-gh-jmichalak, thanks for looking at this issue this fast. We have over 1000 views in our code base and putting all those columns into the config (for sure the code could be generated) means work for our team which we want/need to roll back when the problem is solved. Do you have an idea when the next release will be there so we can decide if we can wait so we do not need to implement the hotfix and then roll back the code changes?
Best regards, Jens