pengzhiwei2018 commented on a change in pull request #2296:
URL: https://github.com/apache/hudi/pull/2296#discussion_r568677443
##########
File path:
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestCOWDataSource.scala
##########
@@ -320,4 +320,21 @@ class TestCOWDataSource extends HoodieClientTestBase {
assertTrue(HoodieDataSourceHelpers.hasNewCommits(fs, basePath, "000"))
}
+
+ @Test def testWithEmptyInput(): Unit = {
+ val inputDF1 =
spark.read.json(spark.sparkContext.parallelize(Seq.empty[String], 1))
+ inputDF1.write.format("org.apache.hudi")
+ .options(commonOpts)
+ .option(DataSourceWriteOptions.OPERATION_OPT_KEY,
DataSourceWriteOptions.INSERT_OPERATION_OPT_VAL)
+ .mode(SaveMode.Overwrite)
+ .save(basePath)
+ assertTrue(HoodieDataSourceHelpers.hasNewCommits(fs, basePath, "000"))
Review comment:
The empty commits has skip now. And the test case has fixed @nsivabalan
@garyli1019 . Please take a look when you have time. Thanks~
##########
File path:
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/AbstractHoodieWriteClient.java
##########
@@ -173,6 +173,10 @@ public boolean commitStats(String instantTime,
List<HoodieWriteStat> stats, Opti
public boolean commitStats(String instantTime, List<HoodieWriteStat> stats,
Option<Map<String, String>> extraMetadata,
String commitActionType, Map<String,
List<String>> partitionToReplaceFileIds) {
+ // Skip the empty commit
+ if (stats.isEmpty()) {
Review comment:
Hi @garyli1019 , it is just a java list#isEmpty here ,so it should has
no impact for the performance. In our previous implement, we use the
RDD#isEmpty to skip the empty commit, It is a heavy operation.
##########
File path:
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/table/action/compact/TestHoodieCompactor.java
##########
@@ -186,7 +191,7 @@ public void testWriteStatusContentsAfterCompaction() throws
Exception {
for (String partitionPath : dataGen.getPartitionPaths()) {
List<WriteStatus> writeStatuses = result.collect();
assertTrue(writeStatuses.stream()
- .filter(writeStatus ->
writeStatus.getStat().getPartitionPath().contentEquals(partitionPath)).count()
> 0);
+ .filter(writeStatus1 ->
writeStatus1.getStat().getPartitionPath().contentEquals(partitionPath)).count()
> 0);
Review comment:
Thanks for the suggestion!
----------------------------------------------------------------
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]