terraform-provider-snowflake icon indicating copy to clipboard operation
terraform-provider-snowflake copied to clipboard

null_if value in file_format cannot be set to ''

Open syldor opened this issue 3 years ago • 4 comments

Provider Version

0.25.19

Terraform Version

1.0.3

Describe the bug

It's impossible to create a file_format with a null_if that compiles in snowflake to

"NULL_IF":[""]

It should be possible with:

null_if                        = [""]

but this gives in Snowflake

"NULL_IF":[]

In the code of the provider here: https://github.com/chanzuckerberg/terraform-provider-snowflake/blob/e3e412942c6706942b5dd21af8ea51658ea0ff5b/pkg/snowflake/file_format.go#L339

Should we change the default to be

		q.WriteString(` NULL_IF = ('')`)

as it's the one to consider an empty value as null?

syldor avatar Oct 07 '21 09:10 syldor

Thanks for raising this. I am having the same issue. Would like to see a fix for this please.

adharshdlx avatar Nov 26 '21 11:11 adharshdlx

Would also like to see a fix for this

caiolauro avatar Dec 20 '21 13:12 caiolauro

also experiencing this, and saddened to see zero address of a bug after so many months

mattthaber avatar Aug 24 '22 19:08 mattthaber

@syldor I have tested this in the latest version (0.44.0) and this does not seem to be an issue anymore. My example terraform configuration is:

resource "snowflake_file_format" "example_file_format" {
  name        = "EXAMPLE_FILE_FORMAT"
  database    = snowflake_database.test.name
  schema      = snowflake_schema.test.name
  format_type = "CSV"
  null_if                        = [""]
}

and the resulting query in Snowflake is:

CREATE FILE FORMAT "test"."test"."EXAMPLE_FILE_FORMAT" TYPE = 'CSV' NULL_IF = () SKIP_BLANK_LINES = false TRIM_SPACE = false ERROR_ON_COLUMN_COUNT_MISMATCH = false REPLACE_INVALID_CHARACTERS = false EMPTY_FIELD_AS_NULL = false SKIP_BYTE_ORDER_MARK = false

Which, as you can see the value is correctly set to NULL_IF = ()

If you can please upgrade to the latest version, that should resolve your issue.

sfc-gh-swinkler avatar Sep 22 '22 18:09 sfc-gh-swinkler

I think the correct value is NULL_IF = ('') , not NULL_IF = ().

yo0824 avatar Jan 26 '23 13:01 yo0824

Whether Still this issue exist ,since i am facing still the issue ..its going as NULL_IF = () for ""

Lesly-prem avatar Mar 08 '23 01:03 Lesly-prem

We are closing this issue as part of a cleanup described in announcement. If you believe that the issue is still valid in v0.89.0, please open a new ticket.

sfc-gh-asawicki avatar Apr 30 '24 16:04 sfc-gh-asawicki