Skip to content

Commit eb30c12

Browse files
committed
test(io): cover infinity range filters and deletes
A double infinity on a float column now binds as a float literal, so <, <=, > and >= match rows instead of binding to always true or always false.
1 parent 60759e1 commit eb30c12

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

‎tests/io/test_pyarrow.py‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@
7171
BoundStartsWith,
7272
EqualTo,
7373
GreaterThan,
74+
GreaterThanOrEqual,
7475
In,
7576
IsNull,
77+
LessThan,
7678
LessThanOrEqual,
7779
Not,
7880
NotEqualTo,
@@ -3728,6 +3730,32 @@ def test_scan_filters_on_infinity(catalog: InMemoryCatalog) -> None:
37283730
assert sorted(table.scan(row_filter=In("x", {math.inf, 1.5})).to_arrow()["x"].to_pylist()) == [1.5, math.inf]
37293731

37303732

3733+
def test_scan_and_delete_filters_on_infinity(catalog: InMemoryCatalog) -> None:
3734+
schema = Schema(
3735+
NestedField(id=1, name="id", field_type=IntegerType(), required=False),
3736+
NestedField(id=2, name="x", field_type=FloatType(), required=False),
3737+
)
3738+
catalog.create_namespace("default")
3739+
table = catalog.create_table("default.test_scan_and_delete_infinity", schema=schema)
3740+
table.append(
3741+
pa.table(
3742+
{
3743+
"id": pa.array([1, 2, 3, 4, 5], type=pa.int32()),
3744+
"x": pa.array([1.5, math.inf, -math.inf, math.nan, None], type=pa.float32()),
3745+
}
3746+
)
3747+
)
3748+
3749+
assert table.scan(row_filter=LessThan("x", math.inf)).to_arrow()["id"].to_pylist() == [1, 3]
3750+
assert table.scan(row_filter=LessThanOrEqual("x", math.inf)).to_arrow()["id"].to_pylist() == [1, 2, 3]
3751+
assert table.scan(row_filter=GreaterThan("x", -math.inf)).to_arrow()["id"].to_pylist() == [1, 2]
3752+
assert table.scan(row_filter=GreaterThanOrEqual("x", math.inf)).to_arrow()["id"].to_pylist() == [2]
3753+
3754+
table.delete(LessThan("x", math.inf))
3755+
3756+
assert table.scan().to_arrow()["id"].to_pylist() == [2, 4, 5]
3757+
3758+
37313759
def test_scan_filters_at_the_end_of_the_date_range(catalog: InMemoryCatalog) -> None:
37323760
schema = Schema(NestedField(id=1, name="x", field_type=DateType(), required=False))
37333761
spec = PartitionSpec(PartitionField(source_id=1, field_id=1000, transform=YearTransform(), name="x_year"))

0 commit comments

Comments
 (0)