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


##########
parquet-variant-compute/src/variant_to_arrow.rs:
##########
@@ -293,21 +337,77 @@ fn get_type_name<T: ArrowPrimitiveType>() -> &'static str 
{
         "arrow_array::types::Float32Type" => "Float32",
         "arrow_array::types::Float64Type" => "Float64",
         "arrow_array::types::Float16Type" => "Float16",
+        "arrow_array::types::TimestampMicrosecondType" => 
"Timestamp(Microsecond)",
+        "arrow_array::types::TimestampNanosecondType" => 
"Timestamp(Nanosecond)",
         _ => "Unknown",
     }
 }
 
+/// Builder for converting variant values to boolean values
+/// Boolean is not primitive types in Arrow, so we need a separate builder
+pub(crate) struct VariantToBooleanArrowRowBuilder<'a> {
+    builder: arrow::array::BooleanBuilder,
+    cast_options: &'a CastOptions<'a>,
+}
+
+impl<'a> VariantToBooleanArrowRowBuilder<'a> {
+    fn new(cast_options: &'a CastOptions<'a>, capacity: usize) -> Self {
+        Self {
+            builder: arrow::array::BooleanBuilder::with_capacity(capacity),

Review Comment:
   Putting it all together, boolean would be:
   ```rust
   define_row_builder!(
       struct VariantToBooleanArrowRowBuilder<'a>,
       |capacity| -> BooleanArrayBuilder { 
BooleanArrayBuilder::with_capacity(capacity) },
       |value| value.as_boolean()
   )
   ```
   while "simple" primitives would be:
   ```rust
   define_row_builder!(
       struct VariantToPrimitiveArrowRowBuilder<'a, T: ArrowPrimitiveType>,
       |capacity| -> PrimitiveArrayBuilder<T> { 
PrimitiveArrayBuilder::with_capacity(capacity) },
       |value| value.as_primitive()
   )
   ```
   ... and timestamps would be:
   ```rust
   define_row_builder!(
       struct VariantToTimestampArrowRowBuilder<'a, T: ArrowTimestampType>,
       |capacity, tz: Option<Arc<str>>| -> PrimitiveArrayBuilder<T>  { 
           PrimitiveArrayBuilder::with_capacity(capacity).with_timezone_opt(tz)
       },
       |value| value.as_primitive()
   )
   ```
   



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