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

Function test_json_fragment_options

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

Source from the content-addressed store, hash-verified

3630
3631@pytest.mark.pandas
3632def test_json_fragment_options(tempdir, dataset_reader):
3633 table = pa.table({'a': pa.array([1, 2, 3], type="int64"),
3634 'b': pa.array([.1, .2, .3], type="float64")})
3635
3636 path = str(tempdir / 'test.json')
3637 out = table.to_pandas().to_json(orient='records')[1:-1].replace('},{', '}\n{')
3638 with open(path, 'w') as f:
3639 f.write(out)
3640
3641 with pytest.raises(ValueError,
3642 match="try to increase block size"):
3643 options = ds.JsonFragmentScanOptions(
3644 read_options=pa.json.ReadOptions(block_size=4))
3645 dataset = ds.dataset(path, format=ds.JsonFileFormat(options))
3646
3647 options = ds.JsonFragmentScanOptions(
3648 read_options=pa.json.ReadOptions(block_size=64))
3649 dataset = ds.dataset(path, format=ds.JsonFileFormat(options))
3650 result = dataset_reader.to_table(dataset)
3651 assert result.equals(table)
3652
3653
3654def test_encoding(tempdir, dataset_reader):

Callers

nothing calls this directly

Calls 5

JsonFileFormatMethod · 0.80
equalsMethod · 0.80
arrayMethod · 0.45
writeMethod · 0.45
to_tableMethod · 0.45

Tested by

no test coverage detected