samredai commented on code in PR #4679:
URL: https://github.com/apache/iceberg/pull/4679#discussion_r865354217
##########
python/src/iceberg/expressions/base.py:
##########
@@ -328,3 +329,49 @@ def eval(self, struct: StructProtocol) -> Any:
Any: The value at the referenced field's position in `struct`
"""
return self._accessor.get(struct)
+
+
+class UnboundReference:
+ """A reference not yet bound to a field in a schema
+
+ Args:
+ name (str): The name of the field
Review Comment:
@emkornfield agreed this could use more details. Once the accessor
functionality is added I'm planning to circle back here and add an example in
the docstring along the lines of:
```py
Example:
>>> from iceberg.expressions.base import UnboundReference
>>> from iceberg.schema import Schema
>>> from iceberg.types import FloatType, MapType, NestedField,
StringType
>>> schema = Schema(
... NestedField(
... field_id=1,
... name="location",
... field_type=MapType(
... key_id=2,
... key_type=StringType(),
... value_id=3,
... value_type=FloatType(),
... value_is_optional=False,
... ),
... is_optional=False,
... ),
... schema_id=1,
... )
>>> name = "location.lat"
>>> unbound_reference = UnboundReference(name="location.lat")
>>> unbound_reference.bind(schema=schema, case_sensitive=False)
BoundReference(field=1, accessor=Accessor(position=1,
inner=Accessor(position=2)))
```
I'll also expand name description to be more descriptive. Thanks!
--
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]