You are viewing documentation about an older version (1.4.0). View latest version

snowflake.snowpark.Session.call

Session.call(sproc_name: str, *args: Any, statement_params: Dict[str, Any] | None = None) Any[source]

Calls a stored procedure by name.

Parameters:
  • sproc_name – The name of stored procedure in Snowflake.

  • args – Arguments should be basic Python types.

  • statement_params – Dictionary of statement level parameters to be set while executing this action.

Example:

>>> import snowflake.snowpark
>>> from snowflake.snowpark.functions import sproc
>>>
>>> session.add_packages('snowflake-snowpark-python')
>>>
>>> @sproc(name="my_copy_sp", replace=True)
... def my_copy(session: snowflake.snowpark.Session, from_table: str, to_table: str, count: int) -> str:
...     session.table(from_table).limit(count).write.save_as_table(to_table)
...     return "SUCCESS"
>>> _ = session.sql("create or replace table test_from(test_str varchar) as select randstr(20, random()) from table(generator(rowCount => 100))").collect()
>>> _ = session.sql("drop table if exists test_to").collect()
>>> session.call("my_copy_sp", "test_from", "test_to", 10)
'SUCCESS'
>>> session.table("test_to").count()
10
Copy