Skip to content

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

pyiceberg/transforms.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -817,10 +817,11 @@ def strict_project(self, name: str, pred: BoundPredicate[Any]) -> Optional[Unbou
817817
if isinstance(pred.term, BoundTransform):
818818
return _project_transform_predicate(self, name, pred)
819819

820+
if isinstance(pred, BoundUnaryPredicate):
821+
return pred.as_unbound(Reference(name))
822+
820823
if isinstance(field_type, (IntegerType, LongType, DecimalType)):
821-
if isinstance(pred, BoundUnaryPredicate):
822-
return pred.as_unbound(Reference(name))
823-
elif isinstance(pred, BoundLiteralPredicate):
824+
if isinstance(pred, BoundLiteralPredicate):
824825
return _truncate_number_strict(name, pred, self.transform(field_type))
825826
elif isinstance(pred, BoundNotIn):
826827
return _set_apply_transform(name, pred, self.transform(field_type))

tests/test_transforms.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,9 @@ def test_negative_year_strict_upper_bound(bound_reference_date: BoundReference[i
12811281
def test_strict_bucket_integer(bound_reference_int: BoundReference[int]) -> None:
12821282
value = literal(100).to(IntegerType())
12831283
transform = BucketTransform(num_buckets=10)
1284+
1285+
_assert_projection_strict(BoundIsNull(term=bound_reference_int), transform, AlwaysFalse)
1286+
12841287
_assert_projection_strict(BoundNotEqualTo(term=bound_reference_int, literal=value), transform, NotEqualTo, "6")
12851288

12861289
for expr in [BoundEqualTo, BoundLessThan, BoundLessThanOrEqual, BoundGreaterThan, BoundGreaterThanOrEqual]:
@@ -1294,6 +1297,9 @@ def test_strict_bucket_integer(bound_reference_int: BoundReference[int]) -> None
12941297
def test_strict_bucket_long(bound_reference_long: BoundReference[int]) -> None:
12951298
value = literal(100).to(LongType())
12961299
transform = BucketTransform(num_buckets=10)
1300+
1301+
_assert_projection_strict(BoundIsNull(term=bound_reference_long), transform, AlwaysFalse)
1302+
12971303
_assert_projection_strict(BoundNotEqualTo(term=bound_reference_long, literal=value), transform, NotEqualTo, "6")
12981304

12991305
for expr in [BoundEqualTo, BoundLessThan, BoundLessThanOrEqual, BoundGreaterThan, BoundGreaterThanOrEqual]:
@@ -1308,6 +1314,9 @@ def test_strict_bucket_decimal(bound_reference_decimal: BoundReference[int]) ->
13081314
dec = DecimalType(9, 2)
13091315
value = literal("100.00").to(dec)
13101316
transform = BucketTransform(num_buckets=10)
1317+
1318+
_assert_projection_strict(BoundIsNull(term=bound_reference_decimal), transform, AlwaysFalse)
1319+
13111320
_assert_projection_strict(BoundNotEqualTo(term=bound_reference_decimal, literal=value), transform, NotEqualTo, "2")
13121321

13131322
for expr in [BoundEqualTo, BoundLessThan, BoundLessThanOrEqual, BoundGreaterThan, BoundGreaterThanOrEqual]:
@@ -1321,6 +1330,9 @@ def test_strict_bucket_decimal(bound_reference_decimal: BoundReference[int]) ->
13211330
def test_strict_bucket_string(bound_reference_str: BoundReference[int]) -> None:
13221331
value = literal("abcdefg").to(StringType())
13231332
transform = BucketTransform(num_buckets=10)
1333+
1334+
_assert_projection_strict(BoundIsNull(term=bound_reference_str), transform, AlwaysFalse)
1335+
13241336
_assert_projection_strict(BoundNotEqualTo(term=bound_reference_str, literal=value), transform, NotEqualTo, "4")
13251337

13261338
for expr in [BoundEqualTo, BoundLessThan, BoundLessThanOrEqual, BoundGreaterThan, BoundGreaterThanOrEqual]:
@@ -1334,6 +1346,9 @@ def test_strict_bucket_string(bound_reference_str: BoundReference[int]) -> None:
13341346
def test_strict_bucket_bytes(bound_reference_binary: BoundReference[int]) -> None:
13351347
value = literal(str.encode("abcdefg")).to(BinaryType())
13361348
transform = BucketTransform(num_buckets=10)
1349+
1350+
_assert_projection_strict(BoundIsNull(term=bound_reference_binary), transform, AlwaysFalse)
1351+
13371352
_assert_projection_strict(BoundNotEqualTo(term=bound_reference_binary, literal=value), transform, NotEqualTo, "4")
13381353

13391354
for expr in [BoundEqualTo, BoundLessThan, BoundLessThanOrEqual, BoundGreaterThan, BoundGreaterThanOrEqual]:
@@ -1347,6 +1362,9 @@ def test_strict_bucket_bytes(bound_reference_binary: BoundReference[int]) -> Non
13471362
def test_strict_bucket_uuid(bound_reference_uuid: BoundReference[int]) -> None:
13481363
value = literal("00000000-0000-007b-0000-0000000001c8").to(UUIDType())
13491364
transform = BucketTransform(num_buckets=10)
1365+
1366+
_assert_projection_strict(BoundIsNull(term=bound_reference_uuid), transform, AlwaysFalse)
1367+
13501368
_assert_projection_strict(BoundNotEqualTo(term=bound_reference_uuid, literal=value), transform, NotEqualTo, "4")
13511369

13521370
for expr in [BoundEqualTo, BoundLessThan, BoundLessThanOrEqual, BoundGreaterThan, BoundGreaterThanOrEqual]:

0 commit comments

Comments
 (0)