Skip to content

Commit 16023ed

Browse files
authored
GH-48404: [Python] Add tests to to_table(filter=...) to reject a boolean expr (#48405)
### Rationale for this change - In order to remove the legacy TODO (from 9cb49f3) - To test non-boolean expressions to be rejected in the filter ### What changes are included in this PR? Added a couple of tests for non-boolean expressions at filter in to_table ### Are these changes tested? Yes, locally via `pytest pyarrow/tests/test_dataset.py`. ### Are there any user-facing changes? No, test-only. * GitHub Issue: #48404 Authored-by: Hyukjin Kwon <[email protected]> Signed-off-by: Adam Reeve <[email protected]>
1 parent c7ac877 commit 16023ed

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

python/pyarrow/tests/test_dataset.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,14 @@ def test_dataset(dataset, dataset_reader):
432432
assert isinstance(dataset, ds.Dataset)
433433
assert isinstance(dataset.schema, pa.Schema)
434434

435-
# TODO(kszucs): test non-boolean Exprs for filter do raise
435+
non_boolean_expr = ds.field('i64')
436+
with pytest.raises(TypeError, match="must evaluate to bool"):
437+
dataset.to_table(filter=non_boolean_expr)
438+
439+
non_boolean_expr2 = ds.field('i64') + 1
440+
with pytest.raises(TypeError, match="must evaluate to bool"):
441+
dataset.to_table(filter=non_boolean_expr2)
442+
436443
expected_i64 = pa.array([0, 1, 2, 3, 4], type=pa.int64())
437444
expected_f64 = pa.array([0, 1, 2, 3, 4], type=pa.float64())
438445

0 commit comments

Comments
 (0)