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

Add support for optional / default arguments for snowflake_procedure resources

Open Juniper-vdg opened this issue 2 years ago • 4 comments

Terraform CLI and Provider Versions

Terraform v1.7.5
on darwin_arm64
+ provider registry.terraform.io/snowflake-labs/snowflake v0.87.2

Use Cases or Problem Statement

I am trying to create a Stored Procedure using Terraform that has a default / optional argument, as specified in the Snowflake Documentation. However, there does not appear to be a way to configure within the snowflake_procedure module a way to signify if an argument for a Stored Procedure has a default value.

Proposal

To address this issue, I would propose that the arguments schema within the stored_procedure module has a new optional parameter, default. If this parameter is present, then the value of this parameter is the default value of the argument.

As an example, suppose that the usage of a stored_procedure module is like the following:

  name     = "SAMPLEPROC"
  database = snowflake_database.db.name
  schema   = snowflake_schema.schema.name
  language = "JAVASCRIPT"
  arguments {
    name = "arg1"
    type = "varchar"
  }
  arguments {
    name = "arg2"
    type = "varchar"
    default = "my_default_value"
  }
  comment             = "Procedure with 2 arguments"
  return_type         = "VARCHAR"
  execute_as          = "CALLER"
  return_behavior     = "IMMUTABLE"
  null_input_behavior = "RETURNS NULL ON NULL INPUT"
  statement           = <<EOT
var X=1
return X
EOT
}

In this example in the generated SnowSQL that was generated in the DDL, argument arg2 would be an optional argument with the default value my_default_value.

How much impact is this issue causing?

Medium

Additional Information

No response

Juniper-vdg avatar Mar 15 '24 02:03 Juniper-vdg

Hey @Erik-vdg. Thanks for reaching out to us.

We are currently working on redesigning existing resources as part of https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/ROADMAP.md#supporting-all-snowflake-ga-features. We will consider it with the procedure resource.

sfc-gh-asawicki avatar Mar 15 '24 08:03 sfc-gh-asawicki

Thank you! I will look forward to the functionality in a future release.

Juniper-vdg avatar Mar 15 '24 15:03 Juniper-vdg

Hi, I'm hoping for the exact same thing, just for functions rather than procedures. Would it be worth creating a separate issue for this?

deanmorin avatar Sep 19 '24 16:09 deanmorin

Hey @deanmorin 👋 Yes, it would be worth it for tracking purposes. The topic is similar, but it's a different resource and we would like to close this one after it's implemented in procedures. If you want to track the change for functions you can create a similar ticket (even reference this one).

sfc-gh-jcieslak avatar Sep 20 '24 06:09 sfc-gh-jcieslak

Hey @Juniper-vdg.

We introduced new procedure resources in v0.100.0. They are in preview in v1.0.0 and they contain default arguments with some Snowflake limitations. Please check it out and let us know.

sfc-gh-asawicki avatar Dec 13 '24 13:12 sfc-gh-asawicki

Closing due to inactivity.

sfc-gh-asawicki avatar Jan 13 '25 22:01 sfc-gh-asawicki