| 1402 | |
| 1403 | |
| 1404 | def test_table_from_batches_and_schema(): |
| 1405 | schema = pa.schema([ |
| 1406 | pa.field('a', pa.int64()), |
| 1407 | pa.field('b', pa.float64()), |
| 1408 | ]) |
| 1409 | batch = pa.record_batch([pa.array([1]), pa.array([3.14])], |
| 1410 | names=['a', 'b']) |
| 1411 | table = pa.Table.from_batches([batch], schema) |
| 1412 | assert table.schema.equals(schema) |
| 1413 | assert table.column(0) == pa.chunked_array([[1]]) |
| 1414 | assert table.column(1) == pa.chunked_array([[3.14]]) |
| 1415 | |
| 1416 | incompatible_schema = pa.schema([pa.field('a', pa.int64())]) |
| 1417 | with pytest.raises(pa.ArrowInvalid): |
| 1418 | pa.Table.from_batches([batch], incompatible_schema) |
| 1419 | |
| 1420 | incompatible_batch = pa.record_batch([pa.array([1])], ['a']) |
| 1421 | with pytest.raises(pa.ArrowInvalid): |
| 1422 | pa.Table.from_batches([incompatible_batch], schema) |
| 1423 | |
| 1424 | |
| 1425 | @pytest.mark.pandas |