From 3ce1895ac220f98f3b69dda83881baba192bd40c Mon Sep 17 00:00:00 2001 From: Ben Kogan Date: Thu, 20 Aug 2026 10:56:45 -0700 Subject: [PATCH 1/2] NO-SNOW: stop relying on connector threads in pandas CTE test Daily Snowpark pandas CI failed because create_dataframe no longer leaves a background thread on Linux/macOS. Spawn a dummy thread so the warning-filter assertion is deterministic. --- .../modin/test_session_cte_optimization.py | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/tests/integ/modin/test_session_cte_optimization.py b/tests/integ/modin/test_session_cte_optimization.py index 74e251ed8d..657616eddd 100644 --- a/tests/integ/modin/test_session_cte_optimization.py +++ b/tests/integ/modin/test_session_cte_optimization.py @@ -4,7 +4,6 @@ # import logging -import pandas as native_pd import threading from contextlib import contextmanager from typing import Any, Generator @@ -31,29 +30,32 @@ def session_parameter_override( @sql_count_checker(query_count=0) -def test_cte_optimization_for_snowpark_pandas(db_parameters, caplog): +def test_cte_optimization_for_snowpark_pandas(caplog): session = _get_active_session() caplog.set_level(logging.WARNING) - # Creating a dataframe ensures that another thread is running which triggers the warning - session.create_dataframe( - native_pd.DataFrame([[1, 11], [2, 12], [2, 13]], columns=["A", "B"]) + # The multithreading warning is emitted only while another thread is alive. + stop = threading.Event() + extra_thread = threading.Thread( + target=stop.wait, name="cte-opt-warning-probe", daemon=True ) - assert len(threading.enumerate()) > 1 + extra_thread.start() + try: + assert len(threading.enumerate()) > 1 - # Use context manager to temporarily disable CTE optimization - with session_parameter_override(session, "cte_optimization_enabled", False): - assert session.cte_optimization_enabled is False + with session_parameter_override(session, "cte_optimization_enabled", False): + assert session.cte_optimization_enabled is False - caplog.clear() + caplog.clear() - # Verify that cte optimization will be enabled once snowpark pandas is used - assert pd.session == session - assert pd.session.cte_optimization_enabled is True + assert pd.session == session + assert pd.session.cte_optimization_enabled is True - # Verify that the warning is filtered out - assert ( - "You might have more than one threads sharing the Session object trying to update" - not in caplog.text - ) + assert ( + "You might have more than one threads sharing the Session object trying to update" + not in caplog.text + ) + finally: + stop.set() + extra_thread.join() From 267cce5ddfb6f0b010151c87b4fc03383e8957be Mon Sep 17 00:00:00 2001 From: Ben Kogan Date: Thu, 20 Aug 2026 11:01:56 -0700 Subject: [PATCH 2/2] NO-SNOW: prove CTE warning fires without suppression and bound probe-thread join Address review nits: add a positive control for the multithreading warning, drop the redundant daemon flag, and fail if the probe thread does not stop. --- .../modin/test_session_cte_optimization.py | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/integ/modin/test_session_cte_optimization.py b/tests/integ/modin/test_session_cte_optimization.py index 657616eddd..3c3a944502 100644 --- a/tests/integ/modin/test_session_cte_optimization.py +++ b/tests/integ/modin/test_session_cte_optimization.py @@ -15,6 +15,10 @@ from tests.integ.utils.sql_counter import sql_count_checker +_MULTITHREAD_SESSION_WARNING = ( + "You might have more than one threads sharing the Session object trying to update" +) + @contextmanager def session_parameter_override( @@ -37,13 +41,15 @@ def test_cte_optimization_for_snowpark_pandas(caplog): # The multithreading warning is emitted only while another thread is alive. stop = threading.Event() - extra_thread = threading.Thread( - target=stop.wait, name="cte-opt-warning-probe", daemon=True - ) + extra_thread = threading.Thread(target=stop.wait, name="cte-opt-warning-probe") extra_thread.start() try: assert len(threading.enumerate()) > 1 + caplog.clear() + session.cte_optimization_enabled = session.cte_optimization_enabled + assert _MULTITHREAD_SESSION_WARNING in caplog.text + with session_parameter_override(session, "cte_optimization_enabled", False): assert session.cte_optimization_enabled is False @@ -52,10 +58,8 @@ def test_cte_optimization_for_snowpark_pandas(caplog): assert pd.session == session assert pd.session.cte_optimization_enabled is True - assert ( - "You might have more than one threads sharing the Session object trying to update" - not in caplog.text - ) + assert _MULTITHREAD_SESSION_WARNING not in caplog.text finally: stop.set() - extra_thread.join() + extra_thread.join(timeout=5) + assert not extra_thread.is_alive()