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

Error message: Actual statement count 2 did not match the desired statement count 1 #648

Closed
aroder opened this issue Aug 17, 2021 · 5 comments
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@aroder
Copy link

aroder commented Aug 17, 2021

Provider Version

The provider version you are using.

provider registry.terraform.io/chanzuckerberg/snowflake v0.22.0

Terraform Version

The version of Terraform you were using when the bug was encountered.

Terraform v1.0.0

Describe the bug

I have created a basic setup with some users, roles, and grants. When I try to remove them by changing their count to 0 and running terraform apply, I get the error message

Error: 000008 (0A000): Actual statement count 2 did not match the desired statement count 1

Expected behavior

I expect the resources to be deleted.

Code samples and commands
The main.tf has a block that adds my snowflake module:

module "snowflake_instance" {
  source = "./modules/snowflake_instance"
  count = var.enable_snowflake_instance ? 1 : 0
  reader_users = var.reader_users
}

where reader_users is defined as

variable "reader_users" {
    type = set(string)
    default = []
}

with a value of

reader_users = ["jsmith"]

The snowflake module adds users, roles and grants such as the following:

resource snowflake_user reader_users {
  for_each = var.reader_users
  name = each.value
  comment = "A user with access to read the public schema in the dw database"
}
resource snowflake_role_grants reader_users_role_grants {
  for_each = var.reader_users
  role_name = snowflake_role.reporter.name
  users = [each.value]
}```

**Additional context**

Add any other context about the problem here.
@aroder aroder added the bug Used to mark issues with provider's incorrect behavior label Aug 17, 2021
@aroder
Copy link
Author

aroder commented Aug 17, 2021

I can reproduce this issue anytime I change the list of roles in a grant. It appears that this forces a replacement, or a drop and then a create. This corroborates the message that there are 2 statements attempting to execute. I don't know if this is useful, but here is an example error message in this case:

image

image

@abdoulsn
Copy link

Having this issue while deployment on Snowflake using liquibase? Any solution?

@praveenkandasamy
Copy link

praveenkandasamy commented Dec 5, 2022

Hi, had this issue on Power bi while running a query on snowflake. Checked out the query history on snowflake and the error was highlighted with further details.

@sfc-gh-asawicki
Copy link
Collaborator

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 sfc-gh-asawicki closed this as not planned Won't fix, can't repro, duplicate, stale Apr 30, 2024
@frankschmitt
Copy link

frankschmitt commented Nov 21, 2024

Having this issue while deployment on Snowflake using liquibase? Any solution?

We ran into the same issue with Snowflake / Liquibase. For us, the solution was to include the Liquibase-specific changeset markes in the SQL file. So instead of


create stage schema1.stage1 DIRECTORY = (ENABLE = TRUE);
put  file://${CI_PROJECT_DIR}/lib/jar/gson-2.10.1.jar @schema1.stage1 auto_compress=false;

we now have

--liquibase formatted sql

--changeset user:1
create stage schema1.stage1 DIRECTORY = (ENABLE = TRUE);
--rollback none;

--changeset user:2
put  file://${CI_PROJECT_DIR}/lib/jar/gson-2.10.1.jar @schema1.stage1 auto_compress=false;
--rollback empty;

and apparently, Liquibase is now executing each statement separately.

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

5 participants