klion26 commented on PR #10157:
URL: https://github.com/apache/arrow-rs/pull/10157#issuecomment-4795241996

   After another look of the code, I perfer the identity function for  
`Variant::as_xx` now, as `some double can't convert to float even located in 
[f32::MIN, f32::MAX]`, this makes the semantics of ` Variant::as_f32` 
tricky(users may not know which double(f64) can or can't be convert to f32 
easily), -- for `shred`, this may led to some `double` (in the same array) 
shred to `f32` into `typed_value` column, and some `double`(which can't convert 
into `f32` lossless) located into `value` column.
   
   After changing to the identity function for `Variant::as_xxx`, there is a 
problem for `Variant::as_u8/16/32/64`, how do we want to handle this?
   if we align the semantics for all of the `Variant::as_xxx`, maybe we can 
only return `Some(value)` for `Variant::as_u8` when it is `Variant::Int8` and 
`None` for the other variants, etc
   
   ```
   fn as_u8(&self) -> Option<u8> {
      match *self {
        Variant::Int8(i) => i.try_into().ok(),
        _ => None,
      }
   }
   
   ...
   
   fn as_u64(&self) -> Option<u64> {
       match *self {
          Variant::Int64(i) => i.try_into().ok(),
         _ => None,
   }
   ```


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