-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
High memory usage reading single column with read_parquet
#15098
Comments
I can reproduce this locally, so I'll see if I can figure out what's going on. |
With With 3 columns, read of a single column So at first glance, this suggests columns that aren't named are still somehow being read by |
The implementation of |
Thank you for figuring this out! |
#15285) Co-authored-by: Itamar Turner-Trauring <[email protected]> Co-authored-by: Stijn de Gooijer <[email protected]>
Checks
Reproducible example
Copy the following into
example.py
Then run and compare the outputs of:
Log output
No response
Issue description
Similar to #8925, the behaviour of
scan_parquet/csv
andread_parquet/csv
for reading a single column is surprising. In particular, when reading a single column from a parquet file with 1/2 billion rows, usingread_parquet(filename, columns=[col_name])
takes nearly 4x the memory usage and 2x the time of callingscan_parquet(filename).select(col_name).collect()
.On the other hand,
read_csv
takes half the memory memory and around 5/6 the time than runningscan_csv.collect()
.Note that some of this may be due to the
rechunk
option, but settingrechunk=False
inread_parquet
still leads to higher memory and time usage thanscan_parquet.collect()
.Detailed table below generated by this gist on an M2 mac running macOS 14.3.1.
read_parquet(rechunk=True).sum
read_csv(rechunk=True).sum
read_parquet(rechunk=False).sum
read_csv(rechunk=False).sum
scan_parquet.collect.sum
scan_csv.collect.sum
scan_parquet.sum.collect
scan_csv.sum.collect
scan_parquet.sum.collect(streaming)
scan_csv.sum.collect(streaming)
Here the function names correspond to:
.collect.sum
:func(filename).select("a").collect().sum()
.sum.collect
:func(filename).select("a").sum().collect()
.sum.collect(streaming)
:func(filename).select("a").sum().collect(streaming=True)
Expected behavior
I would expect reading a single column of parquet with
read_parquet
to take less time but perhaps more memory thanscan_parquet().collect()
and similarly forread_csv
andscan_csv
.Installed versions
The text was updated successfully, but these errors were encountered: