sohailshk opened a new pull request, #41472:
URL: https://github.com/apache/beam/pull/41472

   Fixes #41471
   
   `beam.io.ReadFromCsv` and `apache_beam.dataframe.io.read_csv` return only 
the first part of a compressed file (`.csv.gz`, `.csv.bz2`, ...) and no error. 
With the 200-row file from the issue, the gzip copy gives 80 rows and the bzip2 
copy 53; the uncompressed file gives 200.
   
   The reader's restriction is a byte range taken from the file size on disk, 
while the file is read through a decompressing handle whose positions count 
decompressed bytes. The truncating handle stops claiming once it has read as 
many decompressed bytes as the compressed file has bytes.
   
   A compressed file cannot be restricted by byte range, so for these files the 
restriction that starts at offset 0 claims offset 0, reads the whole file 
through the decompressing handle and claims the rest of its range at the end. 
Any other restriction (only possible after a dynamic split; `ReadFromCsv` is 
splittable by default) is empty, and claiming offset 0 first means a split or 
checkpoint cannot give the file to a second restriction. Uncompressed files 
take the existing path.
   
   Test: `test_read_compressed_csv` (gzip, bzip2, gzip with `splittable=True`) 
fails on master (rows 39..99 missing for gzip, 26..99 for bzip2) and passes 
with the change; `test_read_compressed_csv_split` checks that a checkpoint 
cannot leave a residual starting at offset 0. `dataframe/io_test.py` passes on 
pandas 2.2.3 and 2.3.3.
   
   CHANGES.md updated.
   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us 
incorporate your contribution quickly and easily:
   
    - [x] Mention the appropriate issue in your description (for example: 
`addresses #123`), if applicable. This will automatically add a link to the 
pull request in the issue. If you would like the issue to automatically close 
on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
    - [x] Update `CHANGES.md` with noteworthy changes.
    - [ ] If this contribution is large, please file an Apache [Individual 
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more 
tips on [how to make review process 
smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewer-job-easier).
   


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

Reply via email to