terraform-provider-snowflake icon indicating copy to clipboard operation
terraform-provider-snowflake copied to clipboard

SQL compilation error: An active warehouse is required for creating Python stored procedures.

Open KPGR opened this issue 2 years ago • 5 comments

Provider Version

0.61.0

Terraform Version

1.0.6

Describe the bug

Whilst creating a new Python Stored procedure, I get this error error: creating procedure err = 391531 (42601): SQL compilation error: An active warehouse is required for creating Python stored procedures.

Expected behavior

The stored procedure is created without throwing this error.

Code samples and commands

resource "snowflake_procedure" "test_proc" { name = "stored_proc" database = "TEST" schema = "TEST" language = "PYTHON" comment = "whatever" return_type = "STRING" execute_as = "OWNER" runtime_version = "3.8" handler = "main" packages = ["snowflake-snowpark-python", "pandas"] statement = "my python code" }

Additional context

In order to create a Python stored procedure, the warehouse is required to be defined as well. Therefore, an extra argument "warehouse" needs to be added in the resource and the warehouse needs to be used before creating the procedure. @sfc-gh-jhollan was going in the right direction here: https://github.com/Snowflake-Labs/terraform-provider-snowflake/pull/1533/files, but the PR was closed in favour of https://github.com/Snowflake-Labs/terraform-provider-snowflake/pull/1516

KPGR avatar Apr 07 '23 12:04 KPGR

I detected a similar problem.

Provider Version 0.86.0

Terraform Version 1.7.3

pei0804 avatar Feb 26 '24 08:02 pei0804

Hey @pei0804. I will add this to our consideration for the currently ongoing resources redesign (you can check our roadmap: https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/ROADMAP.md#our-roadmap).

sfc-gh-asawicki avatar Feb 26 '24 11:02 sfc-gh-asawicki

This problem has been resolved. It was possible to use Warehouse with properties.

https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs#warehouse

steps:

grant operate, usage on warehouse xxx_wh to role terraform
$ export SNOWFLAKE_WAREHOUSE:=xxx_wh
$ terraform apply

pei0804 avatar Feb 27 '24 02:02 pei0804