Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17253#discussion_r105526080
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FileScanRDD.scala
 ---
    @@ -130,54 +144,35 @@ class FileScanRDD(
               // Sets InputFileBlockHolder for the file block's information
               InputFileBlockHolder.set(currentFile.filePath, 
currentFile.start, currentFile.length)
     
    -          try {
    -            if (ignoreCorruptFiles) {
    -              currentIterator = new NextIterator[Object] {
    -                private val internalIter = {
    -                  try {
    -                    // The readFunction may read files before consuming 
the iterator.
    -                    // E.g., vectorized Parquet reader.
    -                    readFunction(currentFile)
    -                  } catch {
    -                    case e @(_: RuntimeException | _: IOException) =>
    -                      logWarning(s"Skipped the rest content in the 
corrupted file: $currentFile", e)
    -                      Iterator.empty
    -                  }
    -                }
    -
    -                override def getNext(): AnyRef = {
    -                  try {
    -                    if (internalIter.hasNext) {
    -                      internalIter.next()
    -                    } else {
    -                      finished = true
    -                      null
    -                    }
    -                  } catch {
    -                    case e: IOException =>
    -                      logWarning(s"Skipped the rest content in the 
corrupted file: $currentFile", e)
    -                      finished = true
    -                      null
    +          if (ignoreCorruptFiles) {
    +            currentIterator = new NextIterator[Object] {
    +              // The readFunction may read some bytes before consuming the 
iterator, e.g.,
    +              // vectorized Parquet reader. Here we use lazy val to delay 
the creation of
    +              // iterator so that we will throw exception in `getNext`.
    +              private lazy val internalIter = readCurrentFile()
    +
    +              override def getNext(): AnyRef = {
    +                try {
    +                  if (internalIter.hasNext) {
    +                    internalIter.next()
    +                  } else {
    +                    finished = true
    +                    null
                       }
    +                } catch {
    +                  // Throw FileNotFoundException even `ignoreCorruptFiles` 
is true
    +                  case e: java.io.FileNotFoundException => throw e
    --- End diff --
    
    `FileNotFoundException` extends `IOException`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to