Skip to content

Commit 89425f9

Browse files
formatting (black)
Signed-off-by: varun-edachali-dbx <[email protected]>
1 parent 6654f06 commit 89425f9

File tree

3 files changed

+52
-49
lines changed

3 files changed

+52
-49
lines changed

src/databricks/sql/backend/databricks_client.py

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ def open_session(
3333
) -> SessionId:
3434
"""
3535
Opens a new session with the Databricks SQL service.
36-
36+
3737
This method establishes a new session with the server and returns a session
3838
identifier that can be used for subsequent operations.
39-
39+
4040
Args:
4141
session_configuration: Optional dictionary of configuration parameters for the session
4242
catalog: Optional catalog name to use as the initial catalog for the session
4343
schema: Optional schema name to use as the initial schema for the session
44-
44+
4545
Returns:
4646
SessionId: A session identifier object that can be used for subsequent operations
47-
47+
4848
Raises:
4949
Error: If the session configuration is invalid
5050
OperationalError: If there's an error establishing the session
@@ -56,13 +56,13 @@ def open_session(
5656
def close_session(self, session_id: SessionId) -> None:
5757
"""
5858
Closes an existing session with the Databricks SQL service.
59-
59+
6060
This method terminates the session identified by the given session ID and
6161
releases any resources associated with it.
62-
62+
6363
Args:
6464
session_id: The session identifier returned by open_session()
65-
65+
6666
Raises:
6767
ValueError: If the session ID is invalid
6868
OperationalError: If there's an error closing the session
@@ -86,10 +86,10 @@ def execute_command(
8686
) -> Any:
8787
"""
8888
Executes a SQL command or query within the specified session.
89-
89+
9090
This method sends a SQL command to the server for execution and handles
9191
the response. It can operate in both synchronous and asynchronous modes.
92-
92+
9393
Args:
9494
operation: The SQL command or query to execute
9595
session_id: The session identifier in which to execute the command
@@ -101,12 +101,12 @@ def execute_command(
101101
parameters: List of parameters to bind to the query
102102
async_op: Whether to execute the command asynchronously
103103
enforce_embedded_schema_correctness: Whether to enforce schema correctness
104-
104+
105105
Returns:
106106
If async_op is False, returns an ExecuteResponse object containing the
107107
query results and metadata. If async_op is True, returns None and the
108108
results must be fetched later using get_execution_result().
109-
109+
110110
Raises:
111111
ValueError: If the session ID is invalid
112112
OperationalError: If there's an error executing the command
@@ -118,13 +118,13 @@ def execute_command(
118118
def cancel_command(self, command_id: CommandId) -> None:
119119
"""
120120
Cancels a running command or query.
121-
121+
122122
This method attempts to cancel a command that is currently being executed.
123123
It can be called from a different thread than the one executing the command.
124-
124+
125125
Args:
126126
command_id: The command identifier to cancel
127-
127+
128128
Raises:
129129
ValueError: If the command ID is invalid
130130
OperationalError: If there's an error canceling the command
@@ -135,16 +135,16 @@ def cancel_command(self, command_id: CommandId) -> None:
135135
def close_command(self, command_id: CommandId) -> ttypes.TStatus:
136136
"""
137137
Closes a command and releases associated resources.
138-
138+
139139
This method informs the server that the client is done with the command
140140
and any resources associated with it can be released.
141-
141+
142142
Args:
143143
command_id: The command identifier to close
144-
144+
145145
Returns:
146146
ttypes.TStatus: The status of the close operation
147-
147+
148148
Raises:
149149
ValueError: If the command ID is invalid
150150
OperationalError: If there's an error closing the command
@@ -155,15 +155,15 @@ def close_command(self, command_id: CommandId) -> ttypes.TStatus:
155155
def get_query_state(self, command_id: CommandId) -> ttypes.TOperationState:
156156
"""
157157
Gets the current state of a query or command.
158-
158+
159159
This method retrieves the current execution state of a command from the server.
160-
160+
161161
Args:
162162
command_id: The command identifier to check
163-
163+
164164
Returns:
165165
ttypes.TOperationState: The current state of the command
166-
166+
167167
Raises:
168168
ValueError: If the command ID is invalid
169169
OperationalError: If there's an error retrieving the state
@@ -180,17 +180,17 @@ def get_execution_result(
180180
) -> ExecuteResponse:
181181
"""
182182
Retrieves the results of a previously executed command.
183-
183+
184184
This method fetches the results of a command that was executed asynchronously
185185
or retrieves additional results from a command that has more rows available.
186-
186+
187187
Args:
188188
command_id: The command identifier for which to retrieve results
189189
cursor: The cursor object that will handle the results
190-
190+
191191
Returns:
192192
ExecuteResponse: An object containing the query results and metadata
193-
193+
194194
Raises:
195195
ValueError: If the command ID is invalid
196196
OperationalError: If there's an error retrieving the results
@@ -208,19 +208,19 @@ def get_catalogs(
208208
) -> ExecuteResponse:
209209
"""
210210
Retrieves a list of available catalogs.
211-
211+
212212
This method fetches metadata about all catalogs available in the current
213213
session's context.
214-
214+
215215
Args:
216216
session_id: The session identifier
217217
max_rows: Maximum number of rows to fetch in a single batch
218218
max_bytes: Maximum number of bytes to fetch in a single batch
219219
cursor: The cursor object that will handle the results
220-
220+
221221
Returns:
222222
ExecuteResponse: An object containing the catalog metadata
223-
223+
224224
Raises:
225225
ValueError: If the session ID is invalid
226226
OperationalError: If there's an error retrieving the catalogs
@@ -239,21 +239,21 @@ def get_schemas(
239239
) -> ExecuteResponse:
240240
"""
241241
Retrieves a list of schemas, optionally filtered by catalog and schema name patterns.
242-
242+
243243
This method fetches metadata about schemas available in the specified catalog
244244
or all catalogs if no catalog is specified.
245-
245+
246246
Args:
247247
session_id: The session identifier
248248
max_rows: Maximum number of rows to fetch in a single batch
249249
max_bytes: Maximum number of bytes to fetch in a single batch
250250
cursor: The cursor object that will handle the results
251251
catalog_name: Optional catalog name pattern to filter by
252252
schema_name: Optional schema name pattern to filter by
253-
253+
254254
Returns:
255255
ExecuteResponse: An object containing the schema metadata
256-
256+
257257
Raises:
258258
ValueError: If the session ID is invalid
259259
OperationalError: If there's an error retrieving the schemas
@@ -274,10 +274,10 @@ def get_tables(
274274
) -> ExecuteResponse:
275275
"""
276276
Retrieves a list of tables, optionally filtered by catalog, schema, table name, and table types.
277-
277+
278278
This method fetches metadata about tables available in the specified catalog
279279
and schema, or all catalogs and schemas if not specified.
280-
280+
281281
Args:
282282
session_id: The session identifier
283283
max_rows: Maximum number of rows to fetch in a single batch
@@ -287,10 +287,10 @@ def get_tables(
287287
schema_name: Optional schema name pattern to filter by
288288
table_name: Optional table name pattern to filter by
289289
table_types: Optional list of table types to filter by (e.g., ['TABLE', 'VIEW'])
290-
290+
291291
Returns:
292292
ExecuteResponse: An object containing the table metadata
293-
293+
294294
Raises:
295295
ValueError: If the session ID is invalid
296296
OperationalError: If there's an error retrieving the tables
@@ -311,10 +311,10 @@ def get_columns(
311311
) -> ExecuteResponse:
312312
"""
313313
Retrieves a list of columns, optionally filtered by catalog, schema, table, and column name patterns.
314-
314+
315315
This method fetches metadata about columns available in the specified table,
316316
or all tables if not specified.
317-
317+
318318
Args:
319319
session_id: The session identifier
320320
max_rows: Maximum number of rows to fetch in a single batch
@@ -324,10 +324,10 @@ def get_columns(
324324
schema_name: Optional schema name pattern to filter by
325325
table_name: Optional table name pattern to filter by
326326
column_name: Optional column name pattern to filter by
327-
327+
328328
Returns:
329329
ExecuteResponse: An object containing the column metadata
330-
330+
331331
Raises:
332332
ValueError: If the session ID is invalid
333333
OperationalError: If there's an error retrieving the columns
@@ -340,7 +340,7 @@ def get_columns(
340340
def staging_allowed_local_path(self) -> Union[None, str, List[str]]:
341341
"""
342342
Gets the allowed local paths for staging operations.
343-
343+
344344
Returns:
345345
Union[None, str, List[str]]: The allowed local paths for staging operations,
346346
or None if staging is not allowed
@@ -352,7 +352,7 @@ def staging_allowed_local_path(self) -> Union[None, str, List[str]]:
352352
def ssl_options(self) -> SSLOptions:
353353
"""
354354
Gets the SSL options for this client.
355-
355+
356356
Returns:
357357
SSLOptions: The SSL configuration options
358358
"""
@@ -363,8 +363,8 @@ def ssl_options(self) -> SSLOptions:
363363
def max_download_threads(self) -> int:
364364
"""
365365
Gets the maximum number of download threads for cloud fetch operations.
366-
366+
367367
Returns:
368368
int: The maximum number of download threads
369369
"""
370-
pass
370+
pass

src/databricks/sql/backend/thrift_backend.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,9 @@ def _results_message_to_execute_response(self, resp, operation_state):
816816
arrow_schema_bytes=schema_bytes,
817817
)
818818

819-
def get_execution_result(self, command_id: CommandId, cursor: "Cursor") -> ExecuteResponse:
819+
def get_execution_result(
820+
self, command_id: CommandId, cursor: "Cursor"
821+
) -> ExecuteResponse:
820822
thrift_handle = command_id.to_thrift_handle()
821823
if not thrift_handle:
822824
raise ValueError("Not a valid Thrift command ID")
@@ -1170,4 +1172,3 @@ def close_command(self, command_id: CommandId):
11701172
req = ttypes.TCloseOperationReq(operationHandle=thrift_handle)
11711173
resp = self.make_request(self._client.CloseOperation, req)
11721174
return resp.status
1173-

src/databricks/sql/backend/types.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ def __str__(self) -> str:
7676
return str(self.guid)
7777

7878
@classmethod
79-
def from_thrift_handle(cls, session_handle, properties: Optional[Dict[str, Any]] = None):
79+
def from_thrift_handle(
80+
cls, session_handle, properties: Optional[Dict[str, Any]] = None
81+
):
8082
"""
8183
Create a SessionId from a Thrift session handle.
8284

0 commit comments

Comments
 (0)