ankurdave commented on a change in pull request #34369:
URL: https://github.com/apache/spark/pull/34369#discussion_r734840380



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FileScanRDD.scala
##########
@@ -128,15 +139,21 @@ class FileScanRDD(
           // Sets InputFileBlockHolder for the file block's information
           InputFileBlockHolder.set(currentFile.filePath, currentFile.start, 
currentFile.length)
 
+          resetCurrentIterator()
           if (ignoreMissingFiles || 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()
+              // vectorized Parquet reader. Here we use a lazily initialized 
variable to delay the
+              // creation of iterator so that we will throw exception in 
`getNext`.
+              private var internalIter: Iterator[InternalRow] = null

Review comment:
       If the downstream operator never pulls any rows from the iterator, then 
the first time we access `internalIter` will be when `close()` is called. If 
`internalIter` is a `lazy val`, this will trigger a call to 
`readCurrentFile()`, which is unnecessary and may throw. Changing 
`internalIter` from a `lazy val` to a `var` lets us avoid this unnecessary call.
   
   Several tests fail without this change, including `AvroV1Suite`.




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