| 869 | |
| 870 | |
| 871 | def test_struct_from_buffers(): |
| 872 | ty = pa.struct([pa.field('a', pa.int16()), pa.field('b', pa.utf8())]) |
| 873 | array = pa.array([{'a': 0, 'b': 'foo'}, None, {'a': 5, 'b': ''}], |
| 874 | type=ty) |
| 875 | buffers = array.buffers() |
| 876 | |
| 877 | with pytest.raises(ValueError): |
| 878 | # No children |
| 879 | pa.Array.from_buffers(ty, 3, [None, buffers[1]]) |
| 880 | |
| 881 | children = [pa.Array.from_buffers(pa.int16(), 3, buffers[1:3]), |
| 882 | pa.Array.from_buffers(pa.utf8(), 3, buffers[3:])] |
| 883 | copied = pa.Array.from_buffers(ty, 3, buffers[:1], children=children) |
| 884 | assert copied.equals(array) |
| 885 | |
| 886 | with pytest.raises(ValueError): |
| 887 | # not enough many children |
| 888 | pa.Array.from_buffers(ty, 3, [buffers[0]], |
| 889 | children=children[:1]) |
| 890 | |
| 891 | |
| 892 | def test_struct_from_arrays(): |