linhongliu-db opened a new pull request, #60421:
URL: https://github.com/apache/spark/pull/60421

   ### What changes were proposed in this pull request?
   
   `DataSourceUtils.shouldIgnoreCorruptFileException` returns true for every 
`RuntimeException` and
   `IOException`, which includes `SparkUpgradeException` (for example 
`INCONSISTENT_BEHAVIOR_CROSS_VERSION`
   from a datetime pattern or value that only the legacy parser accepts). So 
with
   `spark.sql.files.ignoreCorruptFiles=true`, the file is truncated at the 
first row that raises the
   upgrade error and the query silently returns partial data — even though the 
CSV/JSON parsers rethrow
   the upgrade error on purpose rather than turning it into a bad record.
   
   This PR stops treating a `SparkUpgradeException` (or a 
`ParquetDecodingException` wrapping one) as
   file corruption, so it is raised. A new conf
   `spark.sql.legacy.files.ignoreCorruptFilesSkipsUpgradeErrors` (default 
`false`) restores the previous
   behavior.
   
   ### Why are the changes needed?
   
   `ignoreCorruptFiles` silently drops valid rows (returns partial data) when a 
read raises an upgrade
   error, which is not file corruption.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, documented in `docs/sql-migration-guide.md`. Such a read now fails with 
the upgrade error
   instead of silently skipping the rest of the file. Set
   `spark.sql.legacy.files.ignoreCorruptFilesSkipsUpgradeErrors=true` to 
restore the old behavior.
   
   ### How was this patch tested?
   
   New `FileBasedDataSourceSuite` unit test asserting 
`shouldIgnoreCorruptFileException` returns false
   for a `SparkUpgradeException` and for a `ParquetDecodingException` wrapping 
one (and true under the
   legacy conf), while a plain decoding/runtime error still counts as 
corruption. Locally it passes and
   scalastyle is clean on JDK 21.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Isaac)
   
   This pull request and its description were written by Isaac.
   


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