snowflakedb/snowflake-cli

SNOW-1001085: Add support for named arguments and defaults for stored procedures.

Closed this issue · 3 comments

Description

Can we add support for named arguments and defaults for stored procedures?

https://medium.com/snowflake/snowflake-supports-named-and-optional-arguments-389d2500726f

Context

No response

Perhaps something like this:

diff --git a/src/snowcli/cli/snowpark/common.py b/src/snowcli/cli/snowpark/common.py
index 7a160a1..0f9936a 100644
--- a/src/snowcli/cli/snowpark/common.py
+++ b/src/snowcli/cli/snowpark/common.py
@@ -182,6 +182,6 @@ class SnowparkObjectManager(SqlExecutionMixin):

 def build_udf_sproc_identifier(udf_sproc_dict):
     arguments = ", ".join(
-        (f"{arg['name']} {arg['type']}" for arg in udf_sproc_dict["signature"])
+        (f"""{arg['name']} {arg['type']}{" DEFAULT '" + arg['default'] + "'" if 'default' in arg else ''}""" for arg in udf_sproc_dict["signature"])
     )
     return f"{udf_sproc_dict['name']}({arguments})"
diff --git a/src/templates/default_snowpark/snowflake.yml b/src/templates/default_snowpark/snowflake.yml
index 1bfad64..49e4308 100644
--- a/src/templates/default_snowpark/snowflake.yml
+++ b/src/templates/default_snowpark/snowflake.yml
@@ -16,6 +16,7 @@ snowpark:
       signature:
         - name: "name"
           type: "string"
+          default: "value"
       returns: string
     - name: test_procedure
       handler: "procedures.test_procedure"

Good idea, we just have to be mindful about supporting different types of input.

This is done: #701