martin-g commented on code in PR #8719:
URL: https://github.com/apache/arrow-rs/pull/8719#discussion_r2465812484


##########
parquet-variant-compute/src/variant_get.rs:
##########
@@ -142,8 +142,11 @@ fn shredded_get_path(
             for i in 0..target.len() {
                 if target.is_null(i) {
                     builder.append_null()?;
+                } else if !cast_options.safe {
+                    let value = target.try_value(i)?;
+                    builder.append_value(value)?;
                 } else {
-                    builder.append_value(target.value(i))?;
+                    
builder.append_value(target.try_value(i).unwrap_or(Variant::Null))?;

Review Comment:
   ```suggestion
                       match target.try_value(i) {
                           Ok(v) => builder.append_value(v)?,
                           Err(_) => builder.append_null()?,
                       }
   ```
   uses `append_null()` because it is a bit smarter



##########
parquet-variant-compute/src/type_conversion.rs:
##########
@@ -302,6 +302,19 @@ macro_rules! generic_conversion_single_value {
 }
 pub(crate) use generic_conversion_single_value;
 
+macro_rules! generic_conversion_single_value_with_result {
+    ($t:ty, $method:ident, $cast_fn:expr, $input:expr, $index:expr) => {{
+        let arr = $input.$method::<$t>();
+        let v = arr.value($index);
+        match ($cast_fn)(v) {
+            Ok(var) => Ok(Variant::from(var)),
+            Err(e) => Err(ArrowError::CastError(format!("Cast failed: {e}"))),

Review Comment:
   ```suggestion
               Err(e) => Err(ArrowError::CastError(format!(
                   "Cast failed at index {idx} (array type: {ty}): {e}",
                   idx = $index,
                   ty = <$t as ArrowPrimitiveType>::DATA_TYPE
               ))),
   ```
   to give some more details in the error message



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