You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by li...@apache.org on 2026/08/20 09:36:32 UTC

(iceberg-rust) branch main updated: fix(transform): support hour transform for nanosecond arrays (#3026)

This is an automated email from the ASF dual-hosted git repository.

blackmwk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-rust.git


The following commit(s) were added to refs/heads/main by this push:
     new 48965dc8c fix(transform): support hour transform for nanosecond arrays (#3026)
48965dc8c is described below

commit 48965dc8cd54bc6e2029205fec617ac66b5ee40e
Author: Matt Faltyn <76...@users.noreply.github.com>
AuthorDate: Thu Aug 20 11:36:26 2026 +0200

    fix(transform): support hour transform for nanosecond arrays (#3026)
---
 crates/iceberg/src/transform/temporal.rs | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/crates/iceberg/src/transform/temporal.rs b/crates/iceberg/src/transform/temporal.rs
index 5f943bb85..e9831b542 100644
--- a/crates/iceberg/src/transform/temporal.rs
+++ b/crates/iceberg/src/transform/temporal.rs
@@ -348,6 +348,11 @@ impl TransformFunction for Hour {
                 .downcast_ref::<TimestampMicrosecondArray>()
                 .unwrap()
                 .unary(|v| -> i32 { Self::hour_timestamp_micro(v) }),
+            DataType::Timestamp(TimeUnit::Nanosecond, _) => input
+                .as_any()
+                .downcast_ref::<TimestampNanosecondArray>()
+                .unwrap()
+                .unary(|v| -> i32 { Self::hour_timestamp_nano(v) }),
             _ => {
                 return Err(Error::new(
                     ErrorKind::FeatureUnsupported,
@@ -391,7 +396,9 @@ impl TransformFunction for Hour {
 mod test {
     use std::sync::Arc;
 
-    use arrow_array::{ArrayRef, Date32Array, Int32Array, TimestampMicrosecondArray};
+    use arrow_array::{
+        ArrayRef, Date32Array, Int32Array, TimestampMicrosecondArray, TimestampNanosecondArray,
+    };
     use chrono::{NaiveDate, NaiveDateTime};
 
     use crate::Result;
@@ -2714,6 +2721,19 @@ mod test {
         assert_eq!(res.value(2), expect_hour[2]);
         assert_eq!(res.value(3), expect_hour[3]);
         assert_eq!(res.value(4), -1);
+
+        // Test TimestampNanosecond with and without timezone
+        let timestamp_nanos = vec![0, super::NANOSECONDS_PER_HOUR, -1];
+        let date_arrays = [
+            Arc::new(TimestampNanosecondArray::from(timestamp_nanos.clone())) as ArrayRef,
+            Arc::new(TimestampNanosecondArray::from(timestamp_nanos).with_timezone_utc())
+                as ArrayRef,
+        ];
+        for date_array in date_arrays {
+            let res = hour.transform(date_array).unwrap();
+            let res = res.as_any().downcast_ref::<Int32Array>().unwrap();
+            assert_eq!(res.values(), &[0, 1, -1]);
+        }
     }
 
     #[test]