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

Method test_inference_failure

python/pyarrow/tests/test_csv.py:1648–1666  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1646 'b': [b'ij']}])
1647
1648 def test_inference_failure(self):
1649 # Inference on first block, then conversion failure on second block
1650 rows = b"a,b\n123,456\nabc,de\xff\ngh,ij\n"
1651 read_options = ReadOptions()
1652 read_options.block_size = len(rows) - 7
1653 reader = self.open_bytes(rows, read_options=read_options)
1654 expected_schema = pa.schema([('a', pa.int64()),
1655 ('b', pa.int64())])
1656 assert reader.schema == expected_schema
1657 assert reader.read_next_batch().to_pydict() == {
1658 'a': [123], 'b': [456]
1659 }
1660 # Second block
1661 with pytest.raises(ValueError,
1662 match="CSV conversion error to int64"):
1663 reader.read_next_batch()
1664 # EOF
1665 with pytest.raises(StopIteration):
1666 reader.read_next_batch()
1667
1668 def test_invalid_csv(self):
1669 # CSV errors on first block

Callers

nothing calls this directly

Calls 4

open_bytesMethod · 0.95
ReadOptionsClass · 0.90
lenFunction · 0.85
schemaMethod · 0.45

Tested by

no test coverage detected