-
Notifications
You must be signed in to change notification settings - Fork 982
[Variant] Add documentation, tests and cleaner api for Variant::get_path #7942
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
@@ -133,29 +132,21 @@ mod test { | |||
fn get_primitive_variant_field() { | |||
single_variant_get_test( | |||
r#"{"some_field": 1234}"#, | |||
vec![VariantPathElement::field("some_field".into())].into(), | |||
VariantPath::from("some_field"), |
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 gives a good idea of what the new API looks like. I think it is much clearer personally
@@ -1068,6 +1072,35 @@ impl<'m, 'v> Variant<'m, 'v> { | |||
/// Return a new Variant with the path followed. | |||
/// | |||
/// If the path is not found, `None` is returned. | |||
/// | |||
/// # Example |
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.
I really wanted to add these tests / examples which lead to the other API changes
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.
FYI @Samyak2 @friendlymatthew and @scovich
@@ -22,7 +22,7 @@ use arrow::{ | |||
error::Result, | |||
}; | |||
use arrow_schema::{ArrowError, Field}; | |||
use parquet_variant::path::VariantPath; | |||
use parquet_variant::VariantPath; |
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.
I re-exported the paths at the same top level
VariantPathElement::field("some_field".into()), | ||
] | ||
.into(), | ||
VariantPath::from(0).join("some_field"), |
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 a much better API!
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.
Love the chaining -- looks very sleek
Thank you @friendlymatthew and @Samyak2 for the reviews |
/// let path3 = VariantPath::new(vec![ | ||
/// VariantPathElement::field("foo"), | ||
/// VariantPathElement::index(0) | ||
/// ]); |
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.
Should it also impl FromIterator
so people can do:
VariantPath::from_iter(["foo".into(), 0.into()])
or
["foo".into(), 0.into()].into_iter().collect::<VariantPath>()
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.
- Great idea -- filed [Variant]
impl FromIterator
fprVariantPath
#7955
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.
variant_get
compute kernel #7919Rationale for this change
While reviewing #7919 from @Samyak2 I found I wanted to write some additional tests directly for
Variant::get_path
When I started doing that I found it was somewhat awkward to write examples, so I added some new conversion routines to make it easier.
What changes are included in this PR?
VaraintGet
andVariantPath
Are these changes tested?
Yes, by doc examples which run in CI
Are there any user-facing changes?
If there are user-facing changes then we may require documentation to be updated before approving the PR.
If there are any breaking changes to public APIs, please call them out.