pvary commented on a change in pull request #2228:
URL: https://github.com/apache/hive/pull/2228#discussion_r622240406



##########
File path: 
iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerWithEngine.java
##########
@@ -759,6 +763,108 @@ public void testMultilevelIdentityPartitionedWrite() 
throws IOException {
     HiveIcebergTestUtils.validateData(table, records, 0);
   }
 
+  @Test
+  public void testYearTransform() throws IOException {
+    Schema schemaWithDate = new Schema(
+        optional(1, "id", Types.LongType.get()),
+        optional(2, "part_field", Types.DateType.get()));
+    PartitionSpec spec = 
PartitionSpec.builderFor(schemaWithDate).year("part_field").build();
+    List<Record> records = 
TestHelper.RecordsBuilder.newInstance(schemaWithDate)
+        .add(1L, LocalDate.of(2020, 1, 21))
+        .add(2L, LocalDate.of(2020, 1, 22))
+        .add(3L, LocalDate.of(2019, 1, 21))
+        .build();
+    Table table = testTables.createTable(shell, "part_test", schemaWithDate, 
spec, fileFormat, records);
+    HiveIcebergTestUtils.validateData(table, records, 0);
+
+    HiveIcebergTestUtils.validateData(shell, "part_test", records, "id");
+  }
+
+  @Test
+  public void testMonthTransform() throws IOException {
+    Schema schemaWithDate = new Schema(
+        optional(1, "id", Types.LongType.get()),
+        optional(2, "part_field", Types.TimestampType.withZone()));
+    PartitionSpec spec = 
PartitionSpec.builderFor(schemaWithDate).month("part_field").build();
+    List<Record> records = 
TestHelper.RecordsBuilder.newInstance(schemaWithDate)
+        .add(1L, OffsetDateTime.of(2017, 11, 22, 11, 30, 7, 0, 
ZoneOffset.ofHours(1)))
+        .add(2L, OffsetDateTime.of(2017, 11, 22, 11, 30, 7, 0, 
ZoneOffset.ofHours(2)))
+        .add(3L, OffsetDateTime.of(2017, 11, 23, 11, 30, 7, 0, 
ZoneOffset.ofHours(3)))
+        .build();
+    Table table = testTables.createTable(shell, "part_test", schemaWithDate, 
spec, fileFormat, records);
+    HiveIcebergTestUtils.validateData(table, records, 0);
+
+    HiveIcebergTestUtils.validateData(shell, "part_test", records, "id");
+  }
+
+  @Test
+  public void testDayTransform() throws IOException {
+    Schema schemaWithDate = new Schema(
+        optional(1, "id", Types.LongType.get()),
+        optional(2, "part_field", Types.TimestampType.withoutZone()));
+    PartitionSpec spec = 
PartitionSpec.builderFor(schemaWithDate).day("part_field").build();
+    List<Record> records = 
TestHelper.RecordsBuilder.newInstance(schemaWithDate)
+        .add(1L, LocalDateTime.of(2019, 2, 22, 9, 44, 54))
+        .add(2L, LocalDateTime.of(2019, 2, 22, 10, 44, 54))
+        .add(3L, LocalDateTime.of(2019, 2, 23, 9, 44, 54))
+        .build();
+    Table table = testTables.createTable(shell, "part_test", schemaWithDate, 
spec, fileFormat, records);
+    HiveIcebergTestUtils.validateData(table, records, 0);
+
+    HiveIcebergTestUtils.validateData(shell, "part_test", records, "id");
+  }
+
+  @Test
+  public void testHourTransform() throws IOException {
+    Schema schemaWithDate = new Schema(
+        optional(1, "id", Types.LongType.get()),
+        optional(2, "part_field", Types.TimestampType.withoutZone()));
+    PartitionSpec spec = 
PartitionSpec.builderFor(schemaWithDate).hour("part_field").build();
+    List<Record> records = 
TestHelper.RecordsBuilder.newInstance(schemaWithDate)
+        .add(1L, LocalDateTime.of(2019, 2, 22, 9, 44, 54))
+        .add(2L, LocalDateTime.of(2019, 2, 22, 10, 44, 54))
+        .add(3L, LocalDateTime.of(2019, 2, 23, 9, 44, 54))
+        .build();
+    Table table = testTables.createTable(shell, "part_test", schemaWithDate, 
spec, fileFormat, records);
+    HiveIcebergTestUtils.validateData(table, records, 0);
+
+    HiveIcebergTestUtils.validateData(shell, "part_test", records, "id");
+  }
+
+  @Test
+  public void testBucketTransform() throws IOException {
+    Schema schemaWithDate = new Schema(

Review comment:
       renamed.
   Good catch! Thx




-- 
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:
us...@infra.apache.org



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

Reply via email to