Snowflake-Labs / terraform-provider-snowflake

Terraform provider for managing Snowflake accounts
https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest
MIT License
552 stars 420 forks source link

[Bug]: Unable to set the replace_invalid_characters option for parquet files #3163

Open cekelly opened 3 weeks ago

cekelly commented 3 weeks ago

Terraform CLI Version

1.7.5

Terraform Provider Version

0.78.0

Terraform Configuration

resource "snowflake_file_format" "CREATE_FILE_FORMAT" {
    provider = snowflake.account_admin
    depends_on = [
        snowflake_stage.CREATE_STAGE
    ]

    name = each.value.name
    format_type = each.value.format_type
    database = each.value.database
    schema = each.value.schema
    binary_as_text = true
    replace_invalid_characters = true

    for_each={
        for key, value in local.file_formats : key => {
            name = value.name
            format_type = value.format_type
            database = value.database
            schema = value.schema
        }if alltrue([contains(value.in_level, var.current_level.name), contains(value.in_env, var.current_env)])
    }
}

Category

category:resource

Object type(s)

resource:file_format

Expected Behavior

You should be able to set replace_invalid_characters option for the file format using the provider

Actual Behavior

No change on the option replace_invalid_characters occurs, it is always set to the default of false

Steps to Reproduce

Using the following config, run a terraform plan, then an apply, then go to snowflake and see the value

How much impact is this issue causing?

Medium

Logs

No response

Additional Information

No response

Would you like to implement a fix?

sfc-gh-sghosh commented 3 weeks ago

Hello @cekelly ,

Thanks for raising the issue, we are able to reproduce the issue, will work on it. I can see its not honoring the property even though we passed it from Terraform config file

desc file format TF_PARQUET_FILE_FORMAT1; REPLACE_INVALID_CHARACTERS | Boolean | false | false

`terraform { required_providers { snowflake = { source = "Snowflake-Labs/snowflake" version = "~> 0.87" } } }

provider "snowflake" { account = "account" # the Snowflake account identifier user = "xxxx" password = "xxxx" role = "xxxxx" }

resource "snowflake_file_format" "parquet_file_format" { name = "TF_PARQUET_FILE_FORMAT1" format_type = "PARQUET"

database = "TF_DATABASE" schema = "TF_SCHEMA"

binary_as_text = true compression = "AUTO" replace_invalid_characters = true null_if = ["\N"] }`

Regards, Sujan

sfc-gh-jcieslak commented 3 weeks ago

Hey @cekelly 👋 We are currently focused on pushing all necessary things toward the recently announced v1. We will try to find some time to fix this earlier, but most likely, this will be a fix that will be done as part of file format refactoring that will take place after the v1 release. For now, please try to utilize the unsafe_execute as a way to alter or completely manage the file format.