alamb commented on code in PR #7740:
URL: https://github.com/apache/arrow-rs/pull/7740#discussion_r2162613664
##########
parquet-variant/src/builder.rs:
##########
@@ -148,189 +318,112 @@ fn make_room_for_header(buffer: &mut Vec<u8>,
start_pos: usize, header_size: usi
///
/// # Example: [`Variant::List`] of [`Variant::Object`]s
///
-/// THis example shows how to create an list of objects:
+/// This example shows how to create an list of objects:
/// ```json
/// [
-/// {
-/// "first_name": "Jiaying",
-/// "last_name": "Li"
-/// },
/// {
-/// "first_name": "Malthe",
-/// "last_name": "Karbo"
-/// }
+/// "id": 1,
+/// "type": "Cauliflower"
+/// },
+/// {
+/// "id": 2,
+/// "type": "Beets"
+/// }
/// ]
/// ```
+/// ```
+/// use parquet_variant::{Variant, VariantBuilder};
+/// let mut builder = VariantBuilder::new();
+///
+/// // Create a builder that will write elements to the list
+/// let mut list_builder = builder.new_list();
+///
+/// {
+/// let mut object_builder = list_builder.new_object();
+/// object_builder.append_value("id", 1);
+/// object_builder.append_value("type", "Cauliflower");
+/// object_builder.finish();
+/// }
+///
+/// {
+/// let mut object_builder = list_builder.new_object();
+/// object_builder.append_value("id", 2);
+/// object_builder.append_value("type", "Beets");
+/// object_builder.finish();
+/// }
+///
+/// list_builder.finish();
+/// // Finish the builder to get the metadata and value
+/// let (metadata, value) = builder.finish();
+/// // use the Variant API to verify the result
+/// let variant = Variant::try_new(&metadata, &value).unwrap();
+/// let Variant::List(variant_list) = variant else {
+/// panic!("unexpected variant type");
+/// };
+///
+/// let Variant::Object(obj1) = variant_list.get(0).unwrap() else {
+/// panic!("unexpected variant type");
+/// };
+///
+/// assert_eq!(
+/// obj1.field_by_name("id").unwrap(),
Review Comment:
I found this API really awkward too -- here is a suggestion on making it
better
- https://github.com/apache/arrow-rs/issues/7756
--
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]