Skip to content

Commit 3bb325f

Browse files
author
Roman Shanin
committed
evaluate projected fields in predicate
1 parent 6dee045 commit 3bb325f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pyiceberg/expressions/visitors.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,24 @@ def visit_bound_predicate(self, predicate: BoundPredicate[L]) -> BooleanExpressi
906906
# in the file schema when reading older data
907907
if isinstance(predicate, BoundIsNull):
908908
return AlwaysTrue()
909+
# Evaluate projected field by value extracted from partition
910+
elif (field_name := predicate.term.ref().field.name) in self.projected_missing_fields:
911+
unbound_predicate: BooleanExpression
912+
if isinstance(predicate, BoundUnaryPredicate):
913+
unbound_predicate = predicate.as_unbound(field_name)
914+
elif isinstance(predicate, BoundLiteralPredicate):
915+
unbound_predicate = predicate.as_unbound(field_name, predicate.literal)
916+
elif isinstance(predicate, BoundSetPredicate):
917+
unbound_predicate = predicate.as_unbound(field_name, predicate.literals)
918+
else:
919+
raise ValueError(f"Unsupported predicate: {predicate}")
920+
field = self.projected_schema.find_field(field_name)
921+
schema = Schema(field)
922+
evaluator = expression_evaluator(schema, unbound_predicate, self.case_sensitive)
923+
if evaluator(Record(self.projected_missing_fields[field_name])):
924+
return AlwaysTrue()
925+
else:
926+
return AlwaysFalse()
909927
else:
910928
return AlwaysFalse()
911929

0 commit comments

Comments
 (0)