nastra commented on code in PR #9008:
URL: https://github.com/apache/iceberg/pull/9008#discussion_r1629245294


##########
api/src/test/java/org/apache/iceberg/transforms/TestTimestamps.java:
##########
@@ -241,4 +243,54 @@ public void testTimestampsReturnType() {
     Type hourResultType = hour.getResultType(type);
     assertThat(hourResultType).isEqualTo(Types.IntegerType.get());
   }
+
+  @Test
+  public void apply_bad_source_type() {
+    Timestamps badSourceType =
+        new Timestamps(ChronoUnit.CENTURIES, Timestamps.ResultTypeUnit.YEARS, 
"year");
+    assertThatThrownBy(() -> badSourceType.apply(11L))
+        .isInstanceOf(UnsupportedOperationException.class)
+        .hasMessageMatching("Unsupported source type unit: Centuries");
+  }
+
+  @Test
+  public void apply_bad_result_type() {
+    Timestamps badResultType =
+        new Timestamps(ChronoUnit.MICROS, Timestamps.ResultTypeUnit.NANOS, 
"nano");
+    assertThatThrownBy(() -> badResultType.apply(11L))
+        .isInstanceOf(UnsupportedOperationException.class)
+        .hasMessageMatching("Unsupported result type unit: NANOS");
+  }
+
+  @Test
+  public void get_TimestampType_ChronoUnit() {
+    Types.TimestampType timestampType = Types.TimestampType.withZone();
+    assertThatThrownBy(() -> Timestamps.get(timestampType, 
ChronoUnit.CENTURIES))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessageMatching("Unsupported source/result type units: 
timestamptz->Centuries");

Review Comment:
   nit: I think it would be good to have a space before/after `->`



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to