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


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



##########
parquet-variant-compute/src/variant_to_arrow.rs:
##########
@@ -545,3 +560,24 @@ impl VariantToBinaryVariantArrowRowBuilder {
         Ok(ArrayRef::from(variant_array))
     }
 }
+
+struct FakeNullBuilder(NullArray);
+
+impl FakeNullBuilder {
+    fn new(capacity: usize) -> Self {
+        Self(NullArray::new(capacity))
+    }
+    fn append_value(&mut self, _: ()) {}
+    fn append_null(&mut self) {}
+
+    fn finish(self) -> NullArray {
+        self.0
+    }
+}
+
+define_variant_to_primitive_builder!(
+    struct VariantToNullArrowRowBuilder<'a>
+    |capacity| -> FakeNullBuilder { FakeNullBuilder::new(capacity) },
+    |value|  value.as_null(),

Review Comment:
   Should we just hard-wire `|_| Some(Variant::Null)` here? 
   All input variant subtypes ultimately produce the same outcome because both 
append_null and append_value are no-ops.



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