Repository navigation
Use new efficient partitioned parquet writing in cuDF - #9971
Conversation
…en a previour write(table) call failed
Exception raised by writer needs to be same as that raised by pandas. If user_data is constructed earlier using pyarrow then the exception is raised early and is different
This reverts commit d0de9a9.
|
Do we have any benchmarks for this? |
vuule
left a comment
There was a problem hiding this comment.
C++ looks good :)
Super curious about the perf gain from this change!
| paths_or_bufs = [ | ||
| ioutils.get_writer_filepath_or_buffer(path, mode="wb", **kwargs) | ||
| for path in paths | ||
| ] | ||
| common_args = { | ||
| "index": index, | ||
| "compression": compression, | ||
| "statistics": statistics, | ||
| "metadata_file_path": metadata_file_path, | ||
| "int96_timestamps": int96_timestamps, | ||
| "row_group_size_bytes": row_group_size_bytes, | ||
| "row_group_size_rows": row_group_size_rows, | ||
| "partitions_info": partitions_info, | ||
| } | ||
| if all([ioutils.is_fsspec_open_file(buf) for buf in paths_or_bufs]): | ||
| with ExitStack() as stack: | ||
| fsspec_objs = [stack.enter_context(file) for file in paths_or_bufs] | ||
| file_objs = [ | ||
| ioutils.get_IOBase_writer(file_obj) for file_obj in fsspec_objs | ||
| ] | ||
| write_parquet_res = libparquet.write_parquet( | ||
| df, filepaths_or_buffers=file_objs, **common_args | ||
| ) |
There was a problem hiding this comment.
Python reviewers, is this an appropriate replacement for https://github.com/rapidsai/cudf/blob/ba3aedbb869ef95cae517f56ffb2bab305bffa40/python/cudf/cudf/io/parquet.py#L702-L708
Note that because we want to open multiple files to write to them at the same time, I couldn't use with.
There was a problem hiding this comment.
I think this is reasonable.
Codecov Report
@@ Coverage Diff @@
## branch-22.02 #9971 +/- ##
================================================
- Coverage 10.49% 10.44% -0.05%
================================================
Files 119 119
Lines 20305 20430 +125
================================================
+ Hits 2130 2134 +4
- Misses 18175 18296 +121
Continue to review full report at Codecov.
|
| paths_or_bufs = [ | ||
| ioutils.get_writer_filepath_or_buffer(path, mode="wb", **kwargs) | ||
| for path in paths | ||
| ] | ||
| common_args = { | ||
| "index": index, | ||
| "compression": compression, | ||
| "statistics": statistics, | ||
| "metadata_file_path": metadata_file_path, | ||
| "int96_timestamps": int96_timestamps, | ||
| "row_group_size_bytes": row_group_size_bytes, | ||
| "row_group_size_rows": row_group_size_rows, | ||
| "partitions_info": partitions_info, | ||
| } | ||
| if all([ioutils.is_fsspec_open_file(buf) for buf in paths_or_bufs]): | ||
| with ExitStack() as stack: | ||
| fsspec_objs = [stack.enter_context(file) for file in paths_or_bufs] | ||
| file_objs = [ | ||
| ioutils.get_IOBase_writer(file_obj) for file_obj in fsspec_objs | ||
| ] | ||
| write_parquet_res = libparquet.write_parquet( | ||
| df, filepaths_or_buffers=file_objs, **common_args | ||
| ) |
There was a problem hiding this comment.
I think this is reasonable.
| if metadata_file_path is not None: | ||
| warnings.warn( | ||
| "metadata_file_path will be ignored/overwritten when " | ||
| "partition_cols are provided" | ||
| ) |
There was a problem hiding this comment.
Can you explain this? It seems like there may be a significant change in behavior here. If so, the behavior should probably be described in the docstring.
There was a problem hiding this comment.
Ah - I see. This is a consequence of the ugly circular logic between to_parquet and write_to_dataset. Some historical context: I believe write_to_dataset was originally inteded to be the only way to write out a partitioned dataset. However, partition_cols was later added to to_parquet to redirect back into write_to_dataset. The problem with this latter approach is that you can no longer specify metadata_file_path. Instead, the user must specify return_metadata=True if they want the final metadata object to be returned.
Perhaps we need to add the return_metadata kwarg to the to_parquet docstring to make this clearer? Either way, the warning above should probably suggest using return_metadata=True if the user tries specifying metadata_file_path. What do you think?
There was a problem hiding this comment.
The problem created by this PR is that now there are two ways to get partitioning with to_parquet. The first is to pass partition_cols and partition_file_name and let cudf figure out the partitions and directory structure. The other is to pass a list of paths, offsets into the df to partition by and list of metadata_file_paths to set to each partition.
The second method is not really intended to be used by users and I worry that someone might think to pass args for both and get confused.
|
@gpucibot merge |


Makes use of the efficient partitioned writing support added in #9810 to improve performance of partitioned parquet dataset writing.
Closes #5059