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

Function test_scan_iterator

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

Source from the content-addressed store, hash-verified

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