alamb commented on code in PR #8638:
URL: https://github.com/apache/arrow-rs/pull/8638#discussion_r2449568933


##########
parquet-variant-compute/src/variant_array.rs:
##########
@@ -968,6 +964,42 @@ fn typed_value_to_variant<'a>(
         DataType::Float64 => {
             primitive_conversion_single_value!(Float64Type, typed_value, index)
         }
+        DataType::Decimal32(_, s) => {
+            generic_conversion_single_value!(
+                Decimal32Type,
+                as_primitive,
+                |v| VariantDecimal4::try_new(v, *s as 
u8).map_or(Variant::Null, Variant::from),
+                typed_value,
+                index
+            )
+        }
+        DataType::Decimal64(_, s) => {
+            generic_conversion_single_value!(
+                Decimal64Type,
+                as_primitive,
+                |v| VariantDecimal8::try_new(v, *s as 
u8).map_or(Variant::Null, Variant::from),
+                typed_value,
+                index
+            )
+        }
+        DataType::Decimal128(_, s) => {
+            generic_conversion_single_value!(
+                Decimal128Type,
+                as_primitive,
+                |v| VariantDecimal16::try_new(v, *s as 
u8).map_or(Variant::Null, Variant::from),

Review Comment:
   > We may need a follow-up item to track turning this into a proper Result 
instead of silently converting to NULL on failure? That would require 
VariantArray::value to return a Result<Variant>, which is a biggish change but 
honestly seems appropriate given that we can't guarantee the input shredding is 
even physically valid, let alone logically valid? It seems too sharp an edge to 
just panic.
   > 
   > @alamb -- thoughts?
   
   How about we add a `try_value()` method that returns a Result and just have 
`value()` unwrap the result?



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