@@ -809,6 +809,37 @@ def test_read_table_filters_buffer_reader_fallback():
809809 assert result ['id' ].to_pylist () == [6 , 7 , 8 , 9 ]
810810
811811
812+ def test_read_table_filters_buffer_reader_fallback_with_projection ():
813+ """Fallback should allow filtering on columns not present in output."""
814+ from pyarrow import orc
815+ import pyarrow .dataset as ds
816+
817+ table = pa .table ({'id' : range (10 ), 'value' : range (10 , 20 )})
818+ sink = pa .BufferOutputStream ()
819+ orc .write_table (table , sink )
820+ source = pa .BufferReader (sink .getvalue ())
821+
822+ result = orc .read_table (source , columns = ['value' ], filters = ds .field ('id' ) > 5 )
823+ assert result .num_rows == 4
824+ assert result .column_names == ['value' ]
825+ assert result ['value' ].to_pylist () == [16 , 17 , 18 , 19 ]
826+
827+
828+ def test_read_table_filters_buffer_reader_fallback_empty_projection ():
829+ """Fallback should preserve filtered row count with columns=[]."""
830+ from pyarrow import orc
831+ import pyarrow .dataset as ds
832+
833+ table = pa .table ({'id' : range (10 ), 'value' : range (10 )})
834+ sink = pa .BufferOutputStream ()
835+ orc .write_table (table , sink )
836+ source = pa .BufferReader (sink .getvalue ())
837+
838+ result = orc .read_table (source , columns = [], filters = ds .field ('id' ) > 5 )
839+ assert result .num_rows == 4
840+ assert result .num_columns == 0
841+
842+
812843def test_parquet_orc_predicate_pushdown_parity (tempdir ):
813844 """Equivalent ORC and Parquet predicates should produce equal results."""
814845 from pyarrow import orc
0 commit comments