You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/07/01 15:20:12 UTC
[GitHub] [iceberg] rdblue commented on a diff in pull request #5170: Python: Move Transforms to Pydantic
rdblue commented on code in PR #5170:
URL: https://github.com/apache/iceberg/pull/5170#discussion_r912054645
##########
python/pyiceberg/transforms.py:
##########
@@ -403,35 +408,38 @@ def _(value: Decimal, _width: int) -> Decimal:
class UnknownTransform(Transform):
"""A transform that represents when an unknown transform is provided
Args:
- source_type (Type): An Iceberg `Type`
+ source_type (IcebergType): An Iceberg `Type`
transform (str): A string name of a transform
Raises:
AttributeError: If the apply method is called.
"""
- def __init__(self, source_type: IcebergType, transform: str):
- super().__init__(
- transform,
- f"transforms.UnknownTransform(source_type={repr(source_type)}, transform={repr(transform)})",
- )
- self._type = source_type
+ __root__: Literal["unknown"] = Field(default="unknown")
+ _source_type: IcebergType = PrivateAttr()
+ _transform: str = PrivateAttr()
+
+ def __init__(self, source_type: IcebergType, transform: str, **data: Any):
+ super().__init__(**data)
+ self._source_type = source_type
self._transform = transform
def apply(self, value: Optional[S]):
raise AttributeError(f"Cannot apply unsupported transform: {self}")
def can_transform(self, source: IcebergType) -> bool:
- return self._type == source
+ return self._source_type == source
def result_type(self, source: IcebergType) -> IcebergType:
return StringType()
+ def __repr__(self) -> str:
+ return f"transforms.UnknownTransform(source_type={repr(self._source_type)}, transform={repr(self._transform)})"
Review Comment:
Some of the other `__repr__` implementations use factory methods, like `transforms.truncate`. Should we do the same here?
--
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-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org