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

Function test_json_format_options

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

Source from the content-addressed store, hash-verified

3614
3615@pytest.mark.pandas
3616def test_json_format_options(tempdir, dataset_reader):
3617 table = pa.table({'a': pa.array([1, 2, 3], type="int64"),
3618 'b': pa.array([.1, .2, .3], type="float64")})
3619
3620 path = str(tempdir / 'test.json')
3621 out = table.to_pandas().to_json(orient='records')[1:-1].replace('},{', '}\n{')
3622 with open(path, 'w') as f:
3623 f.write(out)
3624
3625 with pytest.raises(ValueError,
3626 match="try to increase block size"):
3627 dataset = ds.dataset(path, format=ds.JsonFileFormat(
3628 read_options=pa.json.ReadOptions(block_size=4)))
3629
3630 dataset = ds.dataset(path, format=ds.JsonFileFormat(
3631 read_options=pa.json.ReadOptions(block_size=64)))
3632 result = dataset_reader.to_table(dataset)
3633 assert result.equals(table)
3634
3635
3636@pytest.mark.pandas

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