@@ -78,22 +78,44 @@ def test_sea_async_query_with_cloud_fetch():
78
78
logger .info ("Query is no longer pending, getting results..." )
79
79
cursor .get_async_execution_result ()
80
80
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
+
85
107
logger .info (
86
108
f"Requested { requested_row_count } rows, received { actual_row_count } rows"
87
109
)
88
-
89
- # Verify row count
110
+
111
+ # Verify total row count
90
112
if actual_row_count != requested_row_count :
91
113
logger .error (
92
114
f"FAIL: Row count mismatch. Expected { requested_row_count } , got { actual_row_count } "
93
115
)
94
116
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 " )
97
119
98
120
# Close resources
99
121
cursor .close ()
@@ -179,22 +201,44 @@ def test_sea_async_query_without_cloud_fetch():
179
201
logger .info ("Query is no longer pending, getting results..." )
180
202
cursor .get_async_execution_result ()
181
203
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
+
186
230
logger .info (
187
231
f"Requested { requested_row_count } rows, received { actual_row_count } rows"
188
232
)
189
-
190
- # Verify row count
233
+
234
+ # Verify total row count
191
235
if actual_row_count != requested_row_count :
192
236
logger .error (
193
237
f"FAIL: Row count mismatch. Expected { requested_row_count } , got { actual_row_count } "
194
238
)
195
239
return False
196
240
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 " )
198
242
199
243
# Close resources
200
244
cursor .close ()
0 commit comments