sdf-jkl commented on code in PR #11232:
URL: https://github.com/apache/arrow-rs/pull/11232#discussion_r4389191241


##########
parquet-variant/src/path.rs:
##########
@@ -324,6 +324,32 @@ mod tests {
         assert_eq!(path, expected);
     }
 
+    #[test]
+    fn test_variant_path_bracket_field_ownership() {
+        let path = 
VariantPath::try_from(r#"[""]["plain"]["escaped\]field"]"#).unwrap();
+
+        match &path[0] {
+            VariantPathElement::Field {
+                name: Cow::Borrowed(name),
+            } => assert_eq!(*name, ""),
+            other => panic!("expected borrowed field, got {other:?}"),
+        }
+
+        match &path[1] {
+            VariantPathElement::Field {
+                name: Cow::Borrowed(name),
+            } => assert_eq!(*name, "plain"),
+            other => panic!("expected borrowed field, got {other:?}"),
+        }
+
+        match &path[2] {
+            VariantPathElement::Field {
+                name: Cow::Owned(name),
+            } => assert_eq!(name, "escaped]field"),
+            other => panic!("expected owned field, got {other:?}"),
+        }
+    }

Review Comment:
   Smth like these here could do:
   ```rust
   use VariantPathElement::Field;
   
   assert!(matches!(
       &path[..],
       [
           Field { name: Cow::Borrowed("") },
           Field { name: Cow::Borrowed("plain") },
           Field { name: Cow::Owned(escaped) },
           Field { name: Cow::Borrowed("a]b") },
       ] if escaped == "escaped]field"
   ));
   ```



-- 
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]

Reply via email to