()
| 101 | |
| 102 | |
| 103 | def test_record_batch_reader_source(): |
| 104 | table = pa.table({'a': [1, 2, 3], 'b': [4, 5, 6]}) |
| 105 | reader = pa.RecordBatchReader.from_batches( |
| 106 | table.schema, table.to_batches(max_chunksize=2) |
| 107 | ) |
| 108 | decl = Declaration( |
| 109 | "record_batch_reader_source", RecordBatchReaderSourceNodeOptions(reader) |
| 110 | ) |
| 111 | result = decl.to_table() |
| 112 | assert result.equals(table) |
| 113 | |
| 114 | # a reader can only be consumed once |
| 115 | decl = Declaration( |
| 116 | "record_batch_reader_source", RecordBatchReaderSourceNodeOptions(reader) |
| 117 | ) |
| 118 | result = decl.to_table() |
| 119 | assert result.num_rows == 0 |
| 120 | |
| 121 | with pytest.raises(TypeError): |
| 122 | RecordBatchReaderSourceNodeOptions(table) |
| 123 | |
| 124 | with pytest.raises(TypeError): |
| 125 | RecordBatchReaderSourceNodeOptions(None) |
| 126 | |
| 127 | |
| 128 | def test_record_batch_reader_source_lazy_generator(): |
nothing calls this directly
no test coverage detected