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

Function test_json_format

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

Source from the content-addressed store, hash-verified

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