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

Function test_csv_fragment_options

python/pyarrow/tests/test_dataset.py:3564–3585  ·  view source on GitHub ↗
(tempdir, dataset_reader)

Source from the content-addressed store, hash-verified

3562
3563
3564def test_csv_fragment_options(tempdir, dataset_reader):
3565 path = str(tempdir / 'test.csv')
3566 with open(path, 'w') as sink:
3567 sink.write('col0\nfoo\nspam\nMYNULL\n')
3568 dataset = ds.dataset(path, format='csv')
3569 convert_options = pyarrow.csv.ConvertOptions(null_values=['MYNULL'],
3570 strings_can_be_null=True)
3571 options = ds.CsvFragmentScanOptions(
3572 convert_options=convert_options,
3573 read_options=pa.csv.ReadOptions(block_size=2**16))
3574 result = dataset_reader.to_table(dataset, fragment_scan_options=options)
3575 assert result.equals(pa.table({'col0': pa.array(['foo', 'spam', None])}))
3576
3577 csv_format = ds.CsvFileFormat(convert_options=convert_options)
3578 dataset = ds.dataset(path, format=csv_format)
3579 result = dataset_reader.to_table(dataset)
3580 assert result.equals(pa.table({'col0': pa.array(['foo', 'spam', None])}))
3581
3582 options = ds.CsvFragmentScanOptions()
3583 result = dataset_reader.to_table(dataset, fragment_scan_options=options)
3584 assert result.equals(
3585 pa.table({'col0': pa.array(['foo', 'spam', 'MYNULL'])}))
3586
3587
3588@pytest.mark.pandas

Callers

nothing calls this directly

Calls 5

equalsMethod · 0.80
CsvFileFormatMethod · 0.80
writeMethod · 0.45
to_tableMethod · 0.45
arrayMethod · 0.45

Tested by

no test coverage detected