marton-bod commented on a change in pull request #2228:
URL: https://github.com/apache/hive/pull/2228#discussion_r622181150
##########
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(
+ optional(1, "id", Types.LongType.get()),
+ optional(2, "part_field", Types.StringType.get()));
+ PartitionSpec spec =
PartitionSpec.builderFor(schemaWithDate).bucket("part_field", 2).build();
+ List<Record> records =
TestHelper.RecordsBuilder.newInstance(schemaWithDate)
+ .add(1L, "Part1")
+ .add(2L, "Part2")
+ .add(3L, "Art3")
+ .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 testTruncateTransform() throws IOException {
+ Schema schemaWithDate = new Schema(
+ optional(1, "id", Types.LongType.get()),
+ optional(2, "part_field", Types.StringType.get()));
+ PartitionSpec spec =
PartitionSpec.builderFor(schemaWithDate).truncate("part_field", 2).build();
+ List<Record> records =
TestHelper.RecordsBuilder.newInstance(schemaWithDate)
+ .add(1L, "Part1")
+ .add(2L, "Part2")
+ .add(3L, "Art3")
+ .build();
+ Table table = testTables.createTable(shell, "part_test", schemaWithDate,
spec, fileFormat, records);
+ HiveIcebergTestUtils.validateData(table, records, 0);
Review comment:
What is the difference between the two `validateData` methods?
--
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]