danny0405 commented on a change in pull request #2900:
URL: https://github.com/apache/hudi/pull/2900#discussion_r623569281
##########
File path:
hudi-flink/src/test/java/org/apache/hudi/table/HoodieDataSourceITCase.java
##########
@@ -390,6 +393,34 @@ void testWriteNonPartitionedTable(ExecMode execMode) {
assertRowsEquals(result, "[id1,Sophia,18,1970-01-01T00:00:05,par5]");
}
+ @ParameterizedTest
+ @EnumSource(value = ExecMode.class)
+ void testStreamReadEmptyTablePath(ExecMode execMode) throws Exception {
+ // create filesystem table named source
+ String createSource = TestConfigurations.getFileSourceDDL("source");
+ String createSource2 = TestConfigurations.getFileSourceDDL("source2",
"test_source_2.data");
+ streamTableEnv.executeSql(createSource);
+ streamTableEnv.executeSql(createSource2);
+
+ Map<String, String> options = new HashMap<>();
+ options.put(FlinkOptions.PATH.key(), tempFile.getAbsolutePath());
+ options.put(FlinkOptions.READ_AS_STREAMING.key(), "true");
+ options.put(FlinkOptions.TABLE_TYPE.key(),
FlinkOptions.TABLE_TYPE_MERGE_ON_READ);
+ String createHoodieTable =
TestConfigurations.getCreateHoodieTableDDL("t1", options);
+ streamTableEnv.executeSql(createHoodieTable);
+ String insertInto = "insert into t1 select * from source";
+ execInsertSql(streamTableEnv, insertInto);
+
+ // delete data under the table path
+ for (File file : Objects.requireNonNull(tempFile.listFiles(pathname ->
!pathname.getName().contains(".hoodie")))) {
+ FileUtils.forceDelete(file);
+ }
Review comment:
You can use `StreamerUtil#initTableIfNotExists(Configuration conf)` to
create an empty table, there is no need to insert then delete.
--
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]