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

Function test_json_format

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

Source from the content-addressed store, hash-verified

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