Skip to content

Commit 4debbd3

Browse files
formatting: black + re-organise backend into new dir
Signed-off-by: varun-edachali-dbx <[email protected]>
1 parent 788d8c7 commit 4debbd3

File tree

7 files changed

+26
-18
lines changed

7 files changed

+26
-18
lines changed

src/databricks/sql/db_client_interface.py renamed to src/databricks/sql/backend/databricks_client.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,15 @@ def cancel_command(self, operation_handle: ttypes.TOperationHandle) -> None:
4343
pass
4444

4545
@abstractmethod
46-
def close_command(self, operation_handle: ttypes.TOperationHandle) -> ttypes.TStatus:
46+
def close_command(
47+
self, operation_handle: ttypes.TOperationHandle
48+
) -> ttypes.TStatus:
4749
pass
4850

4951
@abstractmethod
50-
def get_query_state(self, operation_handle: ttypes.TOperationHandle) -> ttypes.TOperationState:
52+
def get_query_state(
53+
self, operation_handle: ttypes.TOperationHandle
54+
) -> ttypes.TOperationState:
5155
pass
5256

5357
@abstractmethod
@@ -132,4 +136,4 @@ def ssl_options(self) -> SSLOptions:
132136
@property
133137
@abstractmethod
134138
def max_download_threads(self) -> int:
135-
pass
139+
pass

src/databricks/sql/thrift_backend.py renamed to src/databricks/sql/backend/thrift_backend.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
convert_column_based_set_to_arrow_table,
4242
)
4343
from databricks.sql.types import SSLOptions
44-
from databricks.sql.db_client_interface import DatabricksClient
44+
from databricks.sql.backend.databricks_client import DatabricksClient
4545

4646
logger = logging.getLogger(__name__)
4747

@@ -221,11 +221,11 @@ def __init__(
221221
@property
222222
def staging_allowed_local_path(self) -> Union[None, str, List[str]]:
223223
return self._staging_allowed_local_path
224-
224+
225225
@property
226226
def ssl_options(self) -> SSLOptions:
227227
return self._ssl_options
228-
228+
229229
@property
230230
def max_download_threads(self) -> int:
231231
return self._max_download_threads
@@ -449,8 +449,10 @@ def attempt_request(attempt):
449449
except Exception as err:
450450
error = err
451451
retry_delay = extract_retry_delay(attempt)
452-
error_message = ThriftDatabricksClient._extract_error_message_from_headers(
453-
getattr(self._transport, "headers", {})
452+
error_message = (
453+
ThriftDatabricksClient._extract_error_message_from_headers(
454+
getattr(self._transport, "headers", {})
455+
)
454456
)
455457
finally:
456458
# Calling `close()` here releases the active HTTP connection back to the pool
@@ -710,7 +712,8 @@ def _col_to_description(col):
710712
@staticmethod
711713
def _hive_schema_to_description(t_table_schema):
712714
return [
713-
ThriftDatabricksClient._col_to_description(col) for col in t_table_schema.columns
715+
ThriftDatabricksClient._col_to_description(col)
716+
for col in t_table_schema.columns
714717
]
715718

716719
def _results_message_to_execute_response(self, resp, operation_state):

src/databricks/sql/client.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
CursorAlreadyClosedError,
2222
)
2323
from databricks.sql.thrift_api.TCLIService import ttypes
24-
from databricks.sql.thrift_backend import ThriftDatabricksClient
25-
from databricks.sql.db_client_interface import DatabricksClient
24+
from databricks.sql.backend.thrift_backend import ThriftDatabricksClient
25+
from databricks.sql.backend.databricks_client import DatabricksClient
2626
from databricks.sql.utils import (
2727
ExecuteResponse,
2828
ParamEscaper,
@@ -1230,7 +1230,7 @@ def _fill_results_buffer(self):
12301230
)
12311231

12321232
# Now we know self.backend is ThriftDatabricksClient, so it has fetch_results
1233-
thrift_backend_instance = self.backend # type: ThriftDatabricksClient
1233+
thrift_backend_instance = self.backend # type: ThriftDatabricksClient
12341234
results, has_more_rows = thrift_backend_instance.fetch_results(
12351235
op_handle=self.command_id,
12361236
max_rows=self.arraysize,
@@ -1447,7 +1447,8 @@ def close(self) -> None:
14471447
If the connection has not been closed, and the cursor has not already
14481448
been closed on the server for some other reason, issue a request to the server to close it.
14491449
"""
1450-
# TODO: the state is still thrift specific, define some ENUM for status that each service has to map to
1450+
# TODO: the state is still thrift specific, define some ENUM for status that each service has to map to
1451+
# when we generalise the ResultSet
14511452
try:
14521453
if (
14531454
self.op_state != ttypes.TOperationState.CLOSED_STATE

src/databricks/sql/session.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from databricks.sql.exc import SessionAlreadyClosedError, DatabaseError, RequestError
88
from databricks.sql import __version__
99
from databricks.sql import USER_AGENT_NAME
10-
from databricks.sql.thrift_backend import ThriftDatabricksClient
11-
from databricks.sql.db_client_interface import DatabricksClient
10+
from databricks.sql.backend.thrift_backend import ThriftDatabricksClient
11+
from databricks.sql.backend.databricks_client import DatabricksClient
1212

1313
logger = logging.getLogger(__name__)
1414

tests/unit/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
THandleIdentifier,
1616
TOperationType,
1717
)
18-
from databricks.sql.thrift_backend import ThriftDatabricksClient
18+
from databricks.sql.backend.thrift_backend import ThriftDatabricksClient
1919

2020
import databricks.sql
2121
import databricks.sql.client as client

tests/unit/test_fetches.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import databricks.sql.client as client
1111
from databricks.sql.utils import ExecuteResponse, ArrowQueue
12-
from databricks.sql.thrift_backend import ThriftDatabricksClient
12+
from databricks.sql.backend.thrift_backend import ThriftDatabricksClient
1313

1414

1515
@pytest.mark.skipif(pa is None, reason="PyArrow is not installed")

tests/unit/test_thrift_backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from databricks.sql.thrift_api.TCLIService import ttypes
1818
from databricks.sql import *
1919
from databricks.sql.auth.authenticators import AuthProvider
20-
from databricks.sql.thrift_backend import ThriftDatabricksClient
20+
from databricks.sql.backend.thrift_backend import ThriftDatabricksClient
2121

2222

2323
def retry_policy_factory():

0 commit comments

Comments
 (0)