-
Notifications
You must be signed in to change notification settings - Fork 689
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 OPTIONAL column in parquet_derive #5717
Conversation
345991c
to
7caee7c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me -- thank you @double-free and sorry for the delay in review
I had one small request to update the comments. Let me know what you think
@@ -248,7 +248,13 @@ impl Field { | |||
let write_batch_expr = quote! { | |||
let mut vals = Vec::new(); | |||
if let #column_reader(mut typed) = column_reader { | |||
typed.read_records(num_records, None, None, &mut vals)?; | |||
let mut definition_levels = Vec::new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please also update the documentation above
/// `Option` types and references not supported
To reflect this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can make it explicit, but to align our understanding, I want to note that this change does NOT mean it supports Option<T>
in the struct to be decoded.
It is to support fields that are marked as "optional" in schema, but in fact all values are non-null. This is very common when parsing parquet files generated by pyarrow
, since by default all columns are optional. I reproduced it in unit test, by adding Option<T>
in the struct to be encoded.
So this comment is still true, but I can make it explicit for the case I mentioned above:
/// `Option` types and references not supported, but the column itself can be nullable (i.e., def_level==1), as long as the values are all valid.
How do you think? To update the comment or keep it as it is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
Thanks for your response! Please check my reply and see if we do need to update the code comment. |
Thanks again @double-free |
Which issue does this PR close?
Closes #5716.
Rationale for this change
See details in the issue.
What changes are included in this PR?
Add definition level in macro code.
Are there any user-facing changes?
No API change, extend parquet_derive to handle OPTIONAL columns.