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

feat: Add allow_missing_columns option to read/scan_parquet #18922

Merged
merged 4 commits into from
Sep 27, 2024

Conversation

nameexhaustion
Copy link
Collaborator

@nameexhaustion nameexhaustion commented Sep 25, 2024

Let me know if there is a better name for this parameter

@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars labels Sep 25, 2024
Copy link

codecov bot commented Sep 25, 2024

Codecov Report

Attention: Patch coverage is 50.31847% with 78 lines in your changes missing coverage. Please review.

Project coverage is 80.03%. Comparing base (011e366) to head (9701b30).
Report is 38 commits behind head on main.

Files with missing lines Patch % Lines
...tream/src/nodes/parquet_source/row_group_decode.rs 0.00% 54 Missing ⚠️
crates/polars-io/src/parquet/read/read_impl.rs 78.72% 10 Missing ⚠️
...-stream/src/nodes/parquet_source/metadata_fetch.rs 0.00% 10 Missing ⚠️
...m/src/nodes/parquet_source/row_group_data_fetch.rs 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #18922      +/-   ##
==========================================
+ Coverage   79.88%   80.03%   +0.14%     
==========================================
  Files        1521     1523       +2     
  Lines      206849   208786    +1937     
  Branches     2906     2906              
==========================================
+ Hits       165238   167092    +1854     
- Misses      41063    41146      +83     
  Partials      548      548              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -384,20 +391,30 @@ fn rg_to_dfs_prefiltered(
.then(|| calc_prefilter_cost(&filter_mask))
.unwrap_or_default();

#[cfg(debug_assertions)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: if cfg!(debug_assertions)

@nameexhaustion
Copy link
Collaborator Author

I bumped the minor version for NodeTraverser as this exposes a new field in FileScanOptions

@coastalwhite
Copy link
Collaborator

I feel like strict_schema is a better name for this, but that is a bit subjective

@alexander-beedie
Copy link
Collaborator

How about allow_missing_columns?

Including the word "rows" in the parameter name feels a bit off, as it's really a column-oriented parameter 🤔

@ritchie46
Copy link
Member

How about allow_missing_columns?

Yeah, let's go for that one. And default to False.

@coastalwhite
Copy link
Collaborator

I think this should also be added to read_parquet if possible

@nameexhaustion nameexhaustion changed the title feat: Add null_rows_for_missing_columns option to scan_parquet feat: Add allow_missing_columns option to read/scan_parquet Sep 26, 2024
@nameexhaustion
Copy link
Collaborator Author

I think this should also be added to read_parquet if possible

I present a magic trick that adds it by changing the title of the PR 😀

@nameexhaustion
Copy link
Collaborator Author

Some technical detail - we do this by making our decode functions (i.e. row_groups_to_dfs) always return empty columns if the column is not found. The control over this behavior is done one level higher when you configure the parquet reader - it checks the schema of the file depending on the allow_missing_columns parameter

@nameexhaustion nameexhaustion deleted the pq-empty-rows-for-missing-cols branch September 27, 2024 08:08
@nameexhaustion nameexhaustion restored the pq-empty-rows-for-missing-cols branch September 27, 2024 10:02
@ritchie46
Copy link
Member

Nice, can we also refer to the solution in the error when the schema resolving fails in strict mode?

@ritchie46 ritchie46 merged commit 13e9717 into pola-rs:main Sep 27, 2024
54 of 55 checks passed
@c-peters c-peters added the accepted Ready for implementation label Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants