-
Hi, I have a database that was created without terraform that is called resource "snowflake_schema" "stage" {
database = "poc_db"
name = "stage"
is_managed = true
is_transient = false
} This fails with the following error: I know that the error is happening because the provider is using quotes for the database name when trying to create the schema so I've got a couple of questions:
Cheers! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I was looking at old issues and this behaviour sounds similar to this issue: #29 |
Beta Was this translation helpful? Give feedback.
-
As most of the times, the answer to this was on the documentation, exactly here: https://docs.snowflake.com/en/sql-reference/identifiers-syntax.html#controlling-case-using-the-quoted-identifiers-ignore-case-parameter Basically, by default I use a user specifically for Terraform so I changed the parameter for that user like this:
|
Beta Was this translation helpful? Give feedback.
-
"I have a database that was created without terraform that is called poc_db" - I think your issue is actually that your database is NOT called "poc_db". Snowflake object names are case-sensitive. If the database was created without the name being quoted then the default behaviour of Snowflake will have been to convert that name to uppercase, so the database may actually be called POC_DB. When you reference the database name the default behaviour of Snowflake is to convert all references to upper case, such that poc_db, Poc_Db and POC_DB are all treated as POC_DB. However if the reference is quoted, which is always is when using the Snowflake provider, then it's treated literally, i.e. "poc_db" is interpreted as lower case and will not match if the actual name is "POC_DB". So my suggestion is to confirm what the actual names of your schema objects are, including case, and then use the correct name in your Terraform script. Alternatively, if you know all schema objects are using upper case names consistently you can wrap some upper() functions around variables, names etc. to ensure they will match even if a lower case value is passed in. |
Beta Was this translation helpful? Give feedback.
As most of the times, the answer to this was on the documentation, exactly here: https://docs.snowflake.com/en/sql-reference/identifiers-syntax.html#controlling-case-using-the-quoted-identifiers-ignore-case-parameter
Basically, by default
"test"
andtest
are treated differently and if you want both of them to be treated as equals, you need to set this parameter in Snowflake:QUOTED_IDENTIFIERS_IGNORE_CASE = true
. The parameter can be set at different levels, check https://docs.snowflake.com/en/sql-reference/parameters.html#session-parameters.I use a user specifically for Terraform so I changed the parameter for that user like this:
ALTER USER my_user SET QUOTED_IDENTIFIERS_IGNORE_CASE = …