spark-test commented on code in PR #60689:
URL: https://github.com/apache/spark/pull/60689#discussion_r4623391981


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/text/TextFileFormat.scala:
##########
@@ -118,9 +118,6 @@ case class TextFileFormat()
       SerializableConfiguration.broadcast(sparkSession.sparkContext, 
hadoopConf)
     val perFileReader = readToUnsafeMem(broadcastedHadoopConf, requiredSchema, 
textOptions)
     val archiveReader = readArchive(broadcastedHadoopConf, requiredSchema, 
textOptions)
-    // A tar archive (always a single split, see `isSplitable`) is streamed 
entry by entry when
-    // archive reads are enabled; otherwise the file is read directly. Archive 
scanning is wired

Review Comment:
   **Nit (P3):** The first sentence of this deleted comment restates the 
dispatch below it, but the second does not. It records why the dispatch sits 
here: archive reads are wired into the V1 text source only, so the dispatch 
lives in `TextFileFormat.buildReader` rather than in a reader shared with the 
DSv2 text source. That is still true. `TextPartitionReaderFactory` reads each 
file with the same `HadoopFileLinesReader` or `HadoopFileWholeTextReader` that 
`readToUnsafeMem` uses, and it has no archive handling. With the comment gone, 
nothing in `TextFileFormat` says so. The Avro, JSON and XML readers keep the 
same note in their `readArchive` scaladoc (`AvroFileFormat.scala:182-183`, 
`JsonDataSource.scala:82-84` and `XmlDataSource.scala:80-81`). Consider 
restoring that sentence, for example in the `readArchive` scaladoc at 
`TextFileFormat.scala:130-136`, where the sibling readers keep theirs.
   
   **Verification:**
   - **Inspection:** Check that TextFileFormat's documentation states that only 
the V1 text read path supports archives, and that this matches the DSv2 text 
source, whose table, scan and partition reader factory have no archive handling.
   - **Inspection:** Compare TextFileFormat before and after the fix with 
comments stripped and confirm that the remaining code is identical.



##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/CSVFileFormat.scala:
##########
@@ -44,8 +44,7 @@ case class CSVFileFormat() extends TextBasedFileFormat with 
DataSourceRegister {
       options: Map[String, String],
       path: Path): Boolean = {
     val parsedOptions = getCsvOptions(sparkSession, options)
-    // A tar archive is decompressed/unpacked as a sequential stream, so it 
must be read as a
-    // single split rather than carved into byte ranges.
+    // An archive is read as one sequential stream (entry by entry), so it is 
never split.

Review Comment:
   **Nit (P3):** This sentence, now used in all five `isSplitable` archive 
branches, keeps tar's reason for every container, and the reason does not hold 
for zip. `SupportsArchiveFormat.openZipStream` is documented as opening a zip 
"by seeking, reading the central directory first": it builds a `ZipFile` over a 
seekable channel and opens each entry separately with 
`zipFile.getInputStream(entry)`. `openSevenZStream` also opens by seeking, and 
only then reads the entries in order through its cursor. Only `openTarStream` 
reads the whole archive as one forward stream. This PR's new comment at 
`ZipArchiveTestUtils.scala:61` also says that zip reads its central directory 
when the archive is opened. The never-split conclusion is right; only the 
reason misleads, for example into thinking a zip could be read from a 
non-seekable stream. A reason that holds for tar, zip and 7z:
   
   ```suggestion
       // An archive is read whole by one reader, entry by entry, so it is 
never split.
   ```
   
   The same sentence needs the same change at `AvroFileFormat.scala:75`, 
`JsonFileFormat.scala:45`, `TextFileFormat.scala:68` and 
`XmlFileFormat.scala:56`.
   
   **Verification:**
   - **Inspection:** Check that each of the five rewritten comments gives a 
reason that is true of every container isArchivePath admits (.tar, .tar.gz, 
.tgz, .zip and .7z), consistent with how SupportsArchiveFormat documents 
opening tar archives through one forward cursor and zip and 7z archives by 
seeking, and that no comment in the archive reader still says an archive in 
general is read as one sequential stream.
   - **Inspection:** Compare each edited file before and after the fix with 
comments stripped and confirm that the remaining code is identical.



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