Skip to content

Commit 53ab3c4

Browse files
formatting (black)
1 parent f80bc15 commit 53ab3c4

File tree

4 files changed

+35
-36
lines changed

4 files changed

+35
-36
lines changed

src/databricks/sql/backend/databricks_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
# Forward reference for type hints
99
from typing import TYPE_CHECKING
10+
1011
if TYPE_CHECKING:
1112
from databricks.sql.result_set import ResultSet
1213

src/databricks/sql/backend/thrift_backend.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -845,14 +845,14 @@ def get_execution_result(self, op_handle, cursor):
845845
description=description,
846846
arrow_schema_bytes=schema_bytes,
847847
)
848-
848+
849849
return ThriftResultSet(
850850
connection=cursor.connection,
851851
execute_response=execute_response,
852852
thrift_client=self,
853853
buffer_size_bytes=cursor.buffer_size_bytes,
854854
arraysize=cursor.arraysize,
855-
use_cloud_fetch=cursor.connection.use_cloud_fetch
855+
use_cloud_fetch=cursor.connection.use_cloud_fetch,
856856
)
857857

858858
def _wait_until_command_done(self, op_handle, initial_operation_status_resp):
@@ -951,14 +951,14 @@ def execute_command(
951951
return None
952952
else:
953953
execute_response = self._handle_execute_response(resp, cursor)
954-
954+
955955
return ThriftResultSet(
956956
connection=cursor.connection,
957957
execute_response=execute_response,
958958
thrift_client=self,
959959
buffer_size_bytes=max_bytes,
960960
arraysize=max_rows,
961-
use_cloud_fetch=use_cloud_fetch
961+
use_cloud_fetch=use_cloud_fetch,
962962
)
963963

964964
def get_catalogs(self, session_handle, max_rows, max_bytes, cursor):
@@ -971,16 +971,16 @@ def get_catalogs(self, session_handle, max_rows, max_bytes, cursor):
971971
),
972972
)
973973
resp = self.make_request(self._client.GetCatalogs, req)
974-
974+
975975
execute_response = self._handle_execute_response(resp, cursor)
976-
976+
977977
return ThriftResultSet(
978978
connection=cursor.connection,
979979
execute_response=execute_response,
980980
thrift_client=self,
981981
buffer_size_bytes=max_bytes,
982982
arraysize=max_rows,
983-
use_cloud_fetch=cursor.connection.use_cloud_fetch
983+
use_cloud_fetch=cursor.connection.use_cloud_fetch,
984984
)
985985

