rdblue commented on code in PR #6525:
URL: https://github.com/apache/iceberg/pull/6525#discussion_r1064185162


##########
python/pyiceberg/utils/iceberg_base_model.py:
##########
@@ -60,3 +63,39 @@ def json(self, exclude_none: bool = True, exclude: 
Optional[Set[str]] = None, by
         return super().json(
             exclude_none=exclude_none, 
exclude=self._exclude_private_properties(exclude), by_alias=by_alias, **kwargs
         )
+
+
+class PydanticStruct(IcebergBaseModel):
+    class Config:
+        frozen = False
+
+    def __setitem__(self, pos: int, value: Any) -> None:
+        positions = list(self.__fields__.values())
+        self.__setattr__(positions[pos].name, value)
+
+    def __getitem__(self, pos: int) -> Any:
+        positions = list(self.__fields__.values())
+        return self.__getattribute__(positions[pos].name)
+
+
+class Record(PydanticStruct):
+    """A generic record"""
+
+    _data: List[Any] = PrivateAttr()
+
+    @staticmethod
+    def of(length: int) -> Record:
+        return Record(*([None] * length))
+
+    def __init__(self, *data: Any) -> None:

Review Comment:
   While we're changing `get` and `set` to `__getitem__` and `__setitem__` 
should we also change `__init__` to take a number of fields rather than 
accepting an iterable of values? Or do we use this somewhere like `Record(1, 
"a")`?
   
   It would make more sense to me to use `Record.of(1, "a")` and 
`Record(length=2)` to construct than the opposite meanings that we have now.



-- 
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]

Reply via email to