snowflakedb / snowflakedb/snowflake-connector-python

SNOW-670332: Creating procedure using functions with variable arguments (*args)

Open
#1,267 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature status-triage_done triaged
Dominant language
Python
Stars
730
Forks
574
Avg merge
5h 45m
Merged PRs (30d)
16

Description

Trying to create a UDF using the snowflake connector by executing this statement. This seems to work for creating a UDF, but not for a Store Procedure. It seems that, while the statement is executed, there is an AST Parser that is executed to check for the arguments.

I would like to take in variable arguments, so that I could modify my function depending on the requirements. Is there a way to achieve what I am trying to do, or by pass the limitation?

  1. What did you do?
create or replace procedure var_arg_proc(arg_1 STRING)
    returns STRING
    language python
    runtime_version = '3.8'
    packages = ('snowflake-snowpark-python')
    handler = 'my_function'
AS
$$
from snowflake.snowpark.session import Session

def my_function(session: Session, *args):
    return arg[0]
$$;
  1. Can you set logging to DEBUG and collect the logs?
100357 (P0000): Python function is defined with 1 arguments (including session), but stored procedure definition
contains 1 arguments. Python function arguments are expected to be session and stored procedure defined 
arguments in function VAR_ARG_PROC with handler my_function

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the stored procedure statement with the Python handler my_function and compare it with the UDF behavior described in the issue. Investigate the AST parser and argument validation that produce error 100357, then determine whether variable arguments can be supported or whether the limitation must be documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sql
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.