Skip to content
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

Implement cudf-polars chunked parquet reading #16944

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
146ac45
access and config chunked parquet reader
brandon-b-miller Sep 10, 2024
0242495
do not early return df
brandon-b-miller Sep 16, 2024
e257242
Merge branch 'branch-24.12' into cudf-polars-chunked-parquet-reader
brandon-b-miller Oct 9, 2024
95ebf4d
fix nrows
brandon-b-miller Oct 9, 2024
7533ed3
Merge branch 'branch-24.12' into cudf-polars-chunked-parquet-reader
brandon-b-miller Oct 22, 2024
43acc47
Merge branch 'branch-24.12' into cudf-polars-chunked-parquet-reader
brandon-b-miller Oct 28, 2024
6ddf128
updates, set defaults
brandon-b-miller Oct 29, 2024
fea77d7
pass config through evaluate
brandon-b-miller Oct 30, 2024
53b0b2a
a trial commit to test a different concatenation strategy
brandon-b-miller Oct 31, 2024
ec298d3
merge/resolve
brandon-b-miller Nov 5, 2024
310f8c2
adjust for IR changes / pass tests
brandon-b-miller Nov 6, 2024
62c277b
address reviews
brandon-b-miller Nov 7, 2024
13df5aa
revert translate.py changes
brandon-b-miller Nov 7, 2024
4aee59f
Revert "a trial commit to test a different concatenation strategy"
brandon-b-miller Nov 7, 2024
50add3a
Merge branch 'branch-24.12' into cudf-polars-chunked-parquet-reader
brandon-b-miller Nov 8, 2024
a113737
add docs
brandon-b-miller Nov 8, 2024
828a3bb
merge/resolve
brandon-b-miller Nov 12, 2024
48d3edc
add test coverage
brandon-b-miller Nov 12, 2024
eacc73d
merge/resolve
brandon-b-miller Nov 13, 2024
9c4c1bf
raise on fail true for default testing engine
brandon-b-miller Nov 13, 2024
d6aa668
Apply suggestions from code review
brandon-b-miller Nov 13, 2024
a06f0ae
reword Parquet Reader Options
brandon-b-miller Nov 13, 2024
9930d2e
partially address reviews
brandon-b-miller Nov 13, 2024
b2530a4
Apply suggestions from code review
brandon-b-miller Nov 13, 2024
9958fe9
chunk on by default
brandon-b-miller Nov 13, 2024
d33ec5e
turn OFF chunking in existing parquet tests
brandon-b-miller Nov 13, 2024
b69eaa6
Merge branch 'branch-24.12' into cudf-polars-chunked-parquet-reader
galipremsagar Nov 13, 2024
2be2847
disable slice pushdown with parquet
brandon-b-miller Nov 13, 2024
e72215b
Merge branch 'branch-24.12' into HEAD
wence- Nov 14, 2024
c23afd9
Test parquet filters with chunking off and on
wence- Nov 14, 2024
df341ea
Implement workaround for #16186
wence- Nov 14, 2024
beb2462
xfail a polars test
wence- Nov 14, 2024
b398172
Apply suggestions from code review
brandon-b-miller Nov 15, 2024
2116d94
Merge branch 'branch-24.12' into cudf-polars-chunked-parquet-reader
galipremsagar Nov 15, 2024
e67614a
Remove commented code
wence- Nov 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion python/cudf_polars/cudf_polars/callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import rmm
from rmm._cuda import gpu

import cudf_polars.dsl.translate
from cudf_polars.dsl.translate import translate_ir

if TYPE_CHECKING:
Expand Down Expand Up @@ -174,7 +175,9 @@ def execute_with_cudf(
device = config.device
memory_resource = config.memory_resource
raise_on_fail = config.config.get("raise_on_fail", False)
if unsupported := (config.config.keys() - {"raise_on_fail"}):
parquet_options = config.config.get("parquet_options", {})
cudf_polars.dsl.translate.ir.parquet_options = parquet_options
brandon-b-miller marked this conversation as resolved.
Show resolved Hide resolved
if unsupported := (config.config.keys() - {"raise_on_fail", "parquet_options"}):
raise ValueError(
f"Engine configuration contains unsupported settings {unsupported}"
)
Expand Down
52 changes: 41 additions & 11 deletions python/cudf_polars/cudf_polars/dsl/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

from cudf_polars.typing import Schema

parquet_options: dict[str, Any] = {}

__all__ = [
"IR",
Expand Down Expand Up @@ -339,17 +340,46 @@ def evaluate(self, *, cache: MutableMapping[int, DataFrame]) -> DataFrame:
colnames[0],
)
elif self.typ == "parquet":
tbl_w_meta = plc.io.parquet.read_parquet(
plc.io.SourceInfo(self.paths),
columns=with_columns,
nrows=n_rows,
skip_rows=self.skip_rows,
)
df = DataFrame.from_table(
tbl_w_meta.tbl,
# TODO: consider nested column names?
tbl_w_meta.column_names(include_children=False),
)
if parquet_options.get("chunked", True):
reader = plc.io.parquet.ChunkedParquetReader(
plc.io.SourceInfo(self.paths),
columns=with_columns,
num_rows=n_rows,
skip_rows=self.skip_rows,
chunk_read_limit=parquet_options.get("chunk_read_limit", 0),
pass_read_limit=parquet_options.get("pass_read_limit", 1024000000),
)
chk = reader.read_chunk()
tbl = chk.tbl
names = chk.column_names()
concatenated_columns = tbl.columns()
while reader.has_next():
tbl = reader.read_chunk().tbl

for i in range(tbl.num_columns()):
concatenated_columns[i] = plc.concatenate.concatenate(
[concatenated_columns[i], tbl._columns[i]]
)
# Drop residual columns to save memory
tbl._columns[i] = None
vyasr marked this conversation as resolved.
Show resolved Hide resolved

df = DataFrame.from_table(
brandon-b-miller marked this conversation as resolved.
Show resolved Hide resolved
plc.Table(concatenated_columns),
names=names,
)
else:
tbl_w_meta = plc.io.parquet.read_parquet(
plc.io.SourceInfo(self.paths),
columns=with_columns,
num_rows=n_rows,
skip_rows=self.skip_rows,
)
df = DataFrame.from_table(
tbl_w_meta.tbl,
# TODO: consider nested column names?
tbl_w_meta.column_names(include_children=False),
)

elif self.typ == "ndjson":
json_schema: list[tuple[str, str, list]] = [
(name, typ, []) for name, typ in self.schema.items()
Expand Down
Loading