Skip to content

Commit fe3acb1

Browse files
replace getters with property tag
Signed-off-by: varun-edachali-dbx <[email protected]>
1 parent c20058e commit fe3acb1

File tree

3 files changed

+24
-26
lines changed

3 files changed

+24
-26
lines changed

src/databricks/sql/backend/types.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def __str__(self) -> str:
139139
if isinstance(self.secret, bytes)
140140
else str(self.secret)
141141
)
142-
return f"{self.get_hex_guid()}|{secret_hex}"
142+
return f"{self.hex_guid}|{secret_hex}"
143143
return str(self.guid)
144144

145145
@classmethod
@@ -217,14 +217,8 @@ def to_sea_session_id(self):
217217

218218
return self.guid
219219

220-
def get_guid(self) -> Any:
221-
"""
222-
Get the ID of the session.
223-
"""
224-
225-
return self.guid
226-
227-
def get_hex_guid(self) -> str:
220+
@property
221+
def hex_guid(self) -> str:
228222
"""
229223
Get a hexadecimal string representation of the session ID.
230224
@@ -237,7 +231,8 @@ def get_hex_guid(self) -> str:
237231
else:
238232
return str(self.guid)
239233

240-
def get_protocol_version(self):
234+
@property
235+
def protocol_version(self):
241236
"""
242237
Get the server protocol version for this session.
243238

src/databricks/sql/client.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,11 @@ def __del__(self):
304304

305305
def get_session_id(self):
306306
"""Get the raw session ID (backend-specific)"""
307-
return self.session.get_id()
307+
return self.session.guid
308308

309309
def get_session_id_hex(self):
310310
"""Get the session ID in hex format"""
311-
return self.session.get_id_hex()
311+
return self.session.guid_hex
312312

313313
@staticmethod
314314
def server_parameterized_queries_enabled(protocolVersion):
@@ -784,7 +784,7 @@ def execute(
784784
self._close_and_clear_active_result_set()
785785
self.active_result_set = self.backend.execute_command(
786786
operation=prepared_operation,
787-
session_id=self.connection.session.get_session_id(),
787+
session_id=self.connection.session.session_id,
788788
max_rows=self.arraysize,
789789
max_bytes=self.buffer_size_bytes,
790790
lz4_compression=self.connection.lz4_compression,
@@ -840,7 +840,7 @@ def execute_async(
840840
self._close_and_clear_active_result_set()
841841
self.backend.execute_command(
842842
operation=prepared_operation,
843-
session_id=self.connection.session.get_session_id(),
843+
session_id=self.connection.session.session_id,
844844
max_rows=self.arraysize,
845845
max_bytes=self.buffer_size_bytes,
846846
lz4_compression=self.connection.lz4_compression,
@@ -927,7 +927,7 @@ def catalogs(self) -> "Cursor":
927927
self._check_not_closed()
928928
self._close_and_clear_active_result_set()
929929
self.active_result_set = self.backend.get_catalogs(
930-
session_id=self.connection.session.get_session_id(),
930+
session_id=self.connection.session.session_id,
931931
max_rows=self.arraysize,
932932
max_bytes=self.buffer_size_bytes,
933933
cursor=self,
@@ -946,7 +946,7 @@ def schemas(
946946
self._check_not_closed()
947947
self._close_and_clear_active_result_set()
948948
self.active_result_set = self.backend.get_schemas(
949-
session_id=self.connection.session.get_session_id(),
949+
session_id=self.connection.session.session_id,
950950
max_rows=self.arraysize,
951951
max_bytes=self.buffer_size_bytes,
952952
cursor=self,
@@ -972,7 +972,7 @@ def tables(
972972
self._close_and_clear_active_result_set()
973973

974974
self.active_result_set = self.backend.get_tables(
975-
session_id=self.connection.session.get_session_id(),
975+
session_id=self.connection.session.session_id,
976976
max_rows=self.arraysize,
977977
max_bytes=self.buffer_size_bytes,
978978
cursor=self,
@@ -1000,7 +1000,7 @@ def columns(
10001000
self._close_and_clear_active_result_set()
10011001

10021002
self.active_result_set = self.backend.get_columns(
1003-
session_id=self.connection.session.get_session_id(),
1003+
session_id=self.connection.session.session_id,
10041004
max_rows=self.arraysize,
10051005
max_bytes=self.buffer_size_bytes,
10061006
cursor=self,

src/databricks/sql/session.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ def open(self):
9595
)
9696
self.protocol_version = self.get_protocol_version(self._session_id)
9797
self.is_open = True
98-
logger.info("Successfully opened session %s", str(self.get_id_hex()))
98+
logger.info("Successfully opened session %s", str(self.guid_hex))
9999

100100
@staticmethod
101101
def get_protocol_version(session_id: SessionId):
102-
return session_id.get_protocol_version()
102+
return session_id.protocol_version
103103

104104
@staticmethod
105105
def server_parameterized_queries_enabled(protocolVersion):
@@ -111,21 +111,24 @@ def server_parameterized_queries_enabled(protocolVersion):
111111
else:
112112
return False
113113

114-
def get_session_id(self) -> SessionId:
114+
@property
115+
def session_id(self) -> SessionId:
115116
"""Get the normalized session ID"""
116117
return self._session_id
117118

118-
def get_id(self):
119+
@property
120+
def guid(self) -> Any:
119121
"""Get the raw session ID (backend-specific)"""
120-
return self._session_id.get_guid()
122+
return self._session_id.guid
121123

122-
def get_id_hex(self) -> str:
124+
@property
125+
def guid_hex(self) -> str:
123126
"""Get the session ID in hex format"""
124-
return self._session_id.get_hex_guid()
127+
return self._session_id.hex_guid
125128

126129
def close(self) -> None:
127130
"""Close the underlying session."""
128-
logger.info("Closing session %s", self.get_id_hex())
131+
logger.info("Closing session %s", self.guid_hex)
129132
if not self.is_open:
130133
logger.debug("Session appears to have been closed already")
131134
return

0 commit comments

Comments
 (0)