lurnagao-dahua commented on code in PR #10210:
URL: https://github.com/apache/iceberg/pull/10210#discussion_r1578796953


##########
mr/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerWithEngine.java:
##########
@@ -1206,6 +1208,55 @@ public void testRemoveAndAddBackColumnFromIcebergTable() 
throws IOException {
         0);
   }
 
+  @TestTemplate
+  public void testWriteWithDatePartition() {
+    assumeThat(executionEngine).as("Tez write is not implemented 
yet").isEqualTo("mr");
+
+    Schema dateSchema =
+        new Schema(
+            optional(1, "id", Types.LongType.get()),
+            optional(2, "part_field", Types.DateType.get()));
+
+    PartitionSpec spec = 
PartitionSpec.builderFor(dateSchema).identity("part_field").build();
+    List<Record> records =
+        TestHelper.RecordsBuilder.newInstance(dateSchema)
+            .add(1L, LocalDate.of(2023, 1, 21))
+            .add(2L, LocalDate.of(2023, 1, 22))
+            .add(3L, LocalDate.of(2022, 1, 21))
+            .build();
+    testTables.createTable(shell, "part_test", dateSchema, spec, 
FileFormat.PARQUET, records);
+    List<Object[]> result = shell.executeStatement("SELECT * from part_test 
order by id");
+
+    assertThat(records.size()).isEqualTo(result.size());
+    assertThat("2023-01-21").isEqualTo(result.get(0)[1]);
+    assertThat("2023-01-22").isEqualTo(result.get(1)[1]);
+    assertThat("2022-01-21").isEqualTo(result.get(2)[1]);
+  }
+
+  @TestTemplate
+  public void testWriteWithTimestampPartition() throws IOException {
+    assumeThat(executionEngine).as("Tez write is not implemented 
yet").isEqualTo("mr");
+
+    Schema dateSchema =
+        new Schema(
+            optional(1, "id", Types.LongType.get()),
+            optional(2, "part_field", Types.TimestampType.withoutZone()));
+    PartitionSpec spec = 
PartitionSpec.builderFor(dateSchema).identity("part_field").build();
+    List<Record> records =
+        TestHelper.RecordsBuilder.newInstance(dateSchema)
+            .add(1L, LocalDateTime.of(2023, 1, 21, 21, 10, 10, 100000000))
+            .add(2L, LocalDateTime.of(2023, 1, 21, 22, 10, 10, 200000000))
+            .add(3L, LocalDateTime.of(2023, 1, 22, 21, 10, 10, 300000000))
+            .build();
+    testTables.createTable(shell, "part_test", dateSchema, spec, 
FileFormat.PARQUET, records);
+    List<Object[]> result = shell.executeStatement("SELECT * from part_test 
order by id");
+
+    assertThat(records.size()).isEqualTo(result.size());
+    assertThat("2023-01-21 21:10:10.1").isEqualTo(result.get(0)[1]);

Review Comment:
   Hi, I updated.



-- 
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