xuzifu666 commented on code in PR #10297:
URL: https://github.com/apache/hudi/pull/10297#discussion_r1438077824


##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/table/action/commit/BaseSparkCommitActionExecutor.java:
##########
@@ -292,8 +294,16 @@ protected void 
setCommitMetadata(HoodieWriteMetadata<HoodieData<WriteStatus>> re
   @Override
   protected void commit(HoodieWriteMetadata<HoodieData<WriteStatus>> result) {
     context.setJobStatus(this.getClass().getSimpleName(), "Commit write status 
collect: " + config.getTableName());
-    commit(result.getWriteStatuses(), result, 
result.getWriteStats().isPresent()
-        ? result.getWriteStats().get() : 
result.getWriteStatuses().map(WriteStatus::getStat).collectAsList());
+    if (!config.getBoolean(WRITE_IGNORE_FAILED) && 
result.getWriteStatuses().filter(status -> status.getErrors().size() > 
0).count() > 0) {
+      WriteStatus writeStatus = result.getWriteStatuses().filter(status -> 
status.getErrors().size() > 0).collectAsList().get(0);
+      HashMap<HoodieKey, Throwable> errors = writeStatus.getErrors();
+      // get first one of error info to show error details
+      HoodieKey key = errors.keySet().iterator().next();
+      throw new HoodieException("Error writing record in the job", 
errors.get(key));
+    }
+    HoodieData<WriteStatus> filterResult = 
result.getWriteStatuses().filter(status -> status.getErrors().size() == 0);
+    commit(filterResult, result, result.getWriteStats().isPresent()

Review Comment:
   Yeah,+1



-- 
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: commits-unsubscr...@hudi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to