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:1465–1483  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1463
1464
1465def test_table_from_batches_and_schema():
1466 schema = pa.schema([
1467 pa.field('a', pa.int64()),
1468 pa.field('b', pa.float64()),
1469 ])
1470 batch = pa.record_batch([pa.array([1]), pa.array([3.14])],
1471 names=['a', 'b'])
1472 table = pa.Table.from_batches([batch], schema)
1473 assert table.schema.equals(schema)
1474 assert table.column(0) == pa.chunked_array([[1]])
1475 assert table.column(1) == pa.chunked_array([[3.14]])
1476
1477 incompatible_schema = pa.schema([pa.field('a', pa.int64())])
1478 with pytest.raises(pa.ArrowInvalid):
1479 pa.Table.from_batches([batch], incompatible_schema)
1480
1481 incompatible_batch = pa.record_batch([pa.array([1])], ['a'])
1482 with pytest.raises(pa.ArrowInvalid):
1483 pa.Table.from_batches([incompatible_batch], schema)
1484
1485
1486@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