986986
def get_schemas(
@@ -1003,16 +1003,16 @@ def get_schemas(
10031003
schemaName=schema_name,
10041004
)
10051005
resp = self.make_request(self._client.GetSchemas, req)
1006-
1006+
10071007
execute_response = self._handle_execute_response(resp, cursor)
1008-
1008+
10091009
return ThriftResultSet(
10101010
connection=cursor.connection,
10111011
execute_response=execute_response,
10121012
thrift_client=self,
10131013
buffer_size_bytes=max_bytes,
10141014
arraysize=max_rows,
1015-
use_cloud_fetch=cursor.connection.use_cloud_fetch
1015+
use_cloud_fetch=cursor.connection.use_cloud_fetch,
10161016
)
10171017

10181018
def get_tables(
@@ -1039,16 +1039,16 @@ def get_tables(
10391039
tableTypes=table_types,
10401040
)
10411041
resp = self.make_request(self._client.GetTables, req)
1042-
1042+
10431043
execute_response = self._handle_execute_response(resp, cursor)
1044-
1044+
10451045
return ThriftResultSet(
10461046
connection=cursor.connection,
10471047
execute_response=execute_response,
10481048
thrift_client=self,
10491049
buffer_size_bytes=max_bytes,
10501050
arraysize=max_rows,
1051-
use_cloud_fetch=cursor.connection.use_cloud_fetch
1051+
use_cloud_fetch=cursor.connection.use_cloud_fetch,
10521052
)
10531053

10541054
def get_columns(
@@ -1075,16 +1075,16 @@ def get_columns(
10751075
columnName=column_name,
10761076
)
10771077
resp = self.make_request(self._client.GetColumns, req)
1078-
1078+
10791079
execute_response = self._handle_execute_response(resp, cursor)
1080-
1080+
10811081
return ThriftResultSet(
10821082
connection=cursor.connection,
10831083
execute_response=execute_response,
10841084
thrift_client=self,
10851085
buffer_size_bytes=max_bytes,
10861086
arraysize=max_rows,
1087-
use_cloud_fetch=cursor.connection.use_cloud_fetch
1087+
use_cloud_fetch=cursor.connection.use_cloud_fetch,
10881088
)
10891089

10901090
def _handle_execute_response(self, resp, cursor):

src/databricks/sql/client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ def execute(
754754

755755
self._check_not_closed()
756756
self._close_and_clear_active_result_set()
757-
757+
758758
self.active_result_set = self.backend.execute_command(
759759
operation=prepared_operation,
760760
session_handle=self.connection.session._session_handle,
@@ -1124,5 +1124,3 @@ def setinputsizes(self, sizes):
11241124
def setoutputsize(self, size, column=None):
11251125
"""Does nothing by default"""
11261126
pass
1127-
1128-

src/databricks/sql/result_set.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
class ResultSet(ABC):
2222
"""
2323
Abstract base class for result sets returned by different backend implementations.
24-
24+
2525
This class defines the interface that all concrete result set implementations must follow.
2626
"""
27-
27+
2828
def __init__(self, connection, backend, arraysize: int, buffer_size_bytes: int):
2929
"""Initialize the base ResultSet with common properties."""
3030
self.connection = connection
@@ -33,50 +33,50 @@ def __init__(self, connection, backend, arraysize: int, buffer_size_bytes: int):
3333
self.buffer_size_bytes = buffer_size_bytes
3434
self._next_row_index = 0
3535
self.description = None
36-
36+
3737
def __iter__(self):
3838
while True:
3939
row = self.fetchone()
4040
if row:
4141
yield row
4242
else:
4343
break
44-
44+
4545
@property
4646
def rownumber(self):
4747
return self._next_row_index
48-
48+
4949
# Define abstract methods that concrete implementations must implement
5050
@abstractmethod
5151
def _fill_results_buffer(self):
5252
"""Fill the results buffer from the backend."""
5353
pass
54-
54+
5555
@abstractmethod
5656
def fetchone(self) -> Optional[Row]:
5757
"""Fetch the next row of a query result set."""
5858
pass
59-
59+
6060
@abstractmethod
6161
def fetchmany(self, size: int) -> List[Row]:
6262
"""Fetch the next set of rows of a query result."""
6363
pass
64-
64+
6565
@abstractmethod
6666
def fetchall(self) -> List[Row]:
6767
"""Fetch all remaining rows of a query result."""
6868
pass
69-
69+
7070
@abstractmethod
7171
def fetchmany_arrow(self, size: int) -> Any:
7272
"""Fetch the next set of rows as an Arrow table."""
7373
pass
74-
74+
7575
@abstractmethod
7676
def fetchall_arrow(self) -> Any:
7777
"""Fetch all remaining rows as an Arrow table."""
7878
pass
79-
79+
8080
@abstractmethod
8181
def close(self) -> None:
8282
"""Close the result set and release any resources."""
@@ -85,7 +85,7 @@ def close(self) -> None:
8585

8686
class ThriftResultSet(ResultSet):
8787
"""ResultSet implementation for the Thrift backend."""
88-
88+
8989
def __init__(
9090
self,
9191
connection,
@@ -97,7 +97,7 @@ def __init__(
9797
):
9898
"""
9999
Initialize a ThriftResultSet with direct access to the ThriftDatabricksClient.
100-
100+
101101
Args:
102102
connection: The parent connection
103103
execute_response: Response from the execute command
@@ -107,7 +107,7 @@ def __init__(
107107
use_cloud_fetch: Whether to use cloud fetch for retrieving results
108108
"""
109109
super().__init__(connection, thrift_client, arraysize, buffer_size_bytes)
110-
110+
111111
# Initialize ThriftResultSet-specific attributes
112112
self.command_id = execute_response.command_handle
113113
self.op_state = execute_response.status
@@ -124,7 +124,7 @@ def __init__(
124124
self.results = execute_response.arrow_queue
125125
else:
126126
self._fill_results_buffer()
127-
127+
128128
def _fill_results_buffer(self):
129129
"""Fill the results buffer using the ThriftDatabricksClient directly."""
130130
# Use the thrift_client (backend) directly to fetch results
@@ -140,7 +140,7 @@ def _fill_results_buffer(self):
140140
)
141141
self.results = results
142142
self.has_more_rows = has_more_rows
143-
143+
144144
def _convert_columnar_table(self, table):
145145
column_names = [c[0] for c in self.description]
146146
ResultRow = Row(*column_names)
@@ -352,4 +352,4 @@ def close(self) -> None:
352352
logger.info("Operation was canceled by a prior request")
353353
finally:
354354
self.has_been_closed_server_side = True
355-
self.op_state = ttypes.TOperationState.CLOSED_STATE
355+
self.op_state = ttypes.TOperationState.CLOSED_STATE

0 commit comments

Comments
 (0)