Fokko commented on code in PR #5011:
URL: https://github.com/apache/iceberg/pull/5011#discussion_r902717817
##########
python/src/iceberg/types.py:
##########
@@ -59,134 +62,176 @@ class IcebergType:
'IcebergType()'
"""
- @property
- def string_type(self) -> str:
- return self.__repr__()
-
- def __str__(self) -> str:
- return self.string_type
+ @classmethod
+ def __get_validators__(cls):
+ # one or more validators may be yielded which will be called in the
+ # order to validate the input, each validator will receive as an input
+ # the value returned from the previous validator
+ yield cls.validate
+
+ @classmethod
+ def validate(cls, v):
Review Comment:
I'm not sure why I missed this comment. So, this is supposed to be still in,
but I moved the actual parsing (regex) to the type itself. Because the schema
is a `List[IcebergType]` it will try to validate that one first. As an example
fixed[22]` It will not be passed to the Fixed validate method (because the
`__root__` is dynamic).
Before I had everything in the validate method, now I call a static method
on the class itself:
```python
if v.startswith("fixed"):
return FixedType.parse(v)
```
--
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]