MCPcopy Create free account
hub / github.com/apache/arrow / test_write_dataset_use_threads

Function test_write_dataset_use_threads

python/pyarrow/tests/test_dataset.py:4701–4736  ·  view source on GitHub ↗
(tempdir)

Source from the content-addressed store, hash-verified

4699@pytest.mark.parquet
4700@pytest.mark.pandas
4701def test_write_dataset_use_threads(tempdir):
4702 directory = tempdir / "partitioned"
4703 _ = _create_parquet_dataset_partitioned(directory)
4704 dataset = ds.dataset(directory, partitioning="hive")
4705
4706 partitioning = ds.partitioning(
4707 pa.schema([("part", pa.string())]), flavor="hive")
4708
4709 target1 = tempdir / 'partitioned1'
4710 paths_written = []
4711
4712 def file_visitor(written_file):
4713 paths_written.append(written_file.path)
4714
4715 ds.write_dataset(
4716 dataset, target1, format="feather", partitioning=partitioning,
4717 use_threads=True, file_visitor=file_visitor
4718 )
4719
4720 expected_paths = {
4721 target1 / 'part=a' / 'part-0.feather',
4722 target1 / 'part=b' / 'part-0.feather'
4723 }
4724 paths_written_set = set(map(pathlib.Path, paths_written))
4725 assert paths_written_set == expected_paths
4726
4727 target2 = tempdir / 'partitioned2'
4728 ds.write_dataset(
4729 dataset, target2, format="feather", partitioning=partitioning,
4730 use_threads=False
4731 )
4732
4733 # check that reading in gives same result
4734 result1 = ds.dataset(target1, format="feather", partitioning=partitioning)
4735 result2 = ds.dataset(target2, format="feather", partitioning=partitioning)
4736 assert result1.to_table().equals(result2.to_table())
4737
4738
4739@pytest.mark.parquet

Callers

nothing calls this directly

Calls 7

mapFunction · 0.85
partitioningMethod · 0.80
equalsMethod · 0.80
schemaMethod · 0.45
stringMethod · 0.45
to_tableMethod · 0.45

Tested by

no test coverage detected