55import pytest
66
77from clickhouse_connect import create_client
8- from clickhouse_connect import datatypes
8+ from clickhouse_connect import datatypes , common
99from clickhouse_connect .driver .client import Client
1010from clickhouse_connect .driver .exceptions import DatabaseError
1111from tests .integration_tests .conftest import TestConfig
@@ -215,7 +215,13 @@ def test_empty_result(test_client: Client):
215215 assert len (test_client .query ("SELECT * FROM system.tables WHERE name = '_NOT_A THING'" ).result_rows ) == 0
216216
217217
218- def test_temporary_tables (test_client : Client ):
218+ def test_temporary_tables (test_create_client : Callable ):
219+ # Create a dedicated client for this test to ensure connection isolation
220+ # which hopefully helps prevent problems in cloud env.
221+ old_max_age = common .get_setting ('max_connection_age' )
222+ common .set_setting ('max_connection_age' , 0 )
223+ test_client = test_create_client ()
224+
219225 session_id = test_client .get_client_setting ("session_id" )
220226 session_settings = {"session_id" : session_id }
221227 test_client .command ("""
@@ -236,6 +242,9 @@ def test_temporary_tables(test_client: Client):
236242 assert len (df ['field1' ]) == 4
237243 test_client .command ('DROP TABLE IF EXISTS temp_test_table' , settings = session_settings )
238244
245+ test_client .close ()
246+ common .set_setting ('max_connection_age' , old_max_age )
247+
239248
240249def test_str_as_bytes (test_client : Client , table_context : Callable ):
241250 with table_context ('test_insert_bytes' , ['key UInt32' , 'byte_str String' , 'n_byte_str Nullable(String)' ]):
0 commit comments