You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "COLDMANYU (via GitHub)" <gi...@apache.org> on 2026/10/21 08:50:48 UTC

[PR] [core] Apply scan.ignore-corrupt-files to failures while iterating rows [paimon]

COLDMANYU opened a new pull request, #10716:
URL: https://github.com/apache/paimon/pull/10716

   ### Purpose
   
   `scan.ignore-corrupt-files` only catches failures while a file is opened and while
   `readBatch()` is called. Row-based formats (CSV, JSON, TEXT, Avro) return a lazy iterator from
   `readBatch()` and do the actual decoding in `next()`, so a file that is corrupt in the middle
   escapes the option and fails the whole query.
   
   A common case is a truncated gzip file in a Format Table: the file opens fine, and
   `java.io.EOFException: Unexpected end of input stream` is only thrown when decompression reaches
   the cut. Spark's `spark.sql.files.ignoreCorruptFiles` does not help either, because a Paimon
   Format Table is read by Paimon's own reader rather than Spark's file scan.
   
   This PR makes `DataFileRecordReader` also guard the iterator it returns when
   `scan.ignore-corrupt-files` is enabled. When `next()`/`skip()` fails with an exception the option
   already treats as corruption, the rows returned so far are kept, a warning is logged, and the rest
   of the file is skipped. This matches the semantics of Spark's `ignoreCorruptFiles`.
   
   Notes:
   - Nothing changes when the option is disabled (the default): the iterator is not wrapped.
   - Columnar iterators (`ColumnarRowIterator`, Parquet/ORC/...) are left unwrapped. They are fully
     materialized in `readBatch()`, which is already covered, and callers detect vectorized batches
     by their type.
   - The set of exceptions treated as corruption is unchanged.
   
   ### Tests
   
   - `FormatTableIgnoreCorruptFilesTest` (new): a Format Table with a gzip file truncated in the
     middle plus an intact file, for CSV and JSON. Without the option the read fails with
     `EOFException`; with the option the rows before the cut and all rows of the intact file are
     returned. The test fails on master and passes with this 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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [core] Apply scan.ignore-corrupt-files to failures while iterating rows [paimon]

Posted by "Akash3121 (via GitHub)" <gi...@apache.org>.
Akash3121 commented on code in PR #10716:
URL: https://github.com/apache/paimon/pull/10716#discussion_r4372612272


##########
paimon-core/src/main/java/org/apache/paimon/io/DataFileRecordReader.java:
##########
@@ -256,4 +270,76 @@ private static boolean ignoreCorruptException(Throwable e, boolean ignoreCorrupt
                         || e instanceof RuntimeException
                         || e instanceof InternalError);
     }
+
+    /**
+     * Row-based formats (CSV, JSON, TEXT, Avro, ...) decode lazily in {@link #next()}, so a file
+     * that is truncated or corrupt in the middle only fails after {@link #readBatch()} returned.
+     * This iterator extends {@code scan.ignore-corrupt-files} to that point: the rows already
+     * returned are kept and the rest of the file is skipped.
+     */
+    private class IgnoreCorruptFileRecordIterator implements FileRecordIterator<InternalRow> {
+
+        private final FileRecordIterator<InternalRow> iterator;
+
+        private IgnoreCorruptFileRecordIterator(FileRecordIterator<InternalRow> iterator) {
+            this.iterator = iterator;
+        }
+
+        @Nullable
+        @Override
+        public InternalRow next() throws IOException {
+            if (corrupted) {
+                return null;
+            }
+            try {
+                return iterator.next();
+            } catch (Exception e) {
+                return handleCorruptException(e, null);

Review Comment:
   `ignoreCorruptException` includes `InternalError` (notably `ZipError`), but this catch only intercepts `Exception`, so that supported corrupt-file failure still escapes and aborts the scan. Could we catch the same throwable set here (and in `skip()`), with a regression test using `ZipError`?



-- 
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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [core] Apply scan.ignore-corrupt-files to failures while iterating rows [paimon]

Posted by "COLDMANYU (via GitHub)" <gi...@apache.org>.
COLDMANYU commented on code in PR #10716:
URL: https://github.com/apache/paimon/pull/10716#discussion_r4373645420


##########
paimon-core/src/main/java/org/apache/paimon/io/DataFileRecordReader.java:
##########
@@ -256,4 +270,76 @@ private static boolean ignoreCorruptException(Throwable e, boolean ignoreCorrupt
                         || e instanceof RuntimeException
                         || e instanceof InternalError);
     }
+
+    /**
+     * Row-based formats (CSV, JSON, TEXT, Avro, ...) decode lazily in {@link #next()}, so a file
+     * that is truncated or corrupt in the middle only fails after {@link #readBatch()} returned.
+     * This iterator extends {@code scan.ignore-corrupt-files} to that point: the rows already
+     * returned are kept and the rest of the file is skipped.
+     */
+    private class IgnoreCorruptFileRecordIterator implements FileRecordIterator<InternalRow> {
+
+        private final FileRecordIterator<InternalRow> iterator;
+
+        private IgnoreCorruptFileRecordIterator(FileRecordIterator<InternalRow> iterator) {
+            this.iterator = iterator;
+        }
+
+        @Nullable
+        @Override
+        public InternalRow next() throws IOException {
+            if (corrupted) {
+                return null;
+            }
+            try {
+                return iterator.next();
+            } catch (Exception e) {
+                return handleCorruptException(e, null);

Review Comment:
   Good catch, thanks! `InternalError` was never reachable there: every catch site only caught `Exception`, so the `InternalError` branch of `ignoreCorruptException` was dead code. This was already true of the two existing sites in `createReader()` and `readBatch()`, and I copied the same pattern into the new ones.
   
   I've fixed it in all of them:
   
   - `DataFileRecordReader`: `createReader()`, `readBatch()`, and the iterator's `next()` and `skip()` now catch `Exception | InternalError`.
   - `FormatReadBuilder`: the reader creation catch does the same.
   
   `InternalError` is only caught so that it can be ignored. When `scan.ignore-corrupt-files` is disabled, it is rethrown unchanged, so the default behavior stays the same. Other `Error`s, such as `OutOfMemoryError`, are still not caught.
   
   This also matches Spark. Since SPARK-52482 (4.1.0), `FileScanRDD` uses `DataSourceUtils.shouldIgnoreCorruptFileException`, which treats `RuntimeException | IOException | InternalError` as corruption. That change was made for the same reason: a corrupt zstd header throws `java.lang.InternalError: Unknown frame descriptor`.
   
   I added `testZipErrorWhileReading` and `testZipErrorAtOpen` (CSV and JSON). They use a `FileIO` that throws `ZipError` either while the file is being read or when it is opened. Without the option, the `ZipError` propagates. With the option, the corrupt file is skipped and the intact file is still read completely. Both tests fail without this 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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [core] Apply scan.ignore-corrupt-files to failures while iterating rows [paimon]

Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi merged PR #10716:
URL: https://github.com/apache/paimon/pull/10716


-- 
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: issues-unsubscribe@paimon.apache.org

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