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

fix: Properly project unordered column in parquet prefiltered #20189

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
2 changes: 1 addition & 1 deletion crates/polars-io/src/parquet/read/read_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ fn rg_to_dfs_prefiltered(
hive::merge_sorted_to_schema_order(
&mut dead_columns.into_iter(), // df_columns
&mut live_columns.into_iter().skip(row_index.is_some() as usize), // hive_columns
schema,
&schema.try_project_indices(projection).unwrap(),
&mut merged,
);

Expand Down
26 changes: 25 additions & 1 deletion py-polars/tests/unit/io/test_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2588,4 +2588,28 @@ def test_utf8_verification_with_slice_20174() -> None:
)

f.seek(0)
pl.scan_parquet(f).head(1).collect()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄

assert_frame_equal(
pl.scan_parquet(f).head(1).collect(),
pl.Series("s", ["a"]).to_frame(),
)


def test_parquet_prefiltered_unordered_projection_20175() -> None:
df = pl.DataFrame(
[
pl.Series("a", [0], pl.Int64),
pl.Series("b", [0], pl.Int64),
]
)

f = io.BytesIO()
df.write_parquet(f)

f.seek(0)
out = (
pl.scan_parquet(f, parallel="prefiltered")
.filter(pl.col.a >= 0)
.select(["b", "a"])
.collect()
)
assert out.schema == pl.Schema({"b": pl.Int64, "a": pl.Int64})
Loading