rdblue commented on code in PR #5601:
URL: https://github.com/apache/iceberg/pull/5601#discussion_r953080807
##########
api/src/main/java/org/apache/iceberg/transforms/Truncate.java:
##########
@@ -71,16 +120,55 @@ public boolean preservesOrder() {
return true;
}
- private static class TruncateInteger extends Truncate<Integer> {
- private final int width;
+ @Override
+ public boolean satisfiesOrderOf(Transform<?, ?> other) {
+ if (this == other) {
+ return true;
+ }
+
+ if (!(other instanceof Truncate)) {
+ return false;
+ }
+
+ Truncate<?> otherTrunc = (Truncate<?>) other;
+ return otherTrunc.width <= width;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ } else if (!(o instanceof Truncate)) {
+ return false;
+ }
+
+ Truncate<?> that = (Truncate<?>) o;
+ return width == that.width;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(width);
+ }
+ @Override
+ public String toString() {
+ return "truncate[" + width + "]";
+ }
+
+ private static class TruncateInteger extends Truncate<Integer>
+ implements Function<Integer, Integer> {
private TruncateInteger(int width) {
- this.width = width;
+ super(width);
}
@Override
- public Integer width() {
- return width;
+ public Function<Integer, Integer> bind(Type type) {
+ if (type.typeId() == Type.TypeID.INTEGER) {
+ return this;
+ } else {
+ return null;
Review Comment:
I think it should be to throw an exception. I should update this.
--
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]