Skip to content

Commit 75b0773

Browse files
remove excess changes in backend
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent 6137a3d commit 75b0773

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/databricks/sql/backend/thrift_backend.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ def make_request(self, method, request, retryable=True):
352352
Will stop retry attempts if total elapsed time + next retry delay would exceed
353353
_retry_stop_after_attempts_duration.
354354
"""
355+
355356
# basic strategy: build range iterator rep'ing number of available
356357
# retries. bounds can be computed from there. iterate over it with
357358
# retries until success or final failure achieved.
@@ -1241,7 +1242,7 @@ def cancel_command(self, command_id: CommandId) -> None:
12411242
if not thrift_handle:
12421243
raise ValueError("Not a valid Thrift command ID")
12431244

1244-
logger.debug("Cancelling command {}".format(command_id.guid))
1245+
logger.debug("Cancelling command {}".format(guid_to_hex_id(command_id.guid)))
12451246
req = ttypes.TCancelOperationReq(thrift_handle)
12461247
self.make_request(self._client.CancelOperation, req)
12471248

src/databricks/sql/backend/types.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,8 @@ def from_thrift_state(
8585
def from_sea_state(cls, state: str) -> Optional["CommandState"]:
8686
"""
8787
Map SEA state string to CommandState enum.
88-
8988
Args:
9089
state: SEA state string
91-
9290
Returns:
9391
CommandState: The corresponding CommandState enum value
9492
"""
@@ -308,6 +306,28 @@ def __init__(
308306
self.has_result_set = has_result_set
309307
self.modified_row_count = modified_row_count
310308

309+
def __str__(self) -> str:
310+
"""
311+
Return a string representation of the CommandId.
312+
313+
For SEA backend, returns the guid.
314+
For Thrift backend, returns a format like "guid|secret".
315+
316+
Returns:
317+
A string representation of the command ID
318+
"""
319+
320+
if self.backend_type == BackendType.SEA:
321+
return str(self.guid)
322+
elif self.backend_type == BackendType.THRIFT:
323+
secret_hex = (
324+
guid_to_hex_id(self.secret)
325+
if isinstance(self.secret, bytes)
326+
else str(self.secret)
327+
)
328+
return f"{self.to_hex_guid()}|{secret_hex}"
329+
return str(self.guid)
330+
311331
@classmethod
312332
def from_thrift_handle(cls, operation_handle):
313333
"""
@@ -319,6 +339,7 @@ def from_thrift_handle(cls, operation_handle):
319339
Returns:
320340
A CommandId instance
321341
"""
342+
322343
if operation_handle is None:
323344
return None
324345

0 commit comments

Comments
 (0)