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

Function test_scan_iterator

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

Source from the content-addressed store, hash-verified

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