1010
1111from databricks .sql .backend .sea .result_set import SeaResultSet , Row
1212from databricks .sql .backend .sea .queue import JsonQueue
13+ from databricks .sql .backend .sea .utils .constants import ResultFormat
1314from databricks .sql .backend .types import CommandId , CommandState
1415from databricks .sql .backend .sea .models .base import ResultData , ResultManifest
1516
@@ -59,6 +60,16 @@ def sample_data(self):
5960 ["value5" , "5" , "true" ],
6061 ]
6162
63+ def _create_empty_manifest (self , format : ResultFormat ):
64+ """Create an empty manifest."""
65+ return ResultManifest (
66+ format = format .value ,
67+ schema = {},
68+ total_row_count = - 1 ,
69+ total_byte_count = - 1 ,
70+ total_chunk_count = - 1 ,
71+ )
72+
6273 @pytest .fixture
6374 def result_set_with_data (
6475 self , mock_connection , mock_sea_client , execute_response , sample_data
@@ -75,7 +86,7 @@ def result_set_with_data(
7586 execute_response = execute_response ,
7687 sea_client = mock_sea_client ,
7788 result_data = result_data ,
78- manifest = None ,
89+ manifest = self . _create_empty_manifest ( ResultFormat . JSON_ARRAY ) ,
7990 buffer_size_bytes = 1000 ,
8091 arraysize = 100 ,
8192 )
@@ -88,18 +99,6 @@ def json_queue(self, sample_data):
8899 """Create a JsonQueue with sample data."""
89100 return JsonQueue (sample_data )
90101
91- def empty_manifest (self ):
92- """Create an empty manifest."""
93- return ResultManifest (
94- format = "JSON_ARRAY" ,
95- schema = {},
96- total_row_count = 0 ,
97- total_byte_count = 0 ,
98- total_chunk_count = 0 ,
99- truncated = False ,
100- is_volume_operation = False ,
101- )
102-
103102 def test_init_with_execute_response (
104103 self , mock_connection , mock_sea_client , execute_response
105104 ):
@@ -109,7 +108,7 @@ def test_init_with_execute_response(
109108 execute_response = execute_response ,
110109 sea_client = mock_sea_client ,
111110 result_data = ResultData (data = []),
112- manifest = self .empty_manifest ( ),
111+ manifest = self ._create_empty_manifest ( ResultFormat . JSON_ARRAY ),
113112 buffer_size_bytes = 1000 ,
114113 arraysize = 100 ,
115114 )
@@ -130,7 +129,7 @@ def test_close(self, mock_connection, mock_sea_client, execute_response):
130129 execute_response = execute_response ,
131130 sea_client = mock_sea_client ,
132131 result_data = ResultData (data = []),
133- manifest = self .empty_manifest ( ),
132+ manifest = self ._create_empty_manifest ( ResultFormat . JSON_ARRAY ),
134133 buffer_size_bytes = 1000 ,
135134 arraysize = 100 ,
136135 )
@@ -152,7 +151,7 @@ def test_close_when_already_closed_server_side(
152151 execute_response = execute_response ,
153152 sea_client = mock_sea_client ,
154153 result_data = ResultData (data = []),
155- manifest = self .empty_manifest ( ),
154+ manifest = self ._create_empty_manifest ( ResultFormat . JSON_ARRAY ),
156155 buffer_size_bytes = 1000 ,
157156 arraysize = 100 ,
158157 )
@@ -176,7 +175,7 @@ def test_close_when_connection_closed(
176175 execute_response = execute_response ,
177176 sea_client = mock_sea_client ,
178177 result_data = ResultData (data = []),
179- manifest = self .empty_manifest ( ),
178+ manifest = self ._create_empty_manifest ( ResultFormat . JSON_ARRAY ),
180179 buffer_size_bytes = 1000 ,
181180 arraysize = 100 ,
182181 )
@@ -332,7 +331,7 @@ def test_fetchmany_arrow_not_implemented(
332331 execute_response = execute_response ,
333332 sea_client = mock_sea_client ,
334333 result_data = ResultData (data = None , external_links = []),
335- manifest = self .empty_manifest ( ),
334+ manifest = self ._create_empty_manifest ( ResultFormat . ARROW_STREAM ),
336335 buffer_size_bytes = 1000 ,
337336 arraysize = 100 ,
338337 )
@@ -352,7 +351,7 @@ def test_fetchall_arrow_not_implemented(
352351 execute_response = execute_response ,
353352 sea_client = mock_sea_client ,
354353 result_data = ResultData (data = None , external_links = []),
355- manifest = self .empty_manifest ( ),
354+ manifest = self ._create_empty_manifest ( ResultFormat . ARROW_STREAM ),
356355 buffer_size_bytes = 1000 ,
357356 arraysize = 100 ,
358357 )
@@ -370,7 +369,7 @@ def test_is_staging_operation(
370369 execute_response = execute_response ,
371370 sea_client = mock_sea_client ,
372371 result_data = ResultData (data = []),
373- manifest = self .empty_manifest ( ),
372+ manifest = self ._create_empty_manifest ( ResultFormat . JSON_ARRAY ),
374373 buffer_size_bytes = 1000 ,
375374 arraysize = 100 ,
376375 )
0 commit comments