@@ -155,16 +155,6 @@ def fetchall(self) -> List[Row]:
155155 """Fetch all remaining rows of a query result."""
156156 pass
157157
158- @abstractmethod
159- def fetchmany_arrow (self , size : int ) -> "pyarrow.Table" :
160- """Fetch the next set of rows as an Arrow table."""
161- pass
162-
163- @abstractmethod
164- def fetchall_arrow (self ) -> "pyarrow.Table" :
165- """Fetch all remaining rows as an Arrow table."""
166- pass
167-
168158 def close (self ) -> None :
169159 """
170160 Close the result set.
@@ -466,19 +456,13 @@ def __init__(
466456 # Build the results queue
467457 results_queue = None
468458
459+ results_queue = None
469460 if result_data :
470- from typing import cast , List
471-
472- # Convert description to the expected format
473- desc = None
474- if execute_response .description :
475- desc = cast (List [Tuple [Any , ...]], execute_response .description )
476-
477461 results_queue = SeaResultSetQueueFactory .build_queue (
478462 result_data ,
479463 manifest ,
480- str (self . statement_id ),
481- description = desc ,
464+ str (execute_response . command_id . to_sea_statement_id () ),
465+ description = execute_response . description ,
482466 max_download_threads = sea_client .max_download_threads ,
483467 ssl_options = sea_client .ssl_options ,
484468 sea_client = sea_client ,
@@ -524,38 +508,6 @@ def fetchmany_arrow(self, size: int) -> "pyarrow.Table":
524508 n_remaining_rows = size - results .num_rows
525509 self ._next_row_index += results .num_rows
526510
527- while n_remaining_rows > 0 :
528- partial_results = self .results .next_n_rows (n_remaining_rows )
529- results = pyarrow .concat_tables ([results , partial_results ])
530- n_remaining_rows = n_remaining_rows - partial_results .num_rows
531- self ._next_row_index += partial_results .num_rows
532-
533- return results
534-
535- def fetchall_arrow (self ) -> "pyarrow.Table" :
536- """
537- Fetch all remaining rows as an Arrow table.
538-
539- Returns:
540- PyArrow Table containing all remaining rows
541-
542- Raises:
543- ImportError: If PyArrow is not installed
544- """
545- results = self .results .remaining_rows ()
546- self ._next_row_index += results .num_rows
547-
548- # If PyArrow is installed and we have a ColumnTable result, convert it to PyArrow Table
549- # Valid only for metadata commands result set
550- if isinstance (results , ColumnTable ) and pyarrow :
551- data = {
552- name : col
553- for name , col in zip (results .column_names , results .column_table )
554- }
555- return pyarrow .Table .from_pydict (data )
556-
557- return results
558-
559511 def fetchmany_json (self , size : int ):
560512 """
561513 Fetch the next set of rows as a columnar table.
@@ -573,15 +525,8 @@ def fetchmany_json(self, size: int):
573525 raise ValueError (f"size argument for fetchmany is { size } but must be >= 0" )
574526
575527 results = self .results .next_n_rows (size )
576- n_remaining_rows = size - len (results )
577528 self ._next_row_index += len (results )
578529
579- while n_remaining_rows > 0 :
580- partial_results = self .results .next_n_rows (n_remaining_rows )
581- results = results + partial_results
582- n_remaining_rows = n_remaining_rows - len (partial_results )
583- self ._next_row_index += len (partial_results )
584-
585530 return results
586531
587532 def fetchall_json (self ):
@@ -605,9 +550,9 @@ def fetchone(self) -> Optional[Row]:
605550 A single Row object or None if no more rows are available
606551 """
607552 if isinstance (self .results , JsonQueue ):
608- res = self .fetchmany_json (1 )
553+ res = self ._convert_json_table ( self . fetchmany_json (1 ) )
609554 else :
610- res = self . _convert_arrow_table ( self . fetchmany_arrow ( 1 ) )
555+ raise NotImplementedError ( "fetchone only supported for JSON data" )
611556
612557 return res [0 ] if res else None
613558
@@ -625,9 +570,9 @@ def fetchmany(self, size: int) -> List[Row]:
625570 ValueError: If size is negative
626571 """
627572 if isinstance (self .results , JsonQueue ):
628- return self .fetchmany_json (size )
573+ return self ._convert_json_table ( self . fetchmany_json (size ) )
629574 else :
630- return self . _convert_arrow_table ( self . fetchmany_arrow ( size ) )
575+ raise NotImplementedError ( "fetchmany only supported for JSON data" )
631576
632577 def fetchall (self ) -> List [Row ]:
633578 """
@@ -637,6 +582,6 @@ def fetchall(self) -> List[Row]:
637582 List of Row objects containing all remaining rows
638583 """
639584 if isinstance (self .results , JsonQueue ):
640- return self .fetchall_json ()
585+ return self ._convert_json_table ( self . fetchall_json () )
641586 else :
642- return self . _convert_arrow_table ( self . fetchall_arrow () )
587+ raise NotImplementedError ( "fetchall only supported for JSON data" )
0 commit comments