danny0405 commented on code in PR #7886:
URL: https://github.com/apache/hudi/pull/7886#discussion_r1104166520


##########
hudi-flink-datasource/hudi-flink/src/test/java/org/apache/hudi/table/ITTestHoodieDataSource.java:
##########
@@ -1693,6 +1693,92 @@ void testWriteReadWithLocalTimestamp(HoodieTableType 
tableType) {
     assertRowsEquals(result, expected);
   }
 
+  @Test
+  void testBulkInsertReadUTCTimeZone() {
+    TableEnvironment tableEnv = batchTableEnv;
+
+    String hoodieTableDDL = sql("t1")
+        .option(FlinkOptions.PATH, tempFile.getAbsolutePath())
+        .option(FlinkOptions.OPERATION, "bulk_insert")
+        .option(FlinkOptions.WRITE_BULK_INSERT_SHUFFLE_INPUT, true)
+        .option(FlinkOptions.WRITE_BULK_INSERT_SORT_INPUT, true)
+        .option(FlinkOptions.WRITE_BULK_INSERT_SORT_INPUT_BY_RECORD_KEY, true)
+        .option(FlinkOptions.UTC_TIMEZONE, true)
+        .end();
+    tableEnv.executeSql(hoodieTableDDL);
+
+    final String insertInto = "insert into t1 values\n"
+        + "('id2','Stephen',33,TIMESTAMP '1970-01-01 18:00:02','par1'),\n"
+        + "('id1','Julian',53,TIMESTAMP '1970-01-01 18:00:03','par1')";
+
+    execInsertSql(tableEnv, insertInto);
+
+    List<Row> rows = CollectionUtil.iterableToList(
+        () -> tableEnv.sqlQuery("select * from t1").execute().collect());
+    assertRowsEquals(rows, TestData.DATA_SET_SOURCE_INSERT_UTCTIMEZONE);
+  }
+
+  @ParameterizedTest
+  @EnumSource(value = ExecMode.class)
+  void testWriteReadTimestampMillisUTCTimeZone(ExecMode execMode) throws 
Exception {
+    String hoodieTableDDL = sql("t1")
+        .option(FlinkOptions.PATH, tempFile.getAbsolutePath())
+        .option(FlinkOptions.UTC_TIMEZONE, true)
+        .end();
+    streamTableEnv.executeSql(hoodieTableDDL);
+    String insertInto = "insert into t1 values\n"
+        + "('id1','Julian',53,TIMESTAMP '1970-01-01 18:00:03','par1'),\n"
+        + "('id2','Stephen',33,TIMESTAMP '1970-01-01 18:00:02','par1')";
+    execInsertSql(streamTableEnv, insertInto);
+
+
+    List<Row> result = execSelectSql(streamTableEnv, "select * from t1", 
execMode);
+
+    assertRowsEquals(result, TestData.DATA_SET_SOURCE_INSERT_UTCTIMEZONE);
+
+    // insert another batch of data
+    execInsertSql(streamTableEnv, insertInto);
+    List<Row> result2 = execSelectSql(streamTableEnv, "select * from t1", 
execMode);
+    assertRowsEquals(result2, TestData.DATA_SET_SOURCE_INSERT_UTCTIMEZONE);
+  }
+
+  @ParameterizedTest
+  @EnumSource(value = ExecMode.class)
+  void testWriteReadTimestampMicrosUTCTimeZone(ExecMode execMode) throws 
Exception {
+    boolean streaming = execMode == ExecMode.STREAM;
+    String hoodieTableDDL = sql("t1")
+        .field("id int")
+        .field("name varchar(10)")
+        .field("ts timestamp(6)")
+        .pkField("id")
+        .noPartition()
+        .option(FlinkOptions.PATH, tempFile.getAbsolutePath())
+        .option(FlinkOptions.READ_AS_STREAMING, streaming)
+        .option(FlinkOptions.UTC_TIMEZONE, true)
+        .end();
+    streamTableEnv.executeSql(hoodieTableDDL);
+    String insertInto = "insert into t1 values\n"
+        + "(1,'Danny',TIMESTAMP '2021-12-01 09:02:01.100001'),\n"
+        + "(2,'Stephen',TIMESTAMP '2021-12-02 11:04:02.200002'),\n"

Review Comment:
   Move the `insertInto` string into `TestSQL.java`



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to