77logger = logging .getLogger (__name__ )
88
99
10- def test_sea_query_execution ():
10+ def test_sea_query_execution_with_compression ():
1111 """
12- Test executing a query using the SEA backend.
12+ Test executing a query using the SEA backend with result compression .
1313
1414 This function connects to a Databricks SQL endpoint using the SEA backend,
15- executes a simple query, and verifies that execution completes successfully.
15+ executes a simple query with result compression enabled and disabled,
16+ and verifies that execution completes successfully.
1617 """
1718 server_hostname = os .environ .get ("DATABRICKS_SERVER_HOSTNAME" )
1819 http_path = os .environ .get ("DATABRICKS_HTTP_PATH" )
@@ -27,7 +28,8 @@ def test_sea_query_execution():
2728 sys .exit (1 )
2829
2930 try :
30- # Create connection with SEA backend
31+ # Test with compression enabled
32+ logger .info ("Creating connection with LZ4 compression enabled" )
3133 connection = Connection (
3234 server_hostname = server_hostname ,
3335 http_path = http_path ,
@@ -36,27 +38,50 @@ def test_sea_query_execution():
3638 schema = "default" ,
3739 use_sea = True ,
3840 user_agent_entry = "SEA-Test-Client" ,
39- use_cloud_fetch = False ,
41+ use_cloud_fetch = True , # Enable cloud fetch to use compression
42+ enable_query_result_lz4_compression = True , # Enable LZ4 compression
4043 )
4144
4245 logger .info (
4346 f"Successfully opened SEA session with ID: { connection .get_session_id_hex ()} "
4447 )
4548 logger .info (f"backend type: { type (connection .session .backend )} " )
4649
47- # Create a cursor and execute a simple query
50+ # Execute a simple query with compression enabled
4851 cursor = connection .cursor (arraysize = 0 , buffer_size_bytes = 0 )
49-
50- logger .info ("Executing query: SELECT 1 as test_value" )
52+ logger .info ("Executing query with LZ4 compression: SELECT 1 as test_value" )
5153 cursor .execute ("SELECT 1 as test_value" )
54+ logger .info ("Query with compression executed successfully" )
55+ cursor .close ()
56+ connection .close ()
57+ logger .info ("Successfully closed SEA session with compression enabled" )
5258
53- # We don't fetch results yet since we haven't implemented the fetch functionality
54- logger .info ("Query executed successfully" )
59+ # Test with compression disabled
60+ logger .info ("Creating connection with LZ4 compression disabled" )
61+ connection = Connection (
62+ server_hostname = server_hostname ,
63+ http_path = http_path ,
64+ access_token = access_token ,
65+ catalog = catalog ,
66+ schema = "default" ,
67+ use_sea = True ,
68+ user_agent_entry = "SEA-Test-Client" ,
69+ use_cloud_fetch = False , # Enable cloud fetch
70+ enable_query_result_lz4_compression = False , # Disable LZ4 compression
71+ )
5572
56- # Close cursor and connection
73+ logger .info (
74+ f"Successfully opened SEA session with ID: { connection .get_session_id_hex ()} "
75+ )
76+
77+ # Execute a simple query with compression disabled
78+ cursor = connection .cursor (arraysize = 0 , buffer_size_bytes = 0 )
79+ logger .info ("Executing query without compression: SELECT 1 as test_value" )
80+ cursor .execute ("SELECT 1 as test_value" )
81+ logger .info ("Query without compression executed successfully" )
5782 cursor .close ()
5883 connection .close ()
59- logger .info ("Successfully closed SEA session" )
84+ logger .info ("Successfully closed SEA session with compression disabled " )
6085
6186 except Exception as e :
6287 logger .error (f"Error during SEA query execution test: { str (e )} " )
@@ -65,7 +90,7 @@ def test_sea_query_execution():
6590 logger .error (traceback .format_exc ())
6691 sys .exit (1 )
6792
68- logger .info ("SEA query execution test completed successfully" )
93+ logger .info ("SEA query execution test with compression completed successfully" )
6994
7095
7196def test_sea_session ():
@@ -133,5 +158,5 @@ def test_sea_session():
133158 # Test session management
134159 test_sea_session ()
135160
136- # Test query execution
137- test_sea_query_execution ()
161+ # Test query execution with compression
162+ test_sea_query_execution_with_compression ()
0 commit comments