(fields, writer_batch_size)
| 189 | "fields", [None, {"col_1": pa.string(), "col_2": pa.int64()}, {"col_1": pa.string(), "col_2": pa.int32()}] |
| 190 | ) |
| 191 | def test_write_row(fields, writer_batch_size): |
| 192 | output = pa.BufferOutputStream() |
| 193 | schema = pa.schema(fields) if fields else None |
| 194 | with ArrowWriter(stream=output, schema=schema, writer_batch_size=writer_batch_size) as writer: |
| 195 | writer.write_row(pa.Table.from_pydict({"col_1": ["foo"], "col_2": [1]})) |
| 196 | writer.write_row(pa.Table.from_pydict({"col_1": ["bar"], "col_2": [2]})) |
| 197 | num_examples, num_bytes = writer.finalize() |
| 198 | assert num_examples == 2 |
| 199 | assert num_bytes > 0 |
| 200 | if not fields: |
| 201 | fields = {"col_1": pa.string(), "col_2": pa.int64()} |
| 202 | assert writer._schema == pa.schema(fields, metadata=writer._schema.metadata) |
| 203 | _check_output(output.getvalue(), expected_num_chunks=num_examples if writer_batch_size == 1 else 1) |
| 204 | |
| 205 | |
| 206 | def test_write_file(): |
nothing calls this directly
no test coverage detected