@@ -62,46 +62,10 @@ def test_sea_sync_query_with_cloud_fetch():
62
62
logger .info (
63
63
f"Executing synchronous query with cloud fetch to generate { requested_row_count } rows"
64
64
)
65
- cursor .execute (query )
66
-
67
- # Use a mix of fetch methods to retrieve all rows
68
- logger .info ("Retrieving data using a mix of fetch methods" )
69
-
70
- # First, get one row with fetchone
71
- first_row = cursor .fetchone ()
72
- if not first_row :
73
- logger .error ("FAIL: fetchone returned None, expected a row" )
74
- return False
75
-
76
- logger .info (f"Successfully retrieved first row with ID: { first_row [0 ]} " )
77
- retrieved_rows = [first_row ]
78
-
79
- # Then, get a batch of rows with fetchmany
80
- batch_size = 100
81
- batch_rows = cursor .fetchmany (batch_size )
82
- logger .info (f"Successfully retrieved { len (batch_rows )} rows with fetchmany" )
83
- retrieved_rows .extend (batch_rows )
84
-
85
- # Finally, get all remaining rows with fetchall
86
- remaining_rows = cursor .fetchall ()
87
- logger .info (f"Successfully retrieved { len (remaining_rows )} rows with fetchall" )
88
- retrieved_rows .extend (remaining_rows )
89
-
90
- # Calculate total row count
91
- actual_row_count = len (retrieved_rows )
92
-
93
- logger .info (
94
- f"Requested { requested_row_count } rows, received { actual_row_count } rows"
95
- )
96
-
97
- # Verify total row count
98
- if actual_row_count != requested_row_count :
99
- logger .error (
100
- f"FAIL: Row count mismatch. Expected { requested_row_count } , got { actual_row_count } "
101
- )
102
- return False
103
-
104
- logger .info ("PASS: Received correct number of rows with cloud fetch and all fetch methods work correctly" )
65
+ results = [cursor .fetchone ()]
66
+ results .extend (cursor .fetchmany (10 ))
67
+ results .extend (cursor .fetchall ())
68
+ logger .info (f"{ len (results )} rows retrieved against 100 requested" )
105
69
106
70
# Close resources
107
71
cursor .close ()
@@ -163,56 +127,15 @@ def test_sea_sync_query_without_cloud_fetch():
163
127
# For non-cloud fetch, use a smaller row count to avoid exceeding inline limits
164
128
requested_row_count = 100
165
129
cursor = connection .cursor ()
166
- query = f"""
167
- SELECT
168
- id,
169
- concat('value_', repeat('a', 100)) as test_value
170
- FROM range(1, { requested_row_count } + 1) AS t(id)
171
- """
172
-
173
- logger .info (
174
- f"Executing synchronous query without cloud fetch to generate { requested_row_count } rows"
130
+ logger .info ("Executing synchronous query without cloud fetch: SELECT 100 rows" )
131
+ cursor .execute (
132
+ "SELECT id, 'test_value_' || CAST(id as STRING) as test_value FROM range(1, 101)"
175
133
)
176
- cursor .execute (query )
177
-
178
- # Use a mix of fetch methods to retrieve all rows
179
- logger .info ("Retrieving data using a mix of fetch methods" )
180
-
181
- # First, get one row with fetchone
182
- first_row = cursor .fetchone ()
183
- if not first_row :
184
- logger .error ("FAIL: fetchone returned None, expected a row" )
185
- return False
186
-
187
- logger .info (f"Successfully retrieved first row with ID: { first_row [0 ]} " )
188
- retrieved_rows = [first_row ]
189
-
190
- # Then, get a batch of rows with fetchmany
191
- batch_size = 10 # Smaller batch size for non-cloud fetch
192
- batch_rows = cursor .fetchmany (batch_size )
193
- logger .info (f"Successfully retrieved { len (batch_rows )} rows with fetchmany" )
194
- retrieved_rows .extend (batch_rows )
195
-
196
- # Finally, get all remaining rows with fetchall
197
- remaining_rows = cursor .fetchall ()
198
- logger .info (f"Successfully retrieved { len (remaining_rows )} rows with fetchall" )
199
- retrieved_rows .extend (remaining_rows )
200
-
201
- # Calculate total row count
202
- actual_row_count = len (retrieved_rows )
203
-
204
- logger .info (
205
- f"Requested { requested_row_count } rows, received { actual_row_count } rows"
206
- )
207
-
208
- # Verify total row count
209
- if actual_row_count != requested_row_count :
210
- logger .error (
211
- f"FAIL: Row count mismatch. Expected { requested_row_count } , got { actual_row_count } "
212
- )
213
- return False
214
-
215
- logger .info ("PASS: Received correct number of rows without cloud fetch and all fetch methods work correctly" )
134
+
135
+ results = [cursor .fetchone ()]
136
+ results .extend (cursor .fetchmany (10 ))
137
+ results .extend (cursor .fetchall ())
138
+ logger .info (f"{ len (results )} rows retrieved against 100 requested" )
216
139
217
140
# Close resources
218
141
cursor .close ()
0 commit comments