jun-he commented on a change in pull request #1981:
URL: https://github.com/apache/iceberg/pull/1981#discussion_r552936378
##########
File path: api/src/main/java/org/apache/iceberg/transforms/Timestamps.java
##########
@@ -52,12 +52,23 @@ public Integer apply(Long timestampMicros) {
return null;
}
- // discards fractional seconds, not needed for calculation
- OffsetDateTime timestamp = Instant
- .ofEpochSecond(timestampMicros / 1_000_000)
- .atOffset(ZoneOffset.UTC);
-
- return (int) granularity.between(EPOCH, timestamp);
+ if (timestampMicros >= 0) {
+ OffsetDateTime timestamp = Instant
+ .ofEpochSecond(
+ Math.floorDiv(timestampMicros, 1_000_000),
+ Math.floorMod(timestampMicros, 1_000_000) * 1000)
Review comment:
nit: extract `1_000_000` and `1000` to be a constant with meaningful
name or use predefined ones in java library.
##########
File path: api/src/main/java/org/apache/iceberg/transforms/Dates.java
##########
@@ -99,11 +107,24 @@ public boolean satisfiesOrderOf(Transform<?, ?> other) {
if (pred.isUnaryPredicate()) {
return Expressions.predicate(pred.op(), fieldName);
+
} else if (pred.isLiteralPredicate()) {
- return ProjectionUtil.truncateInteger(fieldName,
pred.asLiteralPredicate(), this);
+ UnboundPredicate<Integer> projected =
ProjectionUtil.truncateInteger(fieldName, pred.asLiteralPredicate(), this);
+ if (this != DAY) {
Review comment:
Seems the same logic (`if (condition) {return...} return ...`) appears
multiple times, can it be included inside a method, e.g. just embed it in the
method defined in `ProjectionUtil`?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]