lokeshj1703 commented on code in PR #13307:
URL: https://github.com/apache/hudi/pull/13307#discussion_r2126253034


##########
hudi-spark-datasource/hudi-spark-common/src/main/java/org/apache/hudi/DataSourceUtils.java:
##########
@@ -344,4 +350,47 @@ public static JavaRDD<HoodieRecord> 
resolveDuplicates(JavaSparkContext jssc,
     return handleDuplicates(
         new HoodieSparkEngineContext(jssc), incomingHoodieRecords, 
writeConfig, failOnDuplicates);
   }
+
+  /**
+   * Callback for WriteStatus Handler.
+   * If there are error records, we print few of them and exit.
+   * If not, we proceed with the commit.
+   */
+  static class SparkDataSourceWriteStatusHandlerCallback implements 
WriteStatusHandlerCallback {
+
+    private final WriteOperationType writeOperationType;
+    private final AtomicBoolean hasErrored;
+
+    public SparkDataSourceWriteStatusHandlerCallback(WriteOperationType 
writeOperationType, AtomicBoolean hasErrored) {
+      this.writeOperationType = writeOperationType;
+      this.hasErrored = hasErrored;
+    }
+
+    @Override
+    public boolean processWriteStatuses(long totalRecords, long 
totalErroredRecords, Option<HoodieData<WriteStatus>> writeStatusesOpt) {
+      if (totalErroredRecords > 0) {
+        hasErrored.set(true);
+        ValidationUtils.checkArgument(writeStatusesOpt.isPresent(), "RDD 
<WriteStatus> expected to be present when there are errors");
+        LOG.error("%s failed with errors", writeOperationType);

Review Comment:
   Addressed



-- 
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