manuzhang commented on code in PR #14618:
URL: https://github.com/apache/iceberg/pull/14618#discussion_r2544171987


##########
kafka-connect/kafka-connect/src/main/java/org/apache/iceberg/connect/data/IcebergWriter.java:
##########
@@ -56,22 +67,51 @@ private void initNewWriter() {
   }
 
   @Override
-  public void write(SinkRecord record) {
+  public void write(SinkRecord record) throws DataException {
     try {
       // ignore tombstones...
       if (record.value() != null) {
-        Record row = convertToRow(record);
-        writer.write(row);
+        Record row = null;
+        try {
+          row = convertToRow(record);
+        } catch (Exception e) {
+          String recordData = "";
+          if (this.config.errorLogIncludeMessages()) {
+            recordData = String.format(", record: %s", 
record.value().toString());
+          }
+          DataException ex =
+            new DataException(
+              String.format(
+                      Locale.ROOT,
+                      "topic: %s, partition, %d, offset: %d %s",
+                      record.topic(),
+                      record.kafkaPartition(),
+                      record.kafkaOffset(),
+                      recordData),
+              e);
+          if 
(this.config.errorTolerance().equalsIgnoreCase(ErrorTolerance.ALL.toString())) {
+            if (this.dlqReporter != null) {
+              this.dlqReporter.send(record);
+            }
+            LOG.error("An error occurred converting record...", ex);
+          } else {
+            throw ex;
+          }
+        }
+        if (row != null) {
+          writer.write(row);
+        }
       }
     } catch (Exception e) {
       throw new DataException(
-          String.format(
-              Locale.ROOT,
-              "An error occurred converting record, topic: %s, partition, %d, 
offset: %d",
-              record.topic(),
-              record.kafkaPartition(),
-              record.kafkaOffset()),
-          e);
+              String.format(

Review Comment:
   unneeded indent change.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to