Skip to content

Commit b5ef330

Browse files
committed
Move tests to existing tests in test_compute
1 parent 9db6ad6 commit b5ef330

2 files changed

Lines changed: 22 additions & 12 deletions

File tree

‎python/pyarrow/tests/test_acero.py‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,6 @@ def test_filter(table_source):
115115
FilterNodeOptions(None)
116116

117117

118-
@pytest.mark.parametrize('source', [
119-
pa.record_batch({"number": [1, 2, 3]}),
120-
pa.table({"number": [1, 2, 3]})
121-
])
122-
def test_filter_all_rows(source):
123-
output = source.filter(pc.field("number") < 0)
124-
125-
assert output.num_rows == 0
126-
assert type(output) is type(source)
127-
assert output.schema.equals(source.schema)
128-
129-
130118
def test_project(table_source):
131119
# default name from expression
132120
decl = Declaration.from_sequence([

‎python/pyarrow/tests/test_compute.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,17 @@ def test_filter_record_batch():
14151415
expected = pa.record_batch([pa.array(["a", None, "e"])], names=["a'"])
14161416
assert result.equals(expected)
14171417

1418+
# GH-46057: filtering all rows should return empty RecordBatch with same schema
1419+
mask_empty_result = batch.filter(pa.array([False] * batch.num_rows))
1420+
assert mask_empty_result.num_rows == 0
1421+
assert isinstance(mask_empty_result, pa.RecordBatch)
1422+
assert mask_empty_result.schema.equals(batch.schema)
1423+
1424+
expr_empty_result = batch.filter(pc.field("a'") == "zzz")
1425+
assert expr_empty_result.num_rows == 0
1426+
assert isinstance(expr_empty_result, pa.RecordBatch)
1427+
assert expr_empty_result.schema.equals(batch.schema)
1428+
14181429

14191430
def test_filter_table():
14201431
table = pa.table([pa.array(["a", None, "c", "d", "e"])], names=["a"])
@@ -1434,6 +1445,17 @@ def test_filter_table():
14341445
result = table.filter(mask, null_selection_behavior="emit_null")
14351446
assert result.equals(expected_null)
14361447

1448+
# GH-46057: filtering all rows should return empty table with same schema
1449+
mask_empty_result = table.filter(pa.array([False] * table.num_rows))
1450+
assert mask_empty_result.num_rows == 0
1451+
assert isinstance(mask_empty_result, pa.Table)
1452+
assert mask_empty_result.schema.equals(table.schema)
1453+
1454+
expr_empty_result = table.filter(pc.field("a") == "zzz")
1455+
assert expr_empty_result.num_rows == 0
1456+
assert isinstance(expr_empty_result, pa.Table)
1457+
assert expr_empty_result.schema.equals(table.schema)
1458+
14371459

14381460
def test_filter_errors():
14391461
arr = pa.chunked_array([["a", None], ["c", "d", "e"]])

0 commit comments

Comments
 (0)