Abyss-lord commented on code in PR #11422:
URL: https://github.com/apache/gravitino/pull/11422#discussion_r3370426456
##########
clients/client-python/gravitino/api/rel/expressions/named_reference.py:
##########
@@ -84,3 +84,30 @@ def __hash__(self) -> int:
def __str__(self) -> str:
"""Returns the string representation of the field reference."""
return ".".join(self._field_names)
+
+
+class MetadataField(NamedReference):
+ """A NamedReference that references a metadata field."""
+
+ _field_names: list[str]
+
+ def __init__(self, field_names: list[str]) -> None:
+ super().__init__()
+ self._field_names = field_names
+
+ def field_name(self) -> list[str]:
+ return list(self._field_names)
Review Comment:
Thanks for the suggestion. I intentionally return a new list here to protect
the internal `field_names` from being modified by callers.
Although `self._field_names` is already a list of strings, returning it
directly would expose the internal mutable list. For example, a caller could do:
```python
field_names = ref.field_name()
field_names.append("unexpected_field")
```
--
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]