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

Function test_json_format

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

Source from the content-addressed store, hash-verified

3587
3588@pytest.mark.pandas
3589def test_json_format(tempdir, dataset_reader):
3590 table = pa.table({'a': pa.array([1, 2, 3], type="int64"),
3591 'b': pa.array([.1, .2, .3], type="float64")})
3592
3593 path = str(tempdir / 'test.json')
3594 out = table.to_pandas().to_json(orient='records')[1:-1].replace('},{', '}\n{')
3595 with open(path, 'w') as f:
3596 f.write(out)
3597
3598 dataset = ds.dataset(path, format=ds.JsonFileFormat())
3599 result = dataset_reader.to_table(dataset)
3600 assert result.equals(table)
3601
3602 assert_dataset_fragment_convenience_methods(dataset)
3603
3604 dataset = ds.dataset(path, format='json')
3605 result = dataset_reader.to_table(dataset)
3606 assert result.equals(table)
3607
3608
3609@pytest.mark.pandas

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected