@@ -78,22 +78,44 @@ def test_sea_async_query_with_cloud_fetch():
7878 logger .info ("Query is no longer pending, getting results..." )
7979 cursor .get_async_execution_result ()
8080
81- # Fetch all rows
82- rows = cursor .fetchall ()
83- actual_row_count = len (rows )
84-
81+ # Use a mix of fetch methods to retrieve all rows
82+ logger .info ("Retrieving data using a mix of fetch methods" )
83+
84+ # First, get one row with fetchone
85+ first_row = cursor .fetchone ()
86+ if not first_row :
87+ logger .error ("FAIL: fetchone returned None, expected a row" )
88+ return False
89+
90+ logger .info (f"Successfully retrieved first row with ID: { first_row [0 ]} " )
91+ retrieved_rows = [first_row ]
92+
93+ # Then, get a batch of rows with fetchmany
94+ batch_size = 100
95+ batch_rows = cursor .fetchmany (batch_size )
96+ logger .info (f"Successfully retrieved { len (batch_rows )} rows with fetchmany" )
97+ retrieved_rows .extend (batch_rows )
98+
99+ # Finally, get all remaining rows with fetchall
100+ remaining_rows = cursor .fetchall ()
101+ logger .info (f"Successfully retrieved { len (remaining_rows )} rows with fetchall" )
102+ retrieved_rows .extend (remaining_rows )
103+
104+ # Calculate total row count
105+ actual_row_count = len (retrieved_rows )
106+
85107 logger .info (
86108 f"Requested { requested_row_count } rows, received { actual_row_count } rows"
87109 )
88-
89- # Verify row count
110+
111+ # Verify total row count
90112 if actual_row_count != requested_row_count :
91113 logger .error (
92114 f"FAIL: Row count mismatch. Expected { requested_row_count } , got { actual_row_count } "
93115 )
94116 return False
95-
96- logger .info ("PASS: Received correct number of rows with cloud fetch" )
117+
118+ logger .info ("PASS: Received correct number of rows with cloud fetch and all fetch methods work correctly " )
97119
98120 # Close resources
99121 cursor .close ()
@@ -179,22 +201,44 @@ def test_sea_async_query_without_cloud_fetch():
179201 logger .info ("Query is no longer pending, getting results..." )
180202 cursor .get_async_execution_result ()
181203
182- # Fetch all rows
183- rows = cursor .fetchall ()
184- actual_row_count = len (rows )
185-
204+ # Use a mix of fetch methods to retrieve all rows
205+ logger .info ("Retrieving data using a mix of fetch methods" )
206+
207+ # First, get one row with fetchone
208+ first_row = cursor .fetchone ()
209+ if not first_row :
210+ logger .error ("FAIL: fetchone returned None, expected a row" )
211+ return False
212+
213+ logger .info (f"Successfully retrieved first row with ID: { first_row [0 ]} " )
214+ retrieved_rows = [first_row ]
215+
216+ # Then, get a batch of rows with fetchmany
217+ batch_size = 10 # Smaller batch size for non-cloud fetch
218+ batch_rows = cursor .fetchmany (batch_size )
219+ logger .info (f"Successfully retrieved { len (batch_rows )} rows with fetchmany" )
220+ retrieved_rows .extend (batch_rows )
221+
222+ # Finally, get all remaining rows with fetchall
223+ remaining_rows = cursor .fetchall ()
224+ logger .info (f"Successfully retrieved { len (remaining_rows )} rows with fetchall" )
225+ retrieved_rows .extend (remaining_rows )
226+
227+ # Calculate total row count
228+ actual_row_count = len (retrieved_rows )
229+
186230 logger .info (
187231 f"Requested { requested_row_count } rows, received { actual_row_count } rows"
188232 )
189-
190- # Verify row count
233+
234+ # Verify total row count
191235 if actual_row_count != requested_row_count :
192236 logger .error (
193237 f"FAIL: Row count mismatch. Expected { requested_row_count } , got { actual_row_count } "
194238 )
195239 return False
196240
197- logger .info ("PASS: Received correct number of rows without cloud fetch" )
241+ logger .info ("PASS: Received correct number of rows without cloud fetch and all fetch methods work correctly " )
198242
199243 # Close resources
200244 cursor .close ()
0 commit comments