sdf-jkl opened a new issue, #10651:
URL: https://github.com/apache/arrow-rs/issues/10651

   ### Describe the bug
   
   Primitive cast errors from `variant_get` hardcode the path as 
`VariantPath([])`.
   
   The value is extracted before being passed to the primitive conversion 
builder, so the builder no longer knows the original path requested by the 
caller.
   
   The diagnostic also exposes the Variant value's internal `Debug` 
representation. There is an existing TODO to format this more cleanly.
   
   ### To Reproduce
   
   ```rust
   use std::sync::Arc;
   
   use arrow::array::{ArrayRef, StringArray};
   use arrow::compute::CastOptions;
   use arrow::datatypes::{DataType, Field};
   use parquet_variant::VariantPath;
   use parquet_variant_compute::{GetOptions, json_to_variant, variant_get};
   
   #[test]
   fn variant_get_cast_error_loses_requested_path() {
       let input: ArrayRef =
           Arc::new(StringArray::from(vec![r#"{"a":"n/a"}"#]));
       let variant = ArrayRef::from(json_to_variant(&input).unwrap());
   
       let options = GetOptions::new_with_path(
           VariantPath::try_from("a").unwrap(),
       )
       .with_as_type(Some(Arc::new(Field::new(
           "result",
           DataType::Int32,
           true,
       ))))
       .with_cast_options(CastOptions {
           safe: false,
           ..Default::default()
       });
   
       let error = variant_get(&variant, options).unwrap_err();
   
       assert_eq!(
           error.to_string(),
           r#"Cast error: Failed to extract primitive of type Int32 from 
variant ShortString(ShortString("n/a")) at path VariantPath([])"#
       );
   }
   ```
   
   The error reports an empty path even though `a` was requested.
   
   ### Expected behavior
   
   The error should report the complete path requested by the caller—in this 
example, `a`—and display the offending value cleanly rather than as 
`ShortString(ShortString("n/a"))`.
   
   For partially shredded values, the reported path should include any prefix 
already traversed through shredded fields.
   
   ### Additional context
   
   The error likely needs to be constructed or enriched at a layer that retains 
the original path. The unshredded fallback receives only the remaining path 
suffix, which is insufficient to produce the complete path after partially 
shredded traversal.
   


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