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

Function test_scan_iterator

python/pyarrow/tests/test_dataset.py:2698–2714  ·  view source on GitHub ↗
(use_threads)

Source from the content-addressed store, hash-verified

2696
2697@pytest.mark.parametrize('use_threads', [False, True])
2698def test_scan_iterator(use_threads):
2699 batch = pa.RecordBatch.from_arrays([pa.array(range(10))], names=["a"])
2700 table = pa.Table.from_batches([batch])
2701 # When constructed from readers/iterators, should be one-shot
2702 match = "OneShotFragment was already scanned"
2703 for factory, schema in (
2704 (lambda: pa.RecordBatchReader.from_batches(
2705 batch.schema, [batch]), None),
2706 (lambda: TableStreamWrapper(table), None),
2707 (lambda: (batch for _ in range(1)), batch.schema),
2708 ):
2709 # Scanning the fragment consumes the underlying iterator
2710 scanner = ds.Scanner.from_batches(
2711 factory(), schema=schema, use_threads=use_threads)
2712 assert scanner.to_table() == table
2713 with pytest.raises(pa.ArrowInvalid, match=match):
2714 scanner.to_table()
2715
2716
2717def _create_partitioned_dataset(basedir):

Callers

nothing calls this directly

Calls 4

TableStreamWrapperClass · 0.85
factoryFunction · 0.85
arrayMethod · 0.45
to_tableMethod · 0.45

Tested by

no test coverage detected