@@ -224,6 +224,7 @@ def unload_to_files(
224224 aws_session_token : Optional [str ] = None ,
225225 region : Optional [str ] = None ,
226226 unload_format : Optional [Literal ["CSV" , "PARQUET" ]] = None ,
227+ parallel : bool = True ,
227228 max_file_size : Optional [float ] = None ,
228229 kms_key_id : Optional [str ] = None ,
229230 manifest : bool = False ,
@@ -265,6 +266,11 @@ def unload_to_files(
265266 unload_format: str, optional
266267 Format of the unloaded S3 objects from the query.
267268 Valid values: "CSV", "PARQUET". Case sensitive. Defaults to PARQUET.
269+ parallel: bool
270+ Whether to unload to multiple files in parallel. Defaults to True.
271+ By default, UNLOAD writes data in parallel to multiple files, according to the number of
272+ slices in the cluster. If parallel is False, UNLOAD writes to one or more data files serially,
273+ sorted absolutely according to the ORDER BY clause, if one is used.
268274 max_file_size : float, optional
269275 Specifies the maximum size (MB) of files that UNLOAD creates in Amazon S3.
270276 Specify a decimal value between 5.0 MB and 6200.0 MB. If None, the default
@@ -305,6 +311,7 @@ def unload_to_files(
305311 partition_str : str = f"\n PARTITION BY ({ ',' .join (partition_cols )} )" if partition_cols else ""
306312 manifest_str : str = "\n manifest" if manifest is True else ""
307313 region_str : str = f"\n REGION AS '{ region } '" if region is not None else ""
314+ parallel_str : str = "\n PARALLEL ON" if parallel else "\n PARALLEL OFF"
308315 if not max_file_size and engine .get () == EngineEnum .RAY :
309316 _logger .warning (
310317 "Unload `MAXFILESIZE` is not specified. "
@@ -330,7 +337,7 @@ def unload_to_files(
330337 f"TO '{ path } '\n "
331338 f"{ auth_str } "
332339 "ALLOWOVERWRITE\n "
333- "PARALLEL ON \n "
340+ f" { parallel_str } \n "
334341 f"FORMAT { format_str } \n "
335342 "ENCRYPTED"
336343 f"{ kms_key_id_str } "
@@ -362,6 +369,7 @@ def unload(
362369 dtype_backend : Literal ["numpy_nullable" , "pyarrow" ] = "numpy_nullable" ,
363370 chunked : Union [bool , int ] = False ,
364371 keep_files : bool = False ,
372+ parallel : bool = True ,
365373 use_threads : Union [bool , int ] = True ,
366374 boto3_session : Optional [boto3 .Session ] = None ,
367375 s3_additional_kwargs : Optional [Dict [str , str ]] = None ,
@@ -433,6 +441,11 @@ def unload(
433441 used to encrypt data files on Amazon S3.
434442 keep_files : bool
435443 Should keep stage files?
444+ parallel: bool
445+ Whether to unload to multiple files in parallel. Defaults to True.
446+ By default, UNLOAD writes data in parallel to multiple files, according to the number of
447+ slices in the cluster. If parallel is False, UNLOAD writes to one or more data files serially,
448+ sorted absolutely according to the ORDER BY clause, if one is used.
436449 dtype_backend: str, optional
437450 Which dtype_backend to use, e.g. whether a DataFrame should have NumPy arrays,
438451 nullable dtypes are used for all dtypes that have a nullable implementation when
@@ -487,6 +500,7 @@ def unload(
487500 max_file_size = max_file_size ,
488501 kms_key_id = kms_key_id ,
489502 manifest = False ,
503+ parallel = parallel ,
490504 boto3_session = boto3_session ,
491505 )
492506 if chunked is False :
0 commit comments