-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[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
| 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
| /// | ||
| /// 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
alamb
left a comment
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
| }; | ||
| 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!
friendlymatthew
left a comment
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 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.