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

Method test_inference_failure

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

Source from the content-addressed store, hash-verified

1717 'b': [b'ij']}])
1718
1719 def test_inference_failure(self):
1720 # Inference on first block, then conversion failure on second block
1721 rows = b"a,b\n123,456\nabc,de\xff\ngh,ij\n"
1722 read_options = ReadOptions()
1723 read_options.block_size = len(rows) - 7
1724 reader = self.open_bytes(rows, read_options=read_options)
1725 expected_schema = pa.schema([('a', pa.int64()),
1726 ('b', pa.int64())])
1727 assert reader.schema == expected_schema
1728 assert reader.read_next_batch().to_pydict() == {
1729 'a': [123], 'b': [456]
1730 }
1731 # Second block
1732 with pytest.raises(ValueError,
1733 match="CSV conversion error to int64"):
1734 reader.read_next_batch()
1735 # EOF
1736 with pytest.raises(StopIteration):
1737 reader.read_next_batch()
1738
1739 def test_invalid_csv(self):
1740 # 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