xanderbailey commented on code in PR #2891:
URL: https://github.com/apache/iceberg-rust/pull/2891#discussion_r3654874052
##########
crates/iceberg/src/transform/bucket.rs:
##########
@@ -146,6 +148,11 @@ impl Bucket {
fn bucket_bytes(&self, v: &[u8]) -> i32 {
self.bucket_n(Self::hash_bytes(v))
}
+
+ #[inline]
+ fn nanos_to_micros(v: i64) -> i64 {
Review Comment:
Confirmed that this matches Java
https://github.com/apache/iceberg/blob/main/api/src/main/java/org/apache/iceberg/util/DateTimeUtil.java#L104
and
https://github.com/apache/iceberg/blob/main/api/src/main/java/org/apache/iceberg/transforms/Bucket.java#L245
##########
crates/iceberg/src/transform/bucket.rs:
##########
@@ -999,4 +1006,43 @@ mod test {
assert_eq!(micro_result.value(0), nano_result.value(0));
}
+
+ #[test]
+ fn test_nanos_to_micros_uses_floor_division() {
+ assert_eq!(Bucket::nanos_to_micros(1_001), 1);
+ assert_eq!(Bucket::nanos_to_micros(1_000), 1);
+ assert_eq!(Bucket::nanos_to_micros(-1_000), -1);
Review Comment:
Maybe worth a sanity check for 0, i64::Min and i64::Max
--
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]