MCPcopy Create free account
hub / github.com/apache/arrow / test_table_from_batches_and_schema

Function test_table_from_batches_and_schema

python/pyarrow/tests/test_table.py:1404–1422  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1402
1403
1404def 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

Callers

nothing calls this directly

Calls 6

equalsMethod · 0.80
chunked_arrayMethod · 0.80
schemaMethod · 0.45
fieldMethod · 0.45
arrayMethod · 0.45
columnMethod · 0.45

Tested by

no test coverage detected