Skip to content

Commit 8257529

Browse files
remove excess changes
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent 0fc79ec commit 8257529

File tree

4 files changed

+167
-25
lines changed

4 files changed

+167
-25
lines changed

.github/workflows/code-quality-checks.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
name: Code Quality Checks
2-
on:
3-
push:
4-
branches:
5-
- main
6-
- sea-migration
7-
- telemetry
8-
pull_request:
9-
branches:
10-
- main
11-
- sea-migration
12-
- telemetry
2+
3+
on: [pull_request]
4+
135
jobs:
146
run-unit-tests:
157
runs-on: ubuntu-latest

.github/workflows/integration.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
name: Integration Tests
2+
23
on:
3-
push:
4-
paths-ignore:
5-
- "**.MD"
6-
- "**.md"
7-
pull_request:
4+
push:
85
branches:
96
- main
10-
- sea-migration
11-
- telemetry
7+
pull_request:
128

139
jobs:
1410
run-e2e-tests:

src/databricks/sql/backend/databricks_client.py

Lines changed: 139 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@
1515
from databricks.sql.client import Cursor
1616

1717
from databricks.sql.thrift_api.TCLIService import ttypes
18-
from databricks.sql.backend.types import (
19-
SessionId,
20-
CommandId,
21-
CommandState,
22-
ExecuteResponse,
23-
)
24-
from databricks.sql.types import SSLOptions
18+
from databricks.sql.backend.types import SessionId, CommandId, CommandState
2519

2620
# Forward reference for type hints
2721
from typing import TYPE_CHECKING
@@ -92,6 +86,34 @@ def execute_command(
9286
async_op: bool,
9387
enforce_embedded_schema_correctness: bool,
9488
) -> Union["ResultSet", None]:
89+
"""
90+
Executes a SQL command or query within the specified session.
91+
92+
This method sends a SQL command to the server for execution and handles
93+
the response. It can operate in both synchronous and asynchronous modes.
94+
95+
Args:
96+
operation: The SQL command or query to execute
97+
session_id: The session identifier in which to execute the command
98+
max_rows: Maximum number of rows to fetch in a single fetch batch
99+
max_bytes: Maximum number of bytes to fetch in a single fetch batch
100+
lz4_compression: Whether to use LZ4 compression for result data
101+
cursor: The cursor object that will handle the results
102+
use_cloud_fetch: Whether to use cloud fetch for retrieving large result sets
103+
parameters: List of parameters to bind to the query
104+
async_op: Whether to execute the command asynchronously
105+
enforce_embedded_schema_correctness: Whether to enforce schema correctness
106+
107+
Returns:
108+
If async_op is False, returns a ResultSet object containing the
109+
query results and metadata. If async_op is True, returns None and the
110+
results must be fetched later using get_execution_result().
111+
112+
Raises:
113+
ValueError: If the session ID is invalid
114+
OperationalError: If there's an error executing the command
115+
ServerOperationError: If the server encounters an error during execution
116+
"""
95117
pass
96118

97119
@abstractmethod
@@ -113,10 +135,40 @@ def cancel_command(self, command_id: CommandId) -> None:
113135

114136
@abstractmethod
115137
def close_command(self, command_id: CommandId) -> None:
138+
"""
139+
Closes a command and releases associated resources.
140+
141+
This method informs the server that the client is done with the command
142+
and any resources associated with it can be released.
143+
144+
Args:
145+
command_id: The command identifier to close
146+
147+
Raises:
148+
ValueError: If the command ID is invalid
149+
OperationalError: If there's an error closing the command
150+
"""
116151
pass
117152

118153
@abstractmethod
119154
def get_query_state(self, command_id: CommandId) -> CommandState:
155+
"""
156+
Gets the current state of a query or command.
157+
158+
This method retrieves the current execution state of a command from the server.
159+
160+
Args:
161+
command_id: The command identifier to check
162+
163+
Returns:
164+
CommandState: The current state of the command
165+
166+
Raises:
167+
ValueError: If the command ID is invalid
168+
OperationalError: If there's an error retrieving the state
169+
ServerOperationError: If the command is in an error state
170+
DatabaseError: If the command has been closed unexpectedly
171+
"""
120172
pass
121173

