Skip to content
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

SQL compilation error when single quotes are present in snowflake_role comments #2425

Closed
joestepp opened this issue Jan 25, 2024 · 1 comment
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@joestepp
Copy link

joestepp commented Jan 25, 2024

Terraform CLI and Provider Versions

Terraform v1.5.7
on darwin_amd64

  • provider registry.terraform.io/hashicorp/aws v5.33.0
  • provider registry.terraform.io/snowflake-labs/snowflake v0.84.1

Terraform Configuration

resource "snowflake_role" "sandbox_test_user_role" {
  provider = snowflake.security_admin
  name     = "SANDBOX_TEST_USER_ROLE"
  comment  = "A role granting access to test_user's sandbox."
}

resource "snowflake_schema" "sandbox_test_user_schema" {
  database = snowflake_database.sandbox_db.name
  name     = "TEST_USER"
  comment  = "test_user's sandbox managed access schema."

  is_managed = true
}

Expected Behavior

The role comment is created/changed without issue.

Actual Behavior

│ Error: 001003 (42000): SQL compilation error:
│ syntax error line 1 at position 89 unexpected 'sandbox'.
│ syntax error line 1 at position 96 unexpected '.'.

│ with snowflake_role.sandbox_test_user_role,
│ on sandbox.tf line 231, in resource "snowflake_role" "sandbox_test_user_role":
│ 231: resource "snowflake_role" "sandbox_test_user_role" {

Steps to Reproduce

  1. terraform apply

How much impact is this issue causing?

Low

Logs

No response

Additional Information

The comment for the snowflake_schema can be created/changed to include the single quote without issue, but doing the same for the role for some reason causes the error. The generated SQL isn't escaping the single quote for the role. From the debug logs:

2024-01-25T13:41:06.525-0300 [DEBUG] provider.terraform-provider-snowflake_v0.84.1: 2024/01/25 13:41:06 [DEBUG] sql-conn-exec: [query ALTER SCHEMA "SANDBOX"."TEST_USER" SET COMMENT = 'test_user\'s sandbox managed access schema.' err <nil> duration 265.117584ms args {}] ()

vs.

2024-01-25T13:41:06.971-0300 [DEBUG] provider.terraform-provider-snowflake_v0.84.1: 2024/01/25 13:41:06 [DEBUG] sql-conn-exec: [query ALTER ROLE "SANDBOX_TEST_USER_ROLE" SET COMMENT = 'A role granting access to test_user's sandbox.' err 001003 (42000): SQL compilation error:
2024-01-25T13:41:06.971-0300 [DEBUG] provider.terraform-provider-snowflake_v0.84.1: syntax error line 1 at position 89 unexpected 'sandbox'.
2024-01-25T13:41:06.971-0300 [DEBUG] provider.terraform-provider-snowflake_v0.84.1: syntax error line 1 at position 96 unexpected '.'. duration 514.861625ms args {}] (%!s(<nil>))
@joestepp joestepp added the bug Used to mark issues with provider's incorrect behavior label Jan 25, 2024
@sfc-gh-asawicki
Copy link
Collaborator

Hey @joestepp. Thanks for reaching out to us.

Closing it as a duplicate of #2411.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to mark issues with provider's incorrect behavior
Projects
None yet
Development

No branches or pull requests

2 participants