westonpace commented on code in PR #34586: URL: https://github.com/apache/arrow/pull/34586#discussion_r1164417858
########## python/pyarrow/tests/test_dataset.py: ########## @@ -3172,6 +3202,58 @@ def test_csv_fragment_options(tempdir, dataset_reader): assert result.equals( pa.table({'col0': pa.array(['foo', 'spam', 'MYNULL'])})) +@pytest.mark.pandas +def test_json_format(tempdir, dataset_reader): + table = pa.table({'a': pa.array([1, 2, 3], type="int64"), + 'b': pa.array([.1, .2, .3], type="float64")}) + + path = str(tempdir / 'test.json') + out = table.to_pandas().to_json(orient='records')[1:-1].replace('},{', '}\n{') + with open(path, 'w') as f: + f.write(out) + + dataset = ds.dataset(path, format=ds.JsonFileFormat()) + result = dataset_reader.to_table(dataset) + assert result.equals(table) + + assert_dataset_fragment_convenience_methods(dataset) + + dataset = ds.dataset(path, format='json') + result = dataset_reader.to_table(dataset) + assert result.equals(table) + +def test_json_format_options(tempdir, dataset_reader): + table = pa.table({'a': pa.array([1, 2, 3], type="int64"), + 'b': pa.array([.1, .2, .3], type="float64")}) + + path = str(tempdir / 'test.json') + out = table.to_pandas().to_json(orient='records')[1:-1].replace('},{', '}\n{') + with open(path, 'w') as f: + f.write(out) + + dataset = ds.dataset(path, format=ds.JsonFileFormat( + read_options=pa.json.ReadOptions(block_size=64))) Review Comment: Ok, the updated test is good. Please do open an issue for `newlines_in_values` but we don't need to hold up this PR for that. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org