Skip to content

Commit a63ece8

Browse files
committed
Fixed merge conflicts
2 parents 3fc4e01 + f9d6ef1 commit a63ece8

File tree

6 files changed

+23
-9
lines changed

6 files changed

+23
-9
lines changed

CHANGELOG.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
# Release History
22

3-
4-
# 4.0.0
3+
# 4.0.0 (TBD)
54

65
- Split the connector into two separate packages: `databricks-sql-connector` and `databricks-sqlalchemy`. The `databricks-sql-connector` package contains the core functionality of the connector, while the `databricks-sqlalchemy` package contains the SQLAlchemy dialect for the connector.
76
- Pyarrow dependency is now optional in `databricks-sql-connector`. Users needing arrow are supposed to explicitly install pyarrow
87

8+
# 3.7.0 (2024-12-23)
9+
10+
- Fix: Incorrect number of rows fetched in inline results when fetching results with FETCH_NEXT orientation (databricks/databricks-sql-python#479 by @jprakash-db)
11+
- Updated the doc to specify native parameters are not supported in PUT operation (databricks/databricks-sql-python#477 by @jprakash-db)
12+
- Relax `pyarrow` and `numpy` pin (databricks/databricks-sql-python#452 by @arredond)
13+
- Feature: Support for async execute has been added (databricks/databricks-sql-python#463 by @jprakash-db)
14+
- Updated the HTTP retry logic to be similar to the other Databricks drivers (databricks/databricks-sql-python#467 by @jprakash-db)
15+
916
# 3.6.0 (2024-10-25)
1017

1118
- Support encryption headers in the cloud fetch request (https://github.com/databricks/databricks-sql-python/pull/460 by @jackyhu-db)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "databricks-sql-connector"
3-
version = "4.0.0.b4"
3+
version = "4.0.0"
44
description = "Databricks SQL Connector for Python"
55
authors = ["Databricks <[email protected]>"]
66
license = "Apache-2.0"

src/databricks/sql/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def __repr__(self):
6868
DATE = DBAPITypeObject("date")
6969
ROWID = DBAPITypeObject()
7070

71-
__version__ = "3.6.0"
71+
__version__ = "3.7.0"
7272
USER_AGENT_NAME = "PyDatabricksSqlConnector"
7373

7474
# These two functions are pyhive legacy

src/databricks/sql/client.py

+4
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,7 @@ def execute(
815815
self.thrift_backend,
816816
self.buffer_size_bytes,
817817
self.arraysize,
818+
self.connection.use_cloud_fetch,
818819
)
819820

820821
if execute_response.is_staging_operation:
@@ -1209,6 +1210,7 @@ def __init__(
12091210
thrift_backend: ThriftBackend,
12101211
result_buffer_size_bytes: int = DEFAULT_RESULT_BUFFER_SIZE_BYTES,
12111212
arraysize: int = 10000,
1213+
use_cloud_fetch: bool = True,
12121214
):
12131215
"""
12141216
A ResultSet manages the results of a single command.
@@ -1230,6 +1232,7 @@ def __init__(
12301232
self.description = execute_response.description
12311233
self._arrow_schema_bytes = execute_response.arrow_schema_bytes
12321234
self._next_row_index = 0
1235+
self._use_cloud_fetch = use_cloud_fetch
12331236

12341237
if execute_response.arrow_queue:
12351238
# In this case the server has taken the fast path and returned an initial batch of
@@ -1257,6 +1260,7 @@ def _fill_results_buffer(self):
12571260
lz4_compressed=self.lz4_compressed,
12581261
arrow_schema_bytes=self._arrow_schema_bytes,
12591262
description=self.description,
1263+
use_cloud_fetch=self._use_cloud_fetch,
12601264
)
12611265
self.results = results
12621266
self.has_more_rows = has_more_rows

src/databricks/sql/thrift_backend.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def _handle_request_error(self, error_info, attempt, elapsed):
321321

322322
# FUTURE: Consider moving to https://github.com/litl/backoff or
323323
# https://github.com/jd/tenacity for retry logic.
324-
def make_request(self, method, request):
324+
def make_request(self, method, request, retryable=True):
325325
"""Execute given request, attempting retries when
326326
1. Receiving HTTP 429/503 from server
327327
2. OSError is raised during a GetOperationStatus
@@ -460,7 +460,7 @@ def attempt_request(attempt):
460460
# return on success
461461
# if available: bounded delay and retry
462462
# if not: raise error
463-
max_attempts = self._retry_stop_after_attempts_count
463+
max_attempts = self._retry_stop_after_attempts_count if retryable else 1
464464

465465
# use index-1 counting for logging/human consistency
466466
for attempt in range(1, max_attempts + 1):
@@ -1028,6 +1028,7 @@ def fetch_results(
10281028
lz4_compressed,
10291029
arrow_schema_bytes,
10301030
description,
1031+
use_cloud_fetch=True,
10311032
):
10321033
assert op_handle is not None
10331034

@@ -1044,10 +1045,11 @@ def fetch_results(
10441045
includeResultSetMetadata=True,
10451046
)
10461047

1047-
resp = self.make_request(self._client.FetchResults, req)
1048+
# Fetch results in Inline mode with FETCH_NEXT orientation are not idempotent and hence not retried
1049+
resp = self.make_request(self._client.FetchResults, req, use_cloud_fetch)
10481050
if resp.results.startRowOffset > expected_row_start_offset:
1049-
logger.warning(
1050-
"Expected results to start from {} but they instead start at {}".format(
1051+
raise DataError(
1052+
"fetch_results failed due to inconsistency in the state between the client and the server. Expected results to start from {} but they instead start at {}, some result batches must have been skipped".format(
10511053
expected_row_start_offset, resp.results.startRowOffset
10521054
)
10531055
)

tests/unit/test_fetches.py

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def fetch_results(
7070
lz4_compressed,
7171
arrow_schema_bytes,
7272
description,
73+
use_cloud_fetch=True,
7374
):
7475
nonlocal batch_index
7576
results = FetchTests.make_arrow_queue(batch_list[batch_index])

0 commit comments

Comments
 (0)