shardulm94 commented on a change in pull request #1957:
URL: https://github.com/apache/iceberg/pull/1957#discussion_r546178998



##########
File path: 
spark/src/main/java/org/apache/iceberg/spark/source/BaseDataReader.java
##########
@@ -56,6 +56,7 @@
 
   private CloseableIterator<T> currentIterator;
   private T current = null;
+  private FileScanTask currentTask = null;

Review comment:
       Not really, does it matter if it is in the constructor? It is going to 
be set to null in the constructor anyway. Similar to the `current` variable 
above it.

##########
File path: 
spark/src/main/java/org/apache/iceberg/spark/source/BaseDataReader.java
##########
@@ -77,16 +78,30 @@
   }
 
   public boolean next() throws IOException {
-    while (true) {
-      if (currentIterator.hasNext()) {
-        this.current = currentIterator.next();
-        return true;
-      } else if (tasks.hasNext()) {
-        this.currentIterator.close();
-        this.currentIterator = open(tasks.next());
+    try {
+      while (true) {
+        if (currentIterator.hasNext()) {
+          this.current = currentIterator.next();
+          return true;
+        } else if (tasks.hasNext()) {
+          this.currentIterator.close();
+          this.currentTask = tasks.next();
+          this.currentIterator = open(currentTask);
+        } else {
+          this.currentIterator.close();
+          return false;
+        }
+      }
+    } catch (IOException | RuntimeException e) {
+      if (currentTask == null || currentTask.isDataTask()) {
+        throw e;
       } else {
-        this.currentIterator.close();
-        return false;
+        String message = String.format("Error reading file: %s", 
getInputFile(currentTask).location());
+        if (e instanceof IOException) {
+          throw new IOException(message, e);
+        } else {
+          throw new RuntimeException(message, e);
+        }

Review comment:
       Done




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



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

Reply via email to