Skip to content

Commit d1f045e

Browse files
more clean up
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
1 parent ba2a3a9 commit d1f045e

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

src/databricks/sql/result_set.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def __init__(
244244
session_id_hex=connection.get_session_id_hex(),
245245
statement_id=execute_response.command_id.to_hex_guid(),
246246
chunk_id=self.num_chunks,
247-
http_client=connection.session.http_client,
247+
http_client=connection.http_client,
248248
)
249249
if t_row_set.resultLinks:
250250
self.num_chunks += len(t_row_set.resultLinks)

src/databricks/sql/telemetry/telemetry_client.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -257,18 +257,6 @@ def _send_with_unified_client(self, url, data, headers, timeout=900):
257257
response = self._http_client.request(
258258
HttpMethod.POST, url, body=data, headers=headers, timeout=timeout
259259
)
260-
# Convert urllib3 response to requests-like response for compatibility
261-
response.status_code = response.status
262-
response.ok = 200 <= response.status < 300
263-
response.json = (
264-
lambda: json.loads(response.data.decode()) if response.data else {}
265-
)
266-
# Add raise_for_status method
267-
def raise_for_status():
268-
if not response.ok:
269-
raise Exception(f"HTTP {response.status_code}")
270-
271-
response.raise_for_status = raise_for_status
272260
return response
273261
except Exception as e:
274262
logger.error("Failed to send telemetry with unified client: %s", e)
@@ -279,14 +267,18 @@ def _telemetry_request_callback(self, future, sent_count: int):
279267
try:
280268
response = future.result()
281269

282-
if not response.ok:
270+
# Check if response is successful (urllib3 uses response.status)
271+
is_success = 200 <= response.status < 300
272+
if not is_success:
283273
logger.debug(
284274
"Telemetry request failed with status code: %s, response: %s",
285-
response.status_code,
286-
response.text,
275+
response.status,
276+
response.data.decode() if response.data else "",
287277
)
288278

289-
telemetry_response = TelemetryResponse(**response.json())
279+
# Parse JSON response (urllib3 uses response.data)
280+
response_data = json.loads(response.data.decode()) if response.data else {}
281+
telemetry_response = TelemetryResponse(**response_data)
290282

291283
logger.debug(
292284
"Pushed Telemetry logs with success count: %s, error count: %s",

0 commit comments

Comments
 (0)