| 362 | |
| 363 | |
| 364 | def test_schema_from_mapping(): |
| 365 | fields = OrderedDict([ |
| 366 | ('foo', pa.int32()), |
| 367 | ('bar', pa.string()), |
| 368 | ('baz', pa.list_(pa.int8())), |
| 369 | ]) |
| 370 | sch = pa.schema(fields) |
| 371 | assert sch.names == ['foo', 'bar', 'baz'] |
| 372 | assert sch.types == [pa.int32(), pa.string(), pa.list_(pa.int8())] |
| 373 | assert len(sch) == 3 |
| 374 | assert repr(sch) == """\ |
| 375 | foo: int32 |
| 376 | bar: string |
| 377 | baz: list<item: int8> |
| 378 | child 0, item: int8""" |
| 379 | |
| 380 | fields = OrderedDict([('foo', None)]) |
| 381 | with pytest.raises(TypeError): |
| 382 | pa.schema(fields) |
| 383 | |
| 384 | |
| 385 | def test_schema_duplicate_fields(): |