[Variant] Add documentation, tests and cleaner api for Variant::get_path#7942
[Variant] Add documentation, tests and cleaner api for Variant::get_path#7942alamb merged 1 commit intoapache:mainfrom
Conversation
| 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.
This gives a good idea of what the new API looks like. I think it is much clearer personally
| /// | ||
| /// If the path is not found, `None` is returned. | ||
| /// | ||
| /// # Example |
There was a problem hiding this comment.
I really wanted to add these tests / examples which lead to the other API changes
alamb
left a comment
There was a problem hiding this comment.
FYI @Samyak2 @friendlymatthew and @scovich
| }; | ||
| use arrow_schema::{ArrowError, Field}; | ||
| use parquet_variant::path::VariantPath; | ||
| use parquet_variant::VariantPath; |
There was a problem hiding this comment.
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.
This is a much better API!
friendlymatthew
left a comment
There was a problem hiding this comment.
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.
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.
- Great idea -- filed [Variant]
impl FromIteratorfprVariantPath#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_getcompute kernel #7919Rationale for this change
While reviewing #7919 from @Samyak2 I found I wanted to write some additional tests directly for
Variant::get_pathWhen 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?
VaraintGetandVariantPathAre 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.