terraform-provider-snowflake
terraform-provider-snowflake copied to clipboard
Cannot create inbound share because account ID conflicts with keyword.
Terraform CLI and Provider Versions
Terraform 1.6.2, Snowflake provider 0.80.0
Terraform Configuration
resource "snowflake_database" "database_example" {
name = "DATABASE_EXAMPLE"
data_retention_time_in_days = 0
from_share = {
# Example has been sanitized -- in reality the account identifier
# is another Snowflake or SQL keyword (but not `SELECT`).
provider = "SELECT.XY12345"
share = "SOME_INBOUND_SHARE"
}
}
Expected Behavior
Share should be created (or in the case of this contrived example, the error "SQL execution error: cannot find an organization whose name is 'SELECT'." ought to be returned).
Actual Behavior
We get the following error --
SQL compilation error:
│ syntax error line 1 at position 40 unexpected 'SELECT'.
│ syntax error line 1 at position 55 unexpected '.'.
│ syntax error line 1 at position 85 unexpected '<EOF>'.
Steps to Reproduce
This appears to actually be a side effect of how the SQL is produced from the name in the CreateSharedDatabaseOptions struct.
In the Snowflake web UI, running the following:
CREATE DATABASE DATABASE_EXAMPLE FROM SHARE SELECT."XY12345"."SOME_INBOUND_SHARE";
results in the syntax error mentioned in "Actual Behavior," while running this instruction:
CREATE DATABASE DATABASE_EXAMPLE FROM SHARE "SELECT"."XY12345"."SOME_INBOUND_SHARE";
results in the desired "cannot find an organization" error mentioned above in "Expected Behavior."
I expect this is just a matter of making sure account identifiers are always double-quoted when converting to SQL text.
This does work as a workaround, but it probably shouldn't be necessary:
resource "snowflake_database" "database_example" {
name = "DATABASE_EXAMPLE"
data_retention_time_in_days = 0
from_share = {
provider = "\"SELECT\".XY12345"
share = "SOME_INBOUND_SHARE"
}
}
How much impact is this issue causing?
Medium
Logs
No response
Additional Information
No response
Hey @originalrkk. Thanks for reporting the issue.
We will be reworking identifiers in the upcoming months. For now, you have to double-quote. It is consistent with the UI behavior, as you mentioned.
Hi 👋
The new version (v0.93.0) contains the new database resources. If you can, please try to migrate to/import the snowflake_shared_database. It has a slightly different structure for specifying from_share and should be more stable than the previous version. Closing the ticket as snowflake_database now represents the standard database and the snowflake_database_old (previously snowflake_database) is no longer supported. If you encounter any issues with the new resources, please report a new issue. We have to still go through rework of identifiers, so it is advised to specify escaped fully qualified names (e.g. from_share = "\"organization_name\".\"account_name\".\"share_name\"").
Thank You.