Fokko commented on code in PR #209: URL: https://github.com/apache/iceberg-python/pull/209#discussion_r1434012843
########## pyiceberg/transforms.py: ########## @@ -821,3 +824,34 @@ class BoundTransform(BoundTerm[L]): def __init__(self, term: BoundTerm[L], transform: Transform[L, Any]): self.term: BoundTerm[L] = term self.transform = transform + + def eval(self, struct: StructProtocol) -> L: + """Return the value at the referenced field's position in an object that abides by the StructProtocol.""" + return self.term.eval(struct) + + def ref(self) -> BoundReference[L]: + """Return the bound reference.""" + return self.term.ref() + + +class UnboundTransform(UnboundTerm[L]): + """An unbound transform expression.""" + + transform: Transform[L, Any] + + def __init__(self, term: UnboundTerm[L], transform: Transform[L, Any]): + self.term: UnboundTerm[L] = term + self.transform = transform + + def bind(self, schema: Schema, case_sensitive: bool = True) -> BoundTransform[L]: + bound_term = self.term.bind(schema, case_sensitive) + + if not self.transform.can_transform(bound_term.ref().field.field_type): + raise ValueError("some better error message") + + else: + return BoundTransform(bound_term, self.transform) Review Comment: I think we should actually instantiate the callable of the transform: ```suggestion return BoundTransform(bound_term, self.transform.transform(bound_term.ref().field.field_type)) ``` ########## pyiceberg/transforms.py: ########## @@ -821,3 +824,34 @@ class BoundTransform(BoundTerm[L]): def __init__(self, term: BoundTerm[L], transform: Transform[L, Any]): self.term: BoundTerm[L] = term self.transform = transform + + def eval(self, struct: StructProtocol) -> L: + """Return the value at the referenced field's position in an object that abides by the StructProtocol.""" + return self.term.eval(struct) Review Comment: ```suggestion return self.transform(self.term.eval(struct)) ``` -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org