| 2678 | |
| 2679 | |
| 2680 | def test_construct_in_memory(dataset_reader): |
| 2681 | batch = pa.RecordBatch.from_arrays([pa.array(range(10))], names=["a"]) |
| 2682 | reader = pa.RecordBatchReader.from_batches(batch.schema, [batch]) |
| 2683 | table = pa.Table.from_batches([batch]) |
| 2684 | |
| 2685 | dataset_table = ds.dataset([], format='ipc', schema=pa.schema([]) |
| 2686 | ).to_table() |
| 2687 | assert dataset_table == pa.table([]) |
| 2688 | |
| 2689 | for source in (batch, table, [batch], [table], reader): |
| 2690 | dataset = ds.dataset(source) |
| 2691 | assert dataset_reader.to_table(dataset) == table |
| 2692 | assert len(list(dataset.get_fragments())) == 1 |
| 2693 | assert next(dataset.get_fragments()).to_table() == table |
| 2694 | assert pa.Table.from_batches(list(dataset.to_batches())) == table |
| 2695 | |
| 2696 | |
| 2697 | @pytest.mark.parametrize('use_threads', [False, True]) |