0

I have to create procedure in snowpark with python. I'm trying to get the procedure name inside the function.

CREATE OR REPLACE PROCEDURE TST()
    RETURNS STRING
    LANGUAGE PYTHON
    RUNTIME_VERSION = '3.8'
    PACKAGES = ('snowflake-snowpark-python')
    HANDLER = 'run'
AS
$$
def run(snowpark_session):
    import inspect
    proc_name = inspect.stack()[0][3]
    return proc_name 
$$;

it returns the function name: 'run'.

sys option:

CREATE OR REPLACE PROCEDURE TST()
    RETURNS STRING
    LANGUAGE PYTHON
    RUNTIME_VERSION = '3.8'
    PACKAGES = ('snowflake-snowpark-python')
    HANDLER = 'run'
AS
$$
def run(snowpark_session):
    import sys
    sp_name = sys._getframe().f_back.f_code.co_name
    return sp_name
$$;

it return an error: AttributeError: 'NoneType' object has no attribute 'f_code'

Any idea how to solve it? maybe another way to get the procedure name?

Malka
  • 1

0 Answers0