66import pandas
77
88from databricks .sql .backend .sea .backend import SeaDatabricksClient
9- from databricks .sql .backend .sea .models .base import ExternalLink , ResultData , ResultManifest
9+ from databricks .sql .backend .sea .models .base import (
10+ ExternalLink ,
11+ ResultData ,
12+ ResultManifest ,
13+ )
1014from databricks .sql .cloud_fetch_queue import SeaCloudFetchQueue
1115from databricks .sql .utils import SeaResultSetQueueFactory
1216
@@ -44,10 +48,11 @@ def __init__(
4448 command_id : CommandId ,
4549 status : CommandState ,
4650 has_been_closed_server_side : bool = False ,
47- has_more_rows : bool = False ,
4851 results_queue = None ,
4952 description = None ,
5053 is_staging_operation : bool = False ,
54+ lz4_compressed : bool = False ,
55+ arrow_schema_bytes : bytes = b"" ,
5156 ):
5257 """
5358 A ResultSet manages the results of a single command.
@@ -75,9 +80,10 @@ def __init__(
7580 self .command_id = command_id
7681 self .status = status
7782 self .has_been_closed_server_side = has_been_closed_server_side
78- self .has_more_rows = has_more_rows
7983 self .results = results_queue
8084 self ._is_staging_operation = is_staging_operation
85+ self .lz4_compressed = lz4_compressed
86+ self ._arrow_schema_bytes = arrow_schema_bytes
8187
8288 def __iter__ (self ):
8389 while True :
@@ -181,9 +187,8 @@ def __init__(
181187 has_more_rows: Whether there are more rows to fetch
182188 """
183189 # Initialize ThriftResultSet-specific attributes
184- self ._arrow_schema_bytes = execute_response .arrow_schema_bytes
185190 self ._use_cloud_fetch = use_cloud_fetch
186- self .lz4_compressed = execute_response . lz4_compressed
191+ self .has_more_rows = has_more_rows
187192
188193 # Build the results queue if t_row_set is provided
189194 results_queue = None
@@ -210,10 +215,11 @@ def __init__(
210215 command_id = execute_response .command_id ,
211216 status = execute_response .status ,
212217 has_been_closed_server_side = execute_response .has_been_closed_server_side ,
213- has_more_rows = has_more_rows ,
214218 results_queue = results_queue ,
215219 description = execute_response .description ,
216220 is_staging_operation = execute_response .is_staging_operation ,
221+ lz4_compressed = execute_response .lz4_compressed ,
222+ arrow_schema_bytes = execute_response .arrow_schema_bytes ,
217223 )
218224
219225 # Initialize results queue if not provided
@@ -442,6 +448,7 @@ def map_col_type(type_):
442448 for column in table_schema_message .columns
443449 ]
444450
451+
445452class SeaResultSet (ResultSet ):
446453 """ResultSet implementation for SEA backend."""
447454
@@ -473,24 +480,26 @@ def __init__(
473480 if execute_response .command_id
474481 else None
475482 )
476-
483+
477484 # Build the results queue
478485 results_queue = None
479-
486+
480487 if result_data :
481488 from typing import cast , List
482-
489+
483490 # Convert description to the expected format
484491 desc = None
485492 if execute_response .description :
486493 desc = cast (List [Tuple [Any , ...]], execute_response .description )
487-
494+
488495 results_queue = SeaResultSetQueueFactory .build_queue (
489496 result_data ,
490497 manifest ,
491498 str (self .statement_id ),
492499 description = desc ,
493- schema_bytes = execute_response .arrow_schema_bytes if execute_response .arrow_schema_bytes else None ,
500+ schema_bytes = execute_response .arrow_schema_bytes
501+ if execute_response .arrow_schema_bytes
502+ else None ,
494503 max_download_threads = sea_client .max_download_threads ,
495504 ssl_options = sea_client .ssl_options ,
496505 sea_client = sea_client ,
@@ -506,9 +515,10 @@ def __init__(
506515 command_id = execute_response .command_id ,
507516 status = execute_response .status ,
508517 has_been_closed_server_side = execute_response .has_been_closed_server_side ,
509- has_more_rows = execute_response .has_more_rows ,
510518 description = execute_response .description ,
511519 is_staging_operation = execute_response .is_staging_operation ,
520+ lz4_compressed = execute_response .lz4_compressed ,
521+ arrow_schema_bytes = execute_response .arrow_schema_bytes ,
512522 )
513523
514524 # Initialize queue for result data if not provided
0 commit comments