You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2025/06/23 22:16:36 UTC

[I] [Variant] Improved API for accessing Variant Objects and lists [arrow-rs]

alamb opened a new issue, #7756:
URL: https://github.com/apache/arrow-rs/issues/7756

   **Is your feature request related to a problem or challenge? Please describe what you are trying to do.**
   
   After @scovich's PR  to validate objects on construction
   - https://github.com/apache/arrow-rs/pull/7704
   
   I expected to be able to use the APIs for variant without havin to check for errors. Also I found the `field_by_name` very confusing as I expected  `get()` to retrieve a field of a Variant object but instead it was called `field_by_name`. 
   
   
   **Describe the solution you'd like**
   I want APIs that are  infallible (don't return errors) so they are easier to work with
   
   
   **Describe alternatives you've considered**
   
   I would personally like to write
   ```rust
   let variant_object = variant.as_object().unwrap()
   // retrieve the value from a field as Option<Variant>
   assert_eq!(variant_object.get("my_field"), Some(Variant::from("foo")));
   // non existent fields return None
   assert_eq!(variant_object.get("my_non_existent)field"), None);
   ```
   
   Likewise for VariantLists I would like to do
   ```rust
   let variant_list = variant.as_list().unwrap();
   // retrieve item at index 1
   assert_eq!(variant_list.get(1), Some(Variant::from("foo")));
   /// non existent items return None (like Rust slices)
   assert_eq!(variant_list.get(100), None);
   ```
   
   
   
   **Additional context**
   I noticed this while working on 
   - https://github.com/apache/arrow-rs/pull/7755
   
   


-- 
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-unsubscribe@arrow.apache.org.apache.org

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


Re: [I] [Variant] Improved API for accessing Variant Objects and lists [arrow-rs]

Posted by "friendlymatthew (via GitHub)" <gi...@apache.org>.
friendlymatthew commented on issue #7756:
URL: https://github.com/apache/arrow-rs/issues/7756#issuecomment-2998131829

   take


-- 
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-unsubscribe@arrow.apache.org

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


Re: [I] [Variant] Improved API for accessing Variant Objects and lists [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on issue #7756:
URL: https://github.com/apache/arrow-rs/issues/7756#issuecomment-3130009416

   `label_issue.py` automatically added labels {'parquet'} from #7757


-- 
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-unsubscribe@arrow.apache.org

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