Fokko commented on code in PR #1644:
URL: https://github.com/apache/iceberg-python/pull/1644#discussion_r2175447526
##########
pyiceberg/expressions/visitors.py:
##########
@@ -893,15 +893,28 @@ def visit_unbound_predicate(self, predicate:
UnboundPredicate[L]) -> BooleanExpr
raise TypeError(f"Expected Bound Predicate, got: {predicate.term}")
def visit_bound_predicate(self, predicate: BoundPredicate[L]) ->
BooleanExpression:
- file_column_name =
self.file_schema.find_column_name(predicate.term.ref().field.field_id)
+ field = predicate.term.ref().field
+ file_column_name = self.file_schema.find_column_name(field.field_id)
if file_column_name is None:
# In the case of schema evolution, the column might not be present
- # in the file schema when reading older data
- if isinstance(predicate, BoundIsNull):
- return AlwaysTrue()
+ # we can use the default value as a constant and evaluate it
against
+ # the predicate
+ pred: BooleanExpression
+ if isinstance(predicate, BoundUnaryPredicate):
+ pred = predicate.as_unbound(field.name)
+ elif isinstance(predicate, BoundLiteralPredicate):
+ pred = predicate.as_unbound(field.name, predicate.literal)
+ elif isinstance(predicate, BoundSetPredicate):
+ pred = predicate.as_unbound(field.name, predicate.literals)
else:
- return AlwaysFalse()
+ raise ValueError(f"Unsupported predicate: {predicate}")
+
+ return (
+ AlwaysTrue()
+ if expression_evaluator(Schema(field), pred,
case_sensitive=self.case_sensitive)(Record(field.initial_default))
+ else AlwaysFalse()
+ )
if isinstance(predicate, BoundUnaryPredicate):
Review Comment:
No, this is the normal branch. The branch above applies when the field is
not in the Parquet file.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]