-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating databases ontop of shares/from replicas failing due to SQL parsing errors #2168
Comments
Hey 👋, so I was trying to reproduce the first case (creating a database from Share) and I'm not sure if that was intentional or a copy-paste error, but Terraform version v1.5.7 resource "snowflake_database" "from_share" {
name = "SHARE_TEST_DB"
data_retention_time_in_days = 1
comment = "some comment"
from_share = {
provider = "\"ORG_NAME\".\"ACCOUNT_NAME\""
share = "TEST_SHARE"
}
lifecycle {
ignore_changes = [data_retention_time_in_days]
}
} But looking at the error message it seems like there might be an issue with unnecessary single quoting around identifiers or how they're specified (in config) in a way that Snowflake doesn't expect. In both cases, it's more of a Snowflake error, not a Terraform Provider error. Let me know if that's the case. |
hey @sfc-gh-jcieslak these are being passed in as variables so provider = "${var.client_snowflake_orgname}"."${var.client_snowflake_account_id}" would look something like the string "simon.em12345" or "simon.prod" This has been working for several months and we are starting to see these errors as early as version 0.70.1, when we try to setup this for a new workspace in terraform. Unfortunately we cannot downgrade the provider further as there are separate bugs. This is a snowflake/sql error, but it only happens when running terraform. If we manually run the command directly in the UI it works. |
hey @christyvp, what I meant about the pasted provider is that in Terraform you cannot do two strings with the dot in between like
and your error message looks like it's indicating a wrong ID which most probably could come from an invalid variable value (could be empty or contain special characters which should be enclosed). Just to make sure, could you check on # snowflake_database.from_share will be created
+ resource "snowflake_database" "from_share" {
+ comment = "some comment"
+ data_retention_time_in_days = 1
+ from_share = {
+ "provider" = "simon.prod"
+ "share" = "TEST_SHARE"
}
+ id = (known after apply)
+ is_transient = false
+ name = "SHARE_TEST_DB"
} If they're not correct, then there might be some issues with variables, etc.
|
Most of the previous errors were cleared up after the 0.70.1 release. But it seems each time an error/bug is resolved a new one is introduced, and then affects random workspaces. We don't see these errors in the terraform plan, they always seem to happen when running the apply - and again only hit a few workspaces. (Sometimes workspaces that have successfully run to completion in the past, and the resources already exist). This PR related to shares was added in release 0.70.1 ... not sure if this had any impact: #2040 - because when I downgrade to 0.69 I don't get the error related to the share, I get the error related to the replica - and I can see in the snowflake UI that the database was created on top of the share. When we downgrade we have other breaking errors so it's really hard to tell. Would it be easier to setup a call / screenshare to work through this? |
@christyvp Hey, I've consulted with the team and maybe the best way to quickly find the issue is to see what exact configuration you're running. Could you share your configuration through the Snowflake representative you have contact with? |
@sfc-gh-jcieslak I have sent this over via slack |
Hey @christyvp could you confirm the issue was resovled ? |
We are still seeing this issue. I'll try the latest provider version |
Hey @christyvp, any updates on the latest version? |
@sfc-gh-jcieslak @sfc-gh-asawicki @sfc-gh-swinkler When trying to move to the latest provider we encounter new errors so we can't determine if it has been resolved. |
Provider Version
Latest. We started seeing this in 0.71 and it still continues in 0.75
Terraform Version
Describe the bug
Weird SQL syntax/parsing errors.
Creating a database from a snowflake share fails due to a syntax/parsing error.
Examples
module.snowflake-inbound-cross-region[0].snowflake_database.from_share: Creating... ╷ │ Error: error creating database CLIENT1_SHARE: 001003 (42000): SQL compilation error: │ syntax error line 1 at position 69 unexpected 'prod'. │ │ with module.snowflake-inbound-cross-region[0].snowflake_database.from_share, │ on snowflake-inbound-cross-region-subaccount/snowflake_db.tf line 1, in resource "snowflake_database" "from_share": │ 1: resource "snowflake_database" "from_share" { │ ╵ Operation failed: failed running terraform apply (exit 1)�
│ Error: error creating database CLIENT2_SHARE: 001003 (42000): SQL compilation error: │ syntax error line 1 at position 51 unexpected 'PE_PROD'. │ │ with module.snowflake-inbound-cross-region[0].snowflake_database.from_share, │ on snowflake-inbound-cross-region-subaccount/snowflake_db.tf line 1, in resource "snowflake_database" "from_share": │ 1: resource "snowflake_database" "from_share" { │ ╵ Operation failed: failed running terraform apply (exit 1)
Creating a database from replica fails due to a syntax/parsing error.
Example
module.snowflake-inbound-cross-region[0].snowflake_database.from_replica: Creating... ╷ │ Error: error creating database CLIENT3_CROSS_REGION_SHARE: 001003 (42000): SQL compilation error: │ parse error line 1 at position 153 near '<EOF>'. │ syntax error line 1 at position 153 unexpected '<EOF>'. │ │ with module.snowflake-inbound-cross-region[0].snowflake_database.from_replica, │ on snowflake-inbound-cross-region-subaccount/snowflake_db.tf line 28, in resource "snowflake_database" "from_replica": │ 28: resource "snowflake_database" "from_replica" { │ ╵ Operation failed: failed running terraform apply (exit 1)�
Expected behavior
Code samples and commands
`resource "snowflake_database" "from_share" {
provider = snowflake.subaccount
name = "${local.client_name_upper}_SHARE"
comment = "Database on top of ${var.client_name}_SHARE - Managed by Terraform"
from_share = {
provider = "${var.client_snowflake_orgname}"."${var.client_snowflake_account_id}"
share = var.inbound_share_name
}
data_retention_time_in_days = 1
lifecycle {
ignore_changes = [data_retention_time_in_days]
}
}
resource "snowflake_database" "with_replication" {
provider = snowflake.subaccount
name = "${local.client_name_upper}_CROSS_REGION_SHARE"
comment = "Duplicate database, replicated into primary snowflake account - Managed by Terraform"
replication_configuration {
accounts = ["REDACTED"]
ignore_edition_check = true
}
depends_on = [snowflake_database.from_share]
}
// primary account setup - Create database, assign permissions
resource "snowflake_database" "from_replica" {
name = "${local.client_name_upper}_CROSS_REGION_SHARE"
comment = "Database replica from ${var.subaccount_region} "
from_replica = "REDACTED"."${local.tf_account_name_alternative}"."${snowflake_database.with_replication.name}"
depends_on = [snowflake_database.with_replication]
}`
Additional context
This is blocking a workflow in our production environment, so I would consider this a high priority.
The text was updated successfully, but these errors were encountered: