Fokko commented on code in PR #7782:
URL: https://github.com/apache/iceberg/pull/7782#discussion_r1294983094
##########
python/pyiceberg/transforms.py:
##########
@@ -106,47 +100,37 @@ def _transform_literal(func: Callable[[L], L], lit:
Literal[L]) -> Literal[L]:
return literal(func(lit.value))
-class Transform(IcebergBaseModel, ABC, Generic[S, T]):
+def _deserialize_transform(v: Any) -> Any:
+ if isinstance(v, str):
+ if v == IDENTITY:
+ return IdentityTransform()
+ elif v == VOID:
+ return VoidTransform()
+ elif v.startswith(BUCKET):
+ return BucketTransform(num_buckets=BUCKET_PARSER.match(v))
+ elif v.startswith(TRUNCATE):
+ return TruncateTransform(width=TRUNCATE_PARSER.match(v))
+ elif v == YEAR:
+ return YearTransform()
+ elif v == MONTH:
+ return MonthTransform()
+ elif v == DAY:
+ return DayTransform()
+ elif v == HOUR:
+ return HourTransform()
+ else:
+ return UnknownTransform(transform=v)
+ return v
+
+
+class Transform(IcebergRootModel[str], ABC, Generic[S, T]):
"""Transform base class for concrete transforms.
A base class to transform values and project predicates on partition
values.
This class is not used directly. Instead, use one of module method to
create the child classes.
"""
- __root__: str = Field()
-
- @classmethod
- def __get_validators__(cls) -> Generator[AnyCallable, None, None]:
- """Called to validate the input of the Transform class."""
- # 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: Any) -> IcebergBaseModel:
Review Comment:
This changed in 2.0:
https://docs.pydantic.dev/latest/migration/#validate_arguments-has-been-renamed-to-validate_call
--
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]