Skip to content

Commit

Permalink
Fix stored procedure profiler test of error sp (#2618)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-yuwang authored Nov 14, 2024
1 parent f47f532 commit 670507f
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions tests/integ/test_stored_procedure_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,11 @@ def test_create_temp_stage(profiler_session):
def test_stored_proc_error(
is_profiler_function_exist, profiler_session, db_parameters, tmp_stage_name
):
profiler_session.sql('alter session set PYTHON_UDF_CGROUP_MEMSIZE="1g"').collect()
profiler_session.sql("alter session set UDF_SET_CGROUP_ENABLE = true").collect()
profiler_session.sql("alter session set UDF_CGROUP_ENABLE = true").collect()
profiler_session.sql("ALTER SESSION SET ENABLE_UDF_OOM_NOTIFIER = TRUE;").collect()
function_name = f"oom_sp_{Utils.random_function_name()}"

@sproc(name=function_name, replace=True)
def oom_sp(session: snowflake.snowpark.Session) -> str:
gb = 1024 * 1024 * 1024
x = "*" * gb * 5
return f"Return string is of length {len(x)}"
raise ValueError("fake out of memory")

profiler_session.stored_procedure_profiler.register_modules(["oom_sp"])
profiler_session.stored_procedure_profiler.set_target_stage(
Expand All @@ -283,18 +277,15 @@ def oom_sp(session: snowflake.snowpark.Session) -> str:

profiler_session.stored_procedure_profiler.set_active_profiler("LINE")

with pytest.raises(
SnowparkSQLException, match="Function available memory exhausted"
):
with pytest.raises(SnowparkSQLException, match="fake out of memory") as err:
profiler_session.call(function_name)
res = profiler_session.stored_procedure_profiler.get_output()
query_id = profiler_session.stored_procedure_profiler._get_last_query_id()
assert query_id in str(err)

profiler_session.stored_procedure_profiler.disable()

profiler_session.stored_procedure_profiler.register_modules()

assert res is not None and "oom_sp" in res


@pytest.mark.skipif(
"config.getoption('local_testing_mode', default=False)",
Expand Down

0 comments on commit 670507f

Please sign in to comment.