Skip to content

Commit 2bed9b0

Browse files
committed
refactor: simplify dataset filter tests by removing unnecessary assertions and parameters
1 parent d9af482 commit 2bed9b0

1 file changed

Lines changed: 3 additions & 13 deletions

File tree

python/tests/test_context.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ def test_register_dataset(ctx):
347347
assert result[0].column(1) == pa.array([-3, -3, -3])
348348

349349

350-
def test_dataset_filter(ctx, capfd):
350+
def test_dataset_filter(ctx):
351351
# create a RecordBatch and register it as a pyarrow.dataset.Dataset
352352
batch = pa.RecordBatch.from_arrays(
353353
[pa.array([1, 2, 3]), pa.array([4, 5, 6])],
@@ -359,11 +359,6 @@ def test_dataset_filter(ctx, capfd):
359359
assert ctx.catalog().schema().names() == {"t"}
360360
df = ctx.sql("SELECT a+b, a-b FROM t WHERE a BETWEEN 2 and 3 AND b > 5")
361361

362-
# Make sure the filter was pushed down in Physical Plan
363-
df.explain()
364-
captured = capfd.readouterr()
365-
assert "filter_expr=(((a >= 2) and (a <= 3)) and (b > 5))" in captured.out
366-
367362
result = df.collect()
368363

369364
assert result[0].column(0) == pa.array([9])
@@ -389,21 +384,16 @@ def test_dataset_count(ctx):
389384
assert count[0].column(0) == pa.array([3])
390385

391386

392-
def test_pyarrow_predicate_pushdown_is_null(ctx, capfd):
393-
"""Ensure that pyarrow filter gets pushed down for `IsNull`"""
387+
def test_pyarrow_predicate_is_null(ctx):
388+
"""Ensure that filters with `IsNull` produce correct results"""
394389
# create a RecordBatch and register it as a pyarrow.dataset.Dataset
395390
batch = pa.RecordBatch.from_arrays(
396391
[pa.array([1, 2, 3]), pa.array([4, 5, 6]), pa.array([7, None, 9])],
397392
names=["a", "b", "c"],
398393
)
399394
dataset = ds.dataset([batch])
400395
ctx.register_dataset("t", dataset)
401-
# Make sure the filter was pushed down in Physical Plan
402396
df = ctx.sql("SELECT a FROM t WHERE c is NULL")
403-
df.explain()
404-
captured = capfd.readouterr()
405-
assert "filter_expr=is_null(c, {nan_is_null=false})" in captured.out
406-
407397
result = df.collect()
408398
assert result[0].column(0) == pa.array([2])
409399

0 commit comments

Comments
 (0)