klion26 opened a new issue, #10982: URL: https://github.com/apache/arrow-rs/issues/10982
By calling `variant_to_string` recursively we drop the `Variant::Object` values inside a list. arrow-cast doesn't support Objects -> String, but supports them inside a List [via `ArrayFormatter`](https://github.com/apache/arrow-rs/blob/70219af2ffa16615e2fcde5760b0218f5c986ac6/arrow-cast/src/display.rs#L1244-L1261) 🤷 (separate issue maybe?) regardless of correctness of the Object support above, variant-cast to String shouldn't lose data. ```rust #[test] fn reproduce_list_of_objects_utf8_difference() { // Build the Variant value: [{"x": 1}] let mut variant_builder = VariantBuilder::new(); let mut variant_list = variant_builder.new_list(); variant_list .new_object() .with_field("x", 1_i32) .finish(); variant_list.finish(); let (metadata, value) = variant_builder.finish(); let variant = Variant::new(&metadata, &value); // Current #10114 result let variant_output = variant_to_string(&variant).unwrap(); // Build the equivalent Arrow List<Struct<x: Int32>> let fields = vec![Field::new("x", DataType::Int32, true)]; let struct_builder = StructBuilder::from_fields(fields, 1); let mut arrow_list = ListBuilder::new(struct_builder); let struct_builder = arrow_list.values(); struct_builder .field_builder::<Int32Builder>(0) .unwrap() .append_value(1); struct_builder.append(true); arrow_list.append(true); let arrow_list = arrow_list.finish(); // Arrow List<Struct> → Utf8 result let casted = cast(&arrow_list, &DataType::Utf8).unwrap(); let arrow_output = casted.as_string::<i32>().value(0); assert_eq!(variant_output, "[]"); assert_eq!(arrow_output, "[{x: 1}]"); // Fails assert_eq!(variant_output, arrow_output); } ``` _Originally posted by @sdf-jkl in https://github.com/apache/arrow-rs/pull/10114#discussion_r3908535499_ -- 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]
