@@ -921,6 +921,33 @@ def test_in_filter_pushdown(self, duckdb_cursor):
921921 duckdb_conn .register ("duck_probe_arrow" , duck_probe_arrow )
922922 assert duckdb_conn .execute ("SELECT * from duck_probe_arrow where a = any([1,999])" ).fetchall () == [(1 ,), (999 ,)]
923923
924+ @pytest .mark .timeout (10 )
925+ def test_in_filter_pushdown_large_list (self , duckdb_cursor ):
926+ """Large IN lists must not hang. Regression test for https://github.com/duckdb/duckdb-python/issues/52."""
927+ arrow_table = pa .table ({"a" : pa .array (range (5000 ))})
928+ in_list = ", " .join (str (i ) for i in range (0 , 5000 , 2 ))
929+ result = duckdb .sql (f"SELECT count(*) FROM arrow_table WHERE a IN ({ in_list } )" ).fetchone ()
930+ assert result == (2500 ,)
931+
932+ def test_in_filter_pushdown_with_nulls (self , duckdb_cursor ):
933+ arrow_table = pa .table ({"a" : pa .array ([1 , 2 , None , 4 , None , 6 ])})
934+ # IN list without NULL: null rows should not match
935+ result = duckdb .sql ("SELECT a FROM arrow_table WHERE a IN (1, 4) ORDER BY a" ).fetchall ()
936+ assert result == [(1 ,), (4 ,)]
937+ # IN list with NULL: null rows still should not match (SQL semantics)
938+ result = duckdb .sql ("SELECT a FROM arrow_table WHERE a IN (1, 4, NULL) ORDER BY a" ).fetchall ()
939+ assert result == [(1 ,), (4 ,)]
940+
941+ def test_in_filter_pushdown_varchar (self , duckdb_cursor ):
942+ arrow_table = pa .table ({"s" : pa .array (["alice" , "bob" , "charlie" , "dave" , None ])})
943+ result = duckdb .sql ("SELECT s FROM arrow_table WHERE s IN ('bob', 'dave') ORDER BY s" ).fetchall ()
944+ assert result == [("bob" ,), ("dave" ,)]
945+
946+ def test_in_filter_pushdown_float (self , duckdb_cursor ):
947+ arrow_table = pa .table ({"f" : pa .array ([1.0 , 2.5 , 3.75 , 4.0 , None ], type = pa .float64 ())})
948+ result = duckdb .sql ("SELECT f FROM arrow_table WHERE f IN (2.5, 4.0) ORDER BY f" ).fetchall ()
949+ assert result == [(2.5 ,), (4.0 ,)]
950+
924951 def test_pushdown_of_optional_filter (self , duckdb_cursor ):
925952 cardinality_table = pa .Table .from_pydict (
926953 {
0 commit comments