rdblue commented on code in PR #6128:
URL: https://github.com/apache/iceberg/pull/6128#discussion_r1022172621
##########
python/pyiceberg/transforms.py:
##########
@@ -644,8 +751,89 @@ def can_transform(self, _: IcebergType) -> bool:
def result_type(self, source: IcebergType) -> IcebergType:
return source
+ def project(self, name: str, pred: BoundPredicate) ->
Optional[UnboundPredicate]:
+ return None
+
def to_human_string(self, _: IcebergType, value: Optional[S]) -> str:
return "null"
def __repr__(self) -> str:
return "VoidTransform()"
+
+
+M = TypeVar("M")
+
+
+def _truncate_number(
+ name: str, pred: BoundLiteralPredicate, transform: Callable[[Optional[M]],
Optional[M]]
+) -> Optional[UnboundPredicate]:
+ boundary = pred.literal
+
+ if not isinstance(boundary, (LongLiteral, DecimalLiteral, DateLiteral,
TimeLiteral, TimestampLiteral)):
+ raise ValueError(f"Expected a numeric literal, got: {type(boundary)}")
+
+ if isinstance(pred, BoundLessThan):
+ return LessThanOrEqual(Reference(name), _transform_literal(transform,
boundary.decrement()))
+ elif isinstance(pred, BoundLessThanOrEqual):
+ return LessThanOrEqual(Reference(name), _transform_literal(transform,
boundary))
+ elif isinstance(pred, BoundGreaterThan):
+ return GreaterThanOrEqual(Reference(name),
_transform_literal(transform, boundary.increment()))
+ elif isinstance(pred, BoundGreaterThanOrEqual):
+ return GreaterThanOrEqual(Reference(name),
_transform_literal(transform, boundary))
+ elif isinstance(pred, BoundEqualTo):
+ return EqualTo(Reference(name), _transform_literal(transform,
boundary))
+ else:
+ return None
+
+
+def _truncate_array(
+ name: str, pred: BoundLiteralPredicate, func: Callable[[Optional[M]],
Optional[M]]
Review Comment:
`func` -> `transform`? That would match `_truncate_number`.
##########
python/pyiceberg/transforms.py:
##########
@@ -644,8 +751,89 @@ def can_transform(self, _: IcebergType) -> bool:
def result_type(self, source: IcebergType) -> IcebergType:
return source
+ def project(self, name: str, pred: BoundPredicate) ->
Optional[UnboundPredicate]:
+ return None
+
def to_human_string(self, _: IcebergType, value: Optional[S]) -> str:
return "null"
def __repr__(self) -> str:
return "VoidTransform()"
+
+
+M = TypeVar("M")
+
+
+def _truncate_number(
+ name: str, pred: BoundLiteralPredicate, transform: Callable[[Optional[M]],
Optional[M]]
+) -> Optional[UnboundPredicate]:
+ boundary = pred.literal
+
+ if not isinstance(boundary, (LongLiteral, DecimalLiteral, DateLiteral,
TimeLiteral, TimestampLiteral)):
+ raise ValueError(f"Expected a numeric literal, got: {type(boundary)}")
+
+ if isinstance(pred, BoundLessThan):
+ return LessThanOrEqual(Reference(name), _transform_literal(transform,
boundary.decrement()))
+ elif isinstance(pred, BoundLessThanOrEqual):
+ return LessThanOrEqual(Reference(name), _transform_literal(transform,
boundary))
+ elif isinstance(pred, BoundGreaterThan):
+ return GreaterThanOrEqual(Reference(name),
_transform_literal(transform, boundary.increment()))
+ elif isinstance(pred, BoundGreaterThanOrEqual):
+ return GreaterThanOrEqual(Reference(name),
_transform_literal(transform, boundary))
+ elif isinstance(pred, BoundEqualTo):
+ return EqualTo(Reference(name), _transform_literal(transform,
boundary))
+ else:
+ return None
+
+
+def _truncate_array(
+ name: str, pred: BoundLiteralPredicate, func: Callable[[Optional[M]],
Optional[M]]
Review Comment:
Nit: `func` -> `transform`? That would match `_truncate_number`.
--
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]