diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d39d97949..cc8c173b8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ #### Improvements - Added support for reading XML files with namespaces using `rowTag` and `stripNamespaces` options. +- Added support for parameter `is_return_table` in `Session.call`, which can be used to set the return type of the functions a `DataFrame` object. - Added a new argument to `Dataframe.describe` called `strings_include_math_stats` that triggers `stddev` and `mean` to be calculated for String columns. ### Snowpark Local Testing Updates diff --git a/src/snowflake/snowpark/session.py b/src/snowflake/snowpark/session.py index e61ed035a3..275ec4fb8a 100644 --- a/src/snowflake/snowpark/session.py +++ b/src/snowflake/snowpark/session.py @@ -4114,6 +4114,7 @@ def call( *args: Any, statement_params: Optional[Dict[str, Any]] = None, log_on_exception: bool = False, + return_dataframe: Optional[bool] = None, _emit_ast: bool = True, ) -> Any: """Calls a stored procedure by name. @@ -4124,6 +4125,8 @@ def call( statement_params: Dictionary of statement level parameters to be set while executing this action. log_on_exception: Log warnings if they arise when trying to determine if the stored procedure as a table return type. + return_dataframe: When set to True, the return value of this function is a DataFrame object. + This is useful when the given stored procedure's return type is a table. Example:: @@ -4163,6 +4166,7 @@ def call( *args, statement_params=statement_params, log_on_exception=log_on_exception, + is_return_table=return_dataframe, _emit_ast=_emit_ast, ) diff --git a/tests/integ/test_stored_procedure.py b/tests/integ/test_stored_procedure.py index eda496b744..20381ab26c 100644 --- a/tests/integ/test_stored_procedure.py +++ b/tests/integ/test_stored_procedure.py @@ -2120,3 +2120,28 @@ def upload_and_copy_into(session_): # sproc execution ingestion = sproc(upload_and_copy_into, return_type=StringType()) assert ingestion() == "success" + + +@pytest.mark.skipif( + "config.getoption('local_testing_mode', default=False)", + reason="data source is not supported in local testing", + run=False, +) +def test_procedure_with_default_value(session): + temp_sp_name = Utils.random_name_for_temp_object(TempObjectType.PROCEDURE) + sql = f""" +create temporary procedure {temp_sp_name}(col1 INT, col2 STRING default 'snowflake') +returns table(col1 INT, col2 STRING) +LANGUAGE PYTHON +RUNTIME_VERSION = '3.10' +packages = ('snowflake-snowpark-python', 'pandas') +HANDLER = 'my_handler' +AS $$ +def my_handler(session, col1, col2): + + return session.create_dataframe([[col1,col2]],schema=['col1','col2']) +$$; + """ + session.sql(sql).collect() + df = session.call(temp_sp_name, 1, return_dataframe=True) + Utils.check_answer(df, [Row(COL1=1, COL2="snowflake")])