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: Support reading byte stream split encoded floats and doubles in parquet #17099

Merged
merged 10 commits into from
Jun 24, 2024

Conversation

adamreeve
Copy link
Contributor

@adamreeve adamreeve commented Jun 20, 2024

Fixes #17042

This PR adds support for reading Parquet files with float or double values that are encoded with the byte stream split encoding. I started out using the changes in jorgecarleitao/parquet2#221, but refactored the way the decoder worked to avoid needing to change the State enums for the basic and nested PrimitiveDecoder structs too much (I think these would have at least needed extra type parameters for the ParqueNativeType and converter function).

Version 2.11 of the Parquet format extended the byte stream split encoding to be valid for integer types and fixed length byte arrays, motivated by the addition of the float16 logical type which uses a 2-byte fixed length byte array physical type. But it looks like Polars doesn't support reading float16 data so I think for now it's fine to only handle floats and doubles.

This code doesn't handle when is_filtered is true in build_state, but I couldn't find any code path where that is used by Polars, and is_filtered == true also seems to be unimplemented for dictionary encoded data, so I assume this isn't necessary?

@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 Jun 20, 2024
Copy link
Member

@ritchie46 ritchie46 left a comment

Choose a reason for hiding this comment

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

Thanks. Looks great. I have left some comments.

@adamreeve
Copy link
Contributor Author

Thanks for the review, I've addressed those comments and also added a const for the max element size.

Copy link

codecov bot commented Jun 23, 2024

Codecov Report

Attention: Patch coverage is 98.67550% with 2 lines in your changes missing coverage. Please review.

Project coverage is 80.89%. Comparing base (8a6bf4b) to head (c95231c).
Report is 28 commits behind head on main.

Files Patch % Lines
...uet/src/arrow/read/deserialize/primitive/nested.rs 90.47% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17099      +/-   ##
==========================================
+ Coverage   80.86%   80.89%   +0.03%     
==========================================
  Files        1456     1458       +2     
  Lines      191141   191484     +343     
  Branches     2728     2742      +14     
==========================================
+ Hits       154562   154902     +340     
  Misses      36073    36073              
- Partials      506      509       +3     

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

@ritchie46 ritchie46 changed the title feat(python,rust): Support reading byte stream split encoded floats and doubles feat: Support reading byte stream split encoded floats and doubles in parquet Jun 24, 2024
@ritchie46
Copy link
Member

Alright. Thank you @adamreeve

@ritchie46 ritchie46 merged commit 4731834 into pola-rs:main Jun 24, 2024
27 checks passed
@adamreeve adamreeve deleted the byte_stream_split branch June 24, 2024 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support reading byte stream split encoded Parquet data
2 participants