xiarixiaoyao commented on a change in pull request #3203:
URL: https://github.com/apache/hudi/pull/3203#discussion_r740696192
##########
File path:
hudi-hadoop-mr/src/test/java/org/apache/hudi/hadoop/realtime/TestHoodieRealtimeRecordReader.java
##########
@@ -535,4 +548,211 @@ public void
testSchemaEvolutionAndRollbackBlockInLastLogFile(ExternalSpillableMa
arguments(ExternalSpillableMap.DiskMapType.ROCKS_DB, true, true)
);
}
+
+ @Test
+ public void testIncremetalWithOnlylog() throws Exception {
+ // initial commit
+ Schema schema =
HoodieAvroUtils.addMetadataFields(SchemaTestUtil.getEvolvedSchema());
+ HoodieTestUtils.init(hadoopConf, basePath.toString(),
HoodieTableType.MERGE_ON_READ);
+ String instantTime = "100";
+ final int numRecords = 1000;
+ File partitionDir = InputFormatTestUtil.prepareParquetTable(basePath,
schema, 1, numRecords, instantTime,
+ HoodieTableType.MERGE_ON_READ);
+ //FileCreateUtils.createDeltaCommit(basePath.toString(), instantTime);
+ createDeltaCommitFile(basePath, instantTime,"2016/05/01",
"2016/05/01/fileid0_1-0-1_100.parquet", "fileid0");
+ // Add the paths
+ FileInputFormat.setInputPaths(baseJobConf, partitionDir.getPath());
+
+ // insert new records to log file
+ try {
+ String newCommitTime = "102";
+ HoodieLogFormat.Writer writer =
+ InputFormatTestUtil.writeDataBlockToLogFile(partitionDir, fs,
schema, "fileid0", instantTime, newCommitTime,
+ numRecords, numRecords, 0);
+ writer.close();
+ createDeltaCommitFile(basePath, newCommitTime,"2016/05/01",
"2016/05/01/.fileid0_100.log.1_1-0-1", "fileid0");
+
+ InputFormatTestUtil.setupIncremental(baseJobConf, "101", 1);
+
+ HoodieParquetRealtimeInputFormat inputFormat = new
HoodieParquetRealtimeInputFormat();
+ inputFormat.setConf(baseJobConf);
+ InputSplit[] splits = inputFormat.getSplits(baseJobConf, 1);
+ assertTrue(splits.length == 1);
+ JobConf newJobConf = new JobConf(baseJobConf);
+ List<Schema.Field> fields = schema.getFields();
+ setHiveColumnNameProps(fields, newJobConf, false);
+ RecordReader<NullWritable, ArrayWritable> reader =
inputFormat.getRecordReader(splits[0], newJobConf, Reporter.NULL);
+ // use reader to read log file.
+ NullWritable key = reader.createKey();
+ ArrayWritable value = reader.createValue();
+ while (reader.next(key, value)) {
+ Writable[] values = value.get();
+ // check if the record written is with latest commit, here "101"
+ assertEquals(newCommitTime, values[0].toString());
+ key = reader.createKey();
+ value = reader.createValue();
+ }
+ reader.close();
+ } catch (IOException e) {
+ throw new HoodieException(e.getMessage(), e);
+ }
+ }
+
+ @Test
+ public void testIncremetalWithReplace() throws Exception {
Review comment:
yes will add test case for compaction,
--
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]