-
Notifications
You must be signed in to change notification settings - Fork 1k
[Variant] Rename batch_json_string_to_variant and batch_variant_to_json_string
#8161
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
Conversation
| fn with_json(&mut self, json: &str) -> Result<(), ArrowError>; | ||
| } | ||
|
|
||
| fn build_json(json: &Value, builder: &mut impl VariantBuilderExt) -> Result<(), ArrowError> { |
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.
Removed redundant build_json
| use base64::{engine::general_purpose, Engine as _}; | ||
| use chrono::Timelike; | ||
| use parquet_variant::{Variant, VariantList, VariantObject}; | ||
| use serde_json::Value; |
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.
Changes in this file are basically moving the doc to trait and function body to impl
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 @liamzwbao -- I think this is a really nice improvement (using traits is 👨🍳 👌 )
I took the liberty of renaming with_json to be append_json to be consistent with the other APIs but really this was very nicely done
cc @harshmotw-db and @scovich
|
|
||
| build_json(&json, builder)?; | ||
| Ok(()) | ||
| pub trait JsonToVariant { |
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.
This is quite clever
| Ok(()) | ||
| pub trait JsonToVariant { | ||
| /// Create a Variant from a JSON string | ||
| fn with_json(&mut self, json: &str) -> Result<(), ArrowError>; |
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 pleae call this append_json to be consistent with VariantBuilderExt::append_value ?
Also I think the convention of using with_* in these crates is for builder / fluent style APIs that take self (rather than &mut self)
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.
LGTM
|
Resolved conflicts, should be good to go now |
|
Thank you @liamzwbao and @scovich |
Which issue does this PR close?
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax.
batch_json_string_to_variantandbatch_variant_to_json_stringjson_to_variant #8144.Rationale for this change
What changes are included in this PR?
Use extension traits to wrap the json variant conversion function, and rename batch function to a more common name.
Are these changes tested?
Yes
Are there any user-facing changes?
The APIs of parquet-variant-json are changed