Snowflake-Labs / terraform-provider-snowflake

Terraform provider for managing Snowflake accounts
https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest
MIT License
554 stars 422 forks source link

[Bug]: Cannot create Python Stored Procedures #2856

Open aiden-sobey opened 5 months ago

aiden-sobey commented 5 months ago

Terraform CLI Version

1.7.4

Terraform Provider Version

0.91.0

Terraform Configuration

resource "snowflake_procedure" "staleness_notifications" {
  name     = "SLACK_ALERT_ON_STALE_TABLE"
  database = snowflake_schema.refined.database
  schema   = snowflake_schema.refined.name

  return_type     = "VARCHAR"
  language        = "PYTHON"
  runtime_version = "3.10"
  handler         = "main"
  packages        = ["snowflake-snowpark-python", "requests"]

  arguments {
    name = "table_name"
    type = "varchar"
  }
  arguments {
    name = "hours_since_update"
    type = "integer"
  }

  execute_as = "CALLER"

  statement = <<EOT
    import snowflake.snowpark as snowpark
    import json
    import requests
    import _snowflake
    from datetime import date

    def main(session, table_name, hours_since_update):
      # Generic logic, in our case sending an API request
      return "SUCCESS"
  EOT
}

Category

category:resource

Object type(s)

resource:procedure

Expected Behavior

I expect a Python stored procedure to be created within Snowflake.

Actual Behavior

I receive an error trying to apply the change.

Error: 391531 (42601): SQL compilation error: An active warehouse is required for creating Python stored procedures.

However there is no warehouse parameter on the procedure resource.

Steps to Reproduce

  1. Copy the terraform configuration
  2. Apply

How much impact is this issue causing?

Medium

Logs

https://gist.github.com/aiden-sobey/798fba70d42199eba668a61a7807ad60

Additional Information

I think there needs to be a warehouse parameter on the snowflake_procedure resource, as Snowflake is expecting one to be set.

Would you like to implement a fix?

sfc-gh-asawicki commented 5 months ago

Duplicates #1695.