Skip to content

Commit db73ecf

Browse files
add line gaps after multi-line pydocs for consistency
Signed-off-by: varun-edachali-dbx <[email protected]>
1 parent 54f2b93 commit db73ecf

File tree

6 files changed

+32
-0
lines changed

6 files changed

+32
-0
lines changed

src/databricks/sql/backend/types.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def from_thrift_state(
5757
- CLOSED_STATE -> CLOSED
5858
- CANCELED_STATE -> CANCELLED
5959
"""
60+
6061
if state in (
6162
ttypes.TOperationState.INITIALIZED_STATE,
6263
ttypes.TOperationState.PENDING_STATE,
@@ -113,6 +114,7 @@ def __init__(
113114
secret: The secret part of the identifier (only used for Thrift)
114115
properties: Additional information about the session
115116
"""
117+
116118
self.backend_type = backend_type
117119
self.guid = guid
118120
self.secret = secret
@@ -128,6 +130,7 @@ def __str__(self) -> str:
128130
Returns:
129131
A string representation of the session ID
130132
"""
133+
131134
if self.backend_type == BackendType.SEA:
132135
return str(self.guid)
133136
elif self.backend_type == BackendType.THRIFT:
@@ -152,6 +155,7 @@ def from_thrift_handle(
152155
Returns:
153156
A SessionId instance
154157
"""
158+
155159
if session_handle is None:
156160
return None
157161

@@ -178,6 +182,7 @@ def from_sea_session_id(
178182
Returns:
179183
A SessionId instance
180184
"""
185+
181186
return cls(BackendType.SEA, session_id, properties=properties)
182187

183188
def to_thrift_handle(self):
@@ -187,6 +192,7 @@ def to_thrift_handle(self):
187192
Returns:
188193
A TSessionHandle object or None if this is not a Thrift session ID
189194
"""
195+
190196
if self.backend_type != BackendType.THRIFT:
191197
return None
192198

@@ -205,6 +211,7 @@ def to_sea_session_id(self):
205211
Returns:
206212
The session ID string or None if this is not a SEA session ID
207213
"""
214+
208215
if self.backend_type != BackendType.SEA:
209216
return None
210217

@@ -214,6 +221,7 @@ def get_guid(self) -> Any:
214221
"""
215222
Get the ID of the session.
216223
"""
224+
217225
return self.guid
218226

219227
def get_hex_guid(self) -> str:
@@ -223,6 +231,7 @@ def get_hex_guid(self) -> str:
223231
Returns:
224232
A hexadecimal string representation
225233
"""
234+
226235
if isinstance(self.guid, bytes):
227236
return guid_to_hex_id(self.guid)
228237
else:
@@ -236,6 +245,7 @@ def get_protocol_version(self):
236245
The server protocol version or None if it does not exist
237246
It is not expected to exist for SEA sessions.
238247
"""
248+
239249
return self.properties.get("serverProtocolVersion")
240250

241251

@@ -267,6 +277,7 @@ def __init__(
267277
has_result_set: Whether the command has a result set
268278
modified_row_count: The number of rows modified by the command
269279
"""
280+
270281
self.backend_type = backend_type
271282
self.guid = guid
272283
self.secret = secret
@@ -307,6 +318,7 @@ def from_thrift_handle(cls, operation_handle):
307318
Returns:
308319
A CommandId instance
309320
"""
321+
310322
if operation_handle is None:
311323
return None
312324

@@ -333,6 +345,7 @@ def from_sea_statement_id(cls, statement_id: str):
333345
Returns:
334346
A CommandId instance
335347
"""
348+
336349
return cls(BackendType.SEA, statement_id)
337350

338351
def to_thrift_handle(self):
@@ -342,6 +355,7 @@ def to_thrift_handle(self):
342355
Returns:
343356
A TOperationHandle object or None if this is not a Thrift command ID
344357
"""
358+
345359
if self.backend_type != BackendType.THRIFT:
346360
return None
347361

@@ -362,6 +376,7 @@ def to_sea_statement_id(self):
362376
Returns:
363377
The statement ID string or None if this is not a SEA statement ID
364378
"""
379+
365380
if self.backend_type != BackendType.SEA:
366381
return None
367382

@@ -374,6 +389,7 @@ def to_hex_guid(self) -> str:
374389
Returns:
375390
A hexadecimal string representation
376391
"""
392+
377393
if isinstance(self.guid, bytes):
378394
return guid_to_hex_id(self.guid)
379395
else:

src/databricks/sql/backend/utils/guid_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def guid_to_hex_id(guid: bytes) -> str:
1414
If conversion to hexadecimal fails, a string representation of the original
1515
bytes is returned
1616
"""
17+
1718
try:
1819
this_uuid = uuid.UUID(bytes=guid)
1920
except Exception as e:

src/databricks/sql/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ def __init__(
397397
Cursors are not isolated, i.e., any changes done to the database by a cursor are immediately
398398
visible by other cursors or connections.
399399
"""
400+
400401
self.connection = connection
401402
self.rowcount = -1 # Return -1 as this is not supported
402403
self.buffer_size_bytes = result_buffer_size_bytes
@@ -755,6 +756,7 @@ def execute(
755756
756757
:returns self
757758
"""
759+
758760
logger.debug(
759761
"Cursor.execute(operation=%s, parameters=%s)", operation, parameters
760762
)
@@ -814,6 +816,7 @@ def execute_async(
814816
:param parameters:
815817
:return:
816818
"""
819+
817820
param_approach = self._determine_parameter_approach(parameters)
818821
if param_approach == ParameterApproach.NONE:
819822
prepared_params = NO_NATIVE_PARAMS

src/databricks/sql/session.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def __init__(
3131
3232
This class handles all session-related behavior and communication with the backend.
3333
"""
34+
3435
self.is_open = False
3536
self.host = server_hostname
3637
self.port = kwargs.get("_port", 443)

src/databricks/sql/types.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ def asDict(self, recursive: bool = False) -> Dict[str, Any]:
158158
>>> row.asDict(True) == {'key': 1, 'value': {'name': 'a', 'age': 2}}
159159
True
160160
"""
161+
161162
if not hasattr(self, "__fields__"):
162163
raise TypeError("Cannot convert a Row class into dict")
163164

@@ -186,6 +187,7 @@ def __contains__(self, item: Any) -> bool:
186187
# let object acts like class
187188
def __call__(self, *args: Any) -> "Row":
188189
"""create new Row object"""
190+
189191
if len(args) > len(self):
190192
raise ValueError(
191193
"Can not create Row with fields %s, expected %d values "
@@ -228,13 +230,15 @@ def __reduce__(
228230
self,
229231
) -> Union[str, Tuple[Any, ...]]:
230232
"""Returns a tuple so Python knows how to pickle Row."""
233+
231234
if hasattr(self, "__fields__"):
232235
return (_create_row, (self.__fields__, tuple(self)))
233236
else:
234237
return tuple.__reduce__(self)
235238

236239
def __repr__(self) -> str:
237240
"""Printable representation of Row used in Python REPL."""
241+
238242
if hasattr(self, "__fields__"):
239243
return "Row(%s)" % ", ".join(
240244
"%s=%r" % (k, v) for k, v in zip(self.__fields__, tuple(self))

src/databricks/sql/utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ def build_queue(
7474
Returns:
7575
ResultSetQueue
7676
"""
77+
7778
if row_set_type == TSparkRowSetType.ARROW_BASED_SET:
7879
arrow_table, n_valid_rows = convert_arrow_based_set_to_arrow_table(
7980
t_row_set.arrowBatches, lz4_compressed, arrow_schema_bytes
@@ -173,12 +174,14 @@ def __init__(
173174
:param n_valid_rows: The index of the last valid row in the table
174175
:param start_row_index: The first row in the table we should start fetching from
175176
"""
177+
176178
self.cur_row_index = start_row_index
177179
self.arrow_table = arrow_table
178180
self.n_valid_rows = n_valid_rows
179181

180182
def next_n_rows(self, num_rows: int) -> "pyarrow.Table":
181183
"""Get upto the next n rows of the Arrow dataframe"""
184+
182185
length = min(num_rows, self.n_valid_rows - self.cur_row_index)
183186
# Note that the table.slice API is not the same as Python's slice
184187
# The second argument should be length, not end index
@@ -216,6 +219,7 @@ def __init__(
216219
lz4_compressed (bool): Whether the files are lz4 compressed.
217220
description (List[List[Any]]): Hive table schema description.
218221
"""
222+
219223
self.schema_bytes = schema_bytes
220224
self.max_download_threads = max_download_threads
221225
self.start_row_index = start_row_offset
@@ -256,6 +260,7 @@ def next_n_rows(self, num_rows: int) -> "pyarrow.Table":
256260
Returns:
257261
pyarrow.Table
258262
"""
263+
259264
if not self.table:
260265
logger.debug("CloudFetchQueue: no more rows available")
261266
# Return empty pyarrow table to cause retry of fetch
@@ -285,6 +290,7 @@ def remaining_rows(self) -> "pyarrow.Table":
285290
Returns:
286291
pyarrow.Table
287292
"""
293+
288294
if not self.table:
289295
# Return empty pyarrow table to cause retry of fetch
290296
return self._create_empty_table()
@@ -566,6 +572,7 @@ def transform_paramstyle(
566572
Returns:
567573
str
568574
"""
575+
569576
output = operation
570577
if (
571578
param_structure == ParameterStructure.POSITIONAL

0 commit comments

Comments
 (0)