Skip to content

Commit b2202c7

Browse files
committed
Updated the non retying to only inline case
1 parent bf26881 commit b2202c7

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/databricks/sql/auth/retry.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class CommandType(Enum):
3232
CLOSE_SESSION = "CloseSession"
3333
CLOSE_OPERATION = "CloseOperation"
3434
GET_OPERATION_STATUS = "GetOperationStatus"
35-
FETCH_RESULTS_ORIENTATION_FETCH_NEXT = "FetchResultsOrientation_FETCH_NEXT"
35+
FETCH_RESULTS_INLINE_FETCH_NEXT = "FetchResultsInline_FETCH_NEXT"
3636
OTHER = "Other"
3737

3838
@classmethod
@@ -363,10 +363,10 @@ def should_retry(self, method: str, status_code: int) -> Tuple[bool, str]:
363363
if status_code == 501:
364364
raise NonRecoverableNetworkError("Received code 501 from server.")
365365

366-
if self.command_type == CommandType.FETCH_RESULTS_ORIENTATION_FETCH_NEXT:
366+
if self.command_type == CommandType.FETCH_RESULTS_INLINE_FETCH_NEXT:
367367
return (
368368
False,
369-
"FetchResults with FETCH_NEXT orientation are not idempotent in inline mode and is not retried",
369+
"FetchResults in INLINE mode with FETCH_NEXT orientation are not idempotent and is not retried",
370370
)
371371

372372
# Request failed and this method is not retryable. We only retry POST requests.

src/databricks/sql/thrift_backend.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ def __init__(
156156
)
157157

158158
# Cloud fetch
159+
self._use_cloud_fetch = kwargs.get("use_cloud_fetch", True)
160+
159161
self.max_download_threads = kwargs.get("max_download_threads", 10)
160162

161163
self._ssl_options = ssl_options
@@ -374,10 +376,13 @@ def attempt_request(attempt):
374376

375377
# These three lines are no-ops if the v3 retry policy is not in use
376378
if self.enable_v3_retries:
377-
# Not to retry when FetchResults has orientation as FETCH_NEXT as it is not idempotent
378-
if this_method_name == "FetchResults":
379+
# Not to retry when FetchResults in INLINE mode when it has orientation as FETCH_NEXT as it is not idempotent
380+
if (
381+
this_method_name == "FetchResults"
382+
and self._use_cloud_fetch == False
383+
):
379384
this_method_name += (
380-
"Orientation_"
385+
"Inline_"
381386
+ ttypes.TFetchOrientation._VALUES_TO_NAMES[
382387
request.orientation
383388
]

tests/unit/test_retry.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,6 @@ def test_sleep__retry_after_present(self, t_mock, retry_policy, error_history):
8787

8888
def test_not_retryable__fetch_results_orientation_fetch_next(self, retry_policy):
8989
HTTP_STATUS_CODES = [200, 429, 503, 504]
90-
retry_policy.command_type = CommandType.FETCH_RESULTS_ORIENTATION_FETCH_NEXT
90+
retry_policy.command_type = CommandType.FETCH_RESULTS_INLINE_FETCH_NEXT
9191
for status_code in HTTP_STATUS_CODES:
9292
assert not retry_policy.is_retry("METHOD_NAME", status_code=status_code)

0 commit comments

Comments
 (0)