(fields, writer_batch_size)
| 171 | "fields", [None, {"col_1": pa.string(), "col_2": pa.int64()}, {"col_1": pa.string(), "col_2": pa.int32()}] |
| 172 | ) |
| 173 | def test_write_table(fields, writer_batch_size): |
| 174 | output = pa.BufferOutputStream() |
| 175 | schema = pa.schema(fields) if fields else None |
| 176 | with ArrowWriter(stream=output, schema=schema, writer_batch_size=writer_batch_size) as writer: |
| 177 | writer.write_table(pa.Table.from_pydict({"col_1": ["foo", "bar"], "col_2": [1, 2]})) |
| 178 | num_examples, num_bytes = writer.finalize() |
| 179 | assert num_examples == 2 |
| 180 | assert num_bytes > 0 |
| 181 | if not fields: |
| 182 | fields = {"col_1": pa.string(), "col_2": pa.int64()} |
| 183 | assert writer._schema == pa.schema(fields, metadata=writer._schema.metadata) |
| 184 | _check_output(output.getvalue(), expected_num_chunks=num_examples if writer_batch_size == 1 else 1) |
| 185 | |
| 186 | |
| 187 | @pytest.mark.parametrize("writer_batch_size", [None, 1, 10]) |
nothing calls this directly
no test coverage detected