carpecodeum commented on code in PR #7946:
URL: https://github.com/apache/arrow-rs/pull/7946#discussion_r2216798292


##########
parquet-variant-compute/src/variant_array.rs:
##########
@@ -154,6 +155,172 @@ impl VariantArray {
     fn find_value_field(array: &StructArray) -> Option<ArrayRef> {
         array.column_by_name("value").cloned()
     }
+    /// Extract a field from the variant at the specified row using a path.
+    ///
+    /// This method provides direct access to nested fields without 
reconstructing
+    /// the entire variant, which is critical for performance with shredded 
variants.
+    ///
+    /// # Arguments
+    /// * `index` - The row index in the array
+    /// * `path` - The path to the field to extract
+    ///
+    /// # Returns
+    /// * `Some(Variant)` if the field exists at the specified path
+    /// * `None` if the field doesn't exist or the path is invalid
+    ///
+    /// # Example
+    /// ```
+    /// # use parquet_variant_compute::{VariantArrayBuilder, VariantArray, 
VariantPath};
+    /// # use parquet_variant::VariantBuilder;
+    /// # let mut builder = VariantArrayBuilder::new(1);
+    /// # let mut variant_builder = VariantBuilder::new();
+    /// # let mut obj = variant_builder.new_object();
+    /// # obj.insert("name", "Alice");
+    /// # obj.finish().unwrap();
+    /// # let (metadata, value) = variant_builder.finish();
+    /// # builder.append_variant_buffers(&metadata, &value);
+    /// # let variant_array = builder.build();
+    /// let path = VariantPath::field("name");
+    /// let name_variant = variant_array.get_path(0, &path);
+    /// ```
+    pub fn get_path(&self, index: usize, path: &VariantPath) -> 
Option<Variant> {

Review Comment:
   its quite similar, I started working on it, and didn't realise that the idea 
is very similar to PR 7919 until Wednesday. I'm working on making a lot of 
changes here and removing the redundancy between my PR and the variant_get 
functionality, which might include the tests and examples in this PR itself, 
also will try to do the optimisations for variant_get



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to