This is an automated email from the ASF dual-hosted git repository.
areeve pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 16023ed5cf GH-48404: [Python] Add tests to to_table(filter=...) to
reject a boolean expr (#48405)
16023ed5cf is described below
commit 16023ed5cf6cfab7853ef49f50bed20ec799e9d9
Author: Hyukjin Kwon <[email protected]>
AuthorDate: Tue Dec 16 10:24:10 2025 +0900
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
https://github.com/apache/arrow/commit/9cb49f3d34dde8d28ac2eb921c4540eada2b19a2)
- 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]>
---
python/pyarrow/tests/test_dataset.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/python/pyarrow/tests/test_dataset.py
b/python/pyarrow/tests/test_dataset.py
index d22968c714..e30a484f90 100644
--- a/python/pyarrow/tests/test_dataset.py
+++ b/python/pyarrow/tests/test_dataset.py
@@ -432,7 +432,14 @@ def test_dataset(dataset, dataset_reader):
assert isinstance(dataset, ds.Dataset)
assert isinstance(dataset.schema, pa.Schema)
- # TODO(kszucs): test non-boolean Exprs for filter do raise
+ non_boolean_expr = ds.field('i64')
+ with pytest.raises(TypeError, match="must evaluate to bool"):
+ dataset.to_table(filter=non_boolean_expr)
+
+ non_boolean_expr2 = ds.field('i64') + 1
+ with pytest.raises(TypeError, match="must evaluate to bool"):
+ dataset.to_table(filter=non_boolean_expr2)
+
expected_i64 = pa.array([0, 1, 2, 3, 4], type=pa.int64())
expected_f64 = pa.array([0, 1, 2, 3, 4], type=pa.float64())