| [ Web Proxy ] |
| Viewing: https://arrow.apache.org/docs/python/generated/../generated/pyarrow.dataset.write_dataset.html | [Back] [Original] |
Write a dataset to a given format and partitioning.
Dataset, Table/RecordBatch, RecordBatchReader, list of Table/RecordBatch, or iterable of RecordBatchThe data to write. This can be a Dataset instance or in-memory Arrow data. If an iterable is given, the schema must also be given.
strThe root directory where to write the dataset.
str, optionalA template string used to generate basenames of written data files. The token {i} will be replaced with an automatically incremented integer. If not specified, it defaults to part-{i}. + format.default_extname
FileFormat or strThe format in which to write the dataset. Currently supported: parquet, ipc/arrow/feather, and csv. If a FileSystemDataset is being written and format is not specified, it defaults to the same format as the specified FileSystemDataset. When writing a Table or RecordBatch, this keyword is required.
Partitioning or list[str], optionalThe partitioning scheme specified with the partitioning()
function or a list of field names. When providing a list of
field names, you can use partitioning_flavor to drive which
partitioning type should be used.
str, optionalOne of the partitioning flavors supported by
pyarrow.dataset.partitioning. If omitted will use the
default of partitioning() which is directory partitioning.
Schema, optionalFileSystem, optionalpyarrow.dataset.FileWriteOptions, optionalFileFormat specific write options, created using the
FileFormat.make_write_options() function.
TrueWrite files in parallel. If enabled, then maximum parallelism will be used determined by the number of available CPU cores. Using multiple threads may change the order of rows in the written dataset if preserve_order is set to False.
FalsePreserve the order of rows. If enabled, order of rows in the dataset are guaranteed to be preserved even if use_threads is set to True. This may cause notable performance degradation.
int, default 1024Maximum number of partitions any batch may be written into.
int, default 1024If greater than 0 then this will limit the maximum number of files that can be left open. If an attempt is made to open too many files then the least recently used file will be closed. If this setting is set too low you may end up fragmenting your data into many small files.
int, default 0Maximum number of rows per file. If greater than 0 then this will limit how many rows are placed in any single file. Otherwise there will be no limit and one file will be created in each output directory unless files need to be closed to respect max_open_files
int, default 0Minimum number of rows per group. When the value is greater than 0, the dataset writer will batch incoming data and only write the row groups to the disk when sufficient rows have accumulated.
int, default 1024 * 1024Maximum number of rows per group. If the value is greater than 0, then the dataset writer may split up large incoming batches into multiple row groups. If this value is set, then min_rows_per_group should also be set. Otherwise it could end up with very small row groups.
If set, this function will be called with a WrittenFile instance for each file created during the call. This object will have both a path attribute and a metadata attribute.
The path attribute will be a string containing the path to the created file.
The metadata attribute will be the parquet metadata of the file. This metadata will have the file path attribute set and can be used to build a _metadata file. The metadata attribute will be None if the format is not parquet.
Example visitor which simple collects the filenames created:
visited_paths = []
def file_visitor(written_file):
visited_paths.append(written_file.path)
Controls how the dataset will handle data that already exists in the destination. The default behavior (error) is to raise an error if any data exists in the destination.
overwrite_or_ignore will ignore any existing data and will overwrite files with the same name as an output file. Other existing files will be ignored. This behavior, in combination with a unique basename_template for each write, will allow for an append workflow.
delete_matching is useful when you are writing a partitioned dataset. The first time each partition directory is encountered the entire directory will be deleted. This allows you to overwrite old partitions completely.
TrueIf False, directories will not be created. This can be useful for filesystems that do not require directories.
| Web Proxy Viewer | New URL | Original Page |