Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbc5e716

Browse files
move guid to hex id to new utils module
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent1ec8c45 commitbc5e716

File tree

4 files changed

+27
-19
lines changed

4 files changed

+27
-19
lines changed

‎src/databricks/sql/backend/thrift_backend.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
SessionId,
1616
CommandId,
1717
BackendType,
18-
guid_to_hex_id,
1918
)
19+
fromdatabricks.sql.backend.utilsimportguid_to_hex_id
2020

2121
try:
2222
importpyarrow

‎src/databricks/sql/backend/types.py‎

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,10 @@
11
fromenumimportEnum
22
fromtypingimportDict,Optional,Any,Union
3-
importuuid
43
importlogging
54

6-
logger=logging.getLogger(__name__)
7-
8-
9-
defguid_to_hex_id(guid:bytes)->str:
10-
"""Return a hexadecimal string instead of bytes
5+
fromdatabricks.sql.backend.utilsimportguid_to_hex_id
116

12-
Example:
13-
IN b'\x01\xee\x1d)\xa4\x19\x1d\xb6\xa9\xc0\x8d\xf1\xfe\xbaB\xdd'
14-
OUT '01ee1d29-a419-1db6-a9c0-8df1feba42dd'
15-
16-
If conversion to hexadecimal fails, the original bytes are returned
17-
"""
18-
try:
19-
this_uuid=uuid.UUID(bytes=guid)
20-
exceptExceptionase:
21-
logger.debug(f"Unable to convert bytes to UUID:{guid!r} --{str(e)}")
22-
returnstr(guid)
23-
returnstr(this_uuid)
7+
logger=logging.getLogger(__name__)
248

259

2610
classBackendType(Enum):
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .guid_utilsimportguid_to_hex_id
2+
3+
__all__= ["guid_to_hex_id"]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
importuuid
2+
importlogging
3+
4+
logger=logging.getLogger(__name__)
5+
6+
7+
defguid_to_hex_id(guid:bytes)->str:
8+
"""Return a hexadecimal string instead of bytes
9+
10+
Example:
11+
IN b'\x01\xee\x1d)\xa4\x19\x1d\xb6\xa9\xc0\x8d\xf1\xfe\xbaB\xdd'
12+
OUT '01ee1d29-a419-1db6-a9c0-8df1feba42dd'
13+
14+
If conversion to hexadecimal fails, the original bytes are returned
15+
"""
16+
try:
17+
this_uuid=uuid.UUID(bytes=guid)
18+
exceptExceptionase:
19+
logger.debug(f"Unable to convert bytes to UUID:{guid!r} --{str(e)}")
20+
returnstr(guid)
21+
returnstr(this_uuid)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp