klion26 commented on code in PR #9276:
URL: https://github.com/apache/arrow-rs/pull/9276#discussion_r2846363070
##########
parquet-variant/src/path.rs:
##########
@@ -69,11 +69,21 @@ use crate::utils::parse_path;
/// # use parquet_variant::{VariantPath, VariantPathElement};
/// /// You can access the paths using slices
/// // access the field "foo" and then the first element in a variant list
value
-/// let path = VariantPath::from("foo")
+/// let path = VariantPath::try_from("foo").unwrap()
/// .join("bar")
/// .join("baz");
/// assert_eq!(path[1], VariantPathElement::field("bar"));
/// ```
+///
+/// # Example: Accessing filed with bracket
+/// ```
+/// # use parquet_variant::{VariantPath, VariantPathElement};
+/// let path = VariantPath::try_from("a[b.c].d[2]").unwrap();
Review Comment:
currently, `[2]` -> Index, and `['2']` is Path, (relies on
`unescaped.parse()` to determine whether it's index)
The code below will print `VariantPath([Field { name: "'3'"
}]):::VariantPath([Index { index: 3 }])`
```
let path = VariantPath::try_from("[3]").unwrap();
let p = VariantPath::try_from("['3']").unwrap();
println!("{:?}:::{:?}", p, path);
```
2 `a.foo` equals to `a['foo']`, but leading '.'(`.foo`) will throw an error
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]