Skip to content

Commit 9b6afd2

Browse files
add __str__ for CommandId
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent 7a6237e commit 9b6afd2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/databricks/sql/backend/types.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,28 @@ def __init__(
235235
self.has_result_set = has_result_set
236236
self.modified_row_count = modified_row_count
237237

238+
def __str__(self) -> str:
239+
"""
240+
Return a string representation of the CommandId.
241+
242+
For SEA backend, returns the guid.
243+
For Thrift backend, returns a format like "guid|secret".
244+
245+
Returns:
246+
A string representation of the command ID
247+
"""
248+
249+
if self.backend_type == BackendType.SEA:
250+
return str(self.guid)
251+
elif self.backend_type == BackendType.THRIFT:
252+
secret_hex = (
253+
guid_to_hex_id(self.secret)
254+
if isinstance(self.secret, bytes)
255+
else str(self.secret)
256+
)
257+
return f"{self.to_hex_guid()}|{secret_hex}"
258+
return str(self.guid)
259+
238260
@classmethod
239261
def from_thrift_handle(cls, operation_handle):
240262
"""

0 commit comments

Comments
 (0)