@@ -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
@@ -374,20 +374,9 @@ def attempt_request(attempt):
374374
375375 # These three lines are no-ops if the v3 retry policy is not in use
376376 if self .enable_v3_retries :
377- # Not to retry when FetchResults in INLINE mode when it has orientation as FETCH_NEXT as it is not idempotent
378- if (
379- this_method_name == "FetchResults"
380- and self ._use_cloud_fetch == False
381- ):
382- this_method_name += (
383- "Inline_"
384- + ttypes .TFetchOrientation ._VALUES_TO_NAMES [
385- request .orientation
386- ]
387- )
388-
389377 this_command_type = CommandType .get (this_method_name )
390378 self ._transport .set_retry_command_type (this_command_type )
379+ self ._transport .set_is_retryable (retryable )
391380 self ._transport .startRetryTimer ()
392381
393382 response = method (request )
@@ -898,8 +887,6 @@ def execute_command(
898887 ):
899888 assert session_handle is not None
900889
901- self ._use_cloud_fetch = use_cloud_fetch
902-
903890 spark_arrow_types = ttypes .TSparkArrowTypes (
904891 timestampAsArrow = self ._use_arrow_native_timestamps ,
905892 decimalAsArrow = self ._use_arrow_native_decimals ,
@@ -1042,6 +1029,7 @@ def fetch_results(
10421029 lz4_compressed ,
10431030 arrow_schema_bytes ,
10441031 description ,
1032+ use_cloud_fetch = True ,
10451033 ):
10461034 assert op_handle is not None
10471035
@@ -1058,7 +1046,8 @@ def fetch_results(
10581046 includeResultSetMetadata = True ,
10591047 )
10601048
1061- resp = self .make_request (self ._client .FetchResults , req )
1049+ # Fetch results in Inline mode with FETCH_NEXT orientation are not idempotent and hence not retried
1050+ resp = self .make_request (self ._client .FetchResults , req , use_cloud_fetch )
10621051 if resp .results .startRowOffset > expected_row_start_offset :
10631052 raise DataError (
10641053 "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 (
0 commit comments