122174
@abstractmethod
@@ -125,6 +177,23 @@ def get_execution_result(
125177
command_id: CommandId,
126178
cursor: "Cursor",
127179
) -> "ResultSet":
180+
"""
181+
Retrieves the results of a previously executed command.
182+
183+
This method fetches the results of a command that was executed asynchronously
184+
or retrieves additional results from a command that has more rows available.
185+
186+
Args:
187+
command_id: The command identifier for which to retrieve results
188+
cursor: The cursor object that will handle the results
189+
190+
Returns:
191+
ResultSet: An object containing the query results and metadata
192+
193+
Raises:
194+
ValueError: If the command ID is invalid
195+
OperationalError: If there's an error retrieving the results
196+
"""
128197
pass
129198

130199
# == Metadata Operations ==
@@ -136,6 +205,25 @@ def get_catalogs(
136205
max_bytes: int,
137206
cursor: "Cursor",
138207
) -> "ResultSet":
208+
"""
209+
Retrieves a list of available catalogs.
210+
211+
This method fetches metadata about all catalogs available in the current
212+
session's context.
213+
214+
Args:
215+
session_id: The session identifier
216+
max_rows: Maximum number of rows to fetch in a single batch
217+
max_bytes: Maximum number of bytes to fetch in a single batch
218+
cursor: The cursor object that will handle the results
219+
220+
Returns:
221+
ResultSet: An object containing the catalog metadata
222+
223+
Raises:
224+
ValueError: If the session ID is invalid
225+
OperationalError: If there's an error retrieving the catalogs
226+
"""
139227
pass
140228

141229
@abstractmethod
@@ -148,6 +236,27 @@ def get_schemas(
148236
catalog_name: Optional[str] = None,
149237
schema_name: Optional[str] = None,
150238
) -> "ResultSet":
239+
"""
240+
Retrieves a list of schemas, optionally filtered by catalog and schema name patterns.
241+
242+
This method fetches metadata about schemas available in the specified catalog
243+
or all catalogs if no catalog is specified.
244+
245+
Args:
246+
session_id: The session identifier
247+
max_rows: Maximum number of rows to fetch in a single batch
248+
max_bytes: Maximum number of bytes to fetch in a single batch
249+
cursor: The cursor object that will handle the results
250+
catalog_name: Optional catalog name pattern to filter by
251+
schema_name: Optional schema name pattern to filter by
252+
253+
Returns:
254+
ResultSet: An object containing the schema metadata
255+
256+
Raises:
257+
ValueError: If the session ID is invalid
258+
OperationalError: If there's an error retrieving the schemas
259+
"""
151260
pass
152261

153262
@abstractmethod
@@ -162,6 +271,29 @@ def get_tables(
162271
table_name: Optional[str] = None,
163272
table_types: Optional[List[str]] = None,
164273
) -> "ResultSet":
274+
"""
275+
Retrieves a list of tables, optionally filtered by catalog, schema, table name, and table types.
276+
277+
This method fetches metadata about tables available in the specified catalog
278+
and schema, or all catalogs and schemas if not specified.
279+
280+
Args:
281+
session_id: The session identifier
282+
max_rows: Maximum number of rows to fetch in a single batch
283+
max_bytes: Maximum number of bytes to fetch in a single batch
284+
cursor: The cursor object that will handle the results
285+
catalog_name: Optional catalog name pattern to filter by
286+
schema_name: Optional schema name pattern to filter by
287+
table_name: Optional table name pattern to filter by
288+
table_types: Optional list of table types to filter by (e.g., ['TABLE', 'VIEW'])
289+
290+
Returns:
291+
ResultSet: An object containing the table metadata
292+
293+
Raises:
294+
ValueError: If the session ID is invalid
295+
OperationalError: If there's an error retrieving the tables
296+
"""
165297
pass
166298

167299
@abstractmethod

src/databricks/sql/backend/types.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,28 @@ def __init__(
306306
self.has_result_set = has_result_set
307307
self.modified_row_count = modified_row_count
308308

309+
def __str__(self) -> str:
310+
"""
311+
Return a string representation of the CommandId.
312+
313+
For SEA backend, returns the guid.
314+
For Thrift backend, returns a format like "guid|secret".
315+
316+
Returns:
317+
A string representation of the command ID
318+
"""
319+
320+
if self.backend_type == BackendType.SEA:
321+
return str(self.guid)
322+
elif self.backend_type == BackendType.THRIFT:
323+
secret_hex = (
324+
guid_to_hex_id(self.secret)
325+
if isinstance(self.secret, bytes)
326+
else str(self.secret)
327+
)
328+
return f"{self.to_hex_guid()}|{secret_hex}"
329+
return str(self.guid)
330+
309331
@classmethod
310332
def from_thrift_handle(cls, operation_handle):
311333
"""

0 commit comments

Comments
 (0)