klion26 commented on code in PR #9689:
URL: https://github.com/apache/arrow-rs/pull/9689#discussion_r3063097679
##########
parquet-variant/src/variant.rs:
##########
@@ -1138,6 +1213,18 @@ impl<'m, 'v> Variant<'m, 'v> {
Variant::Int8(_) | Variant::Int16(_) | Variant::Int32(_) |
Variant::Int64(_) => {
self.as_num::<i32>().and_then(|x| x.try_into().ok())
}
+ Variant::Float(f) => single_float_to_decimal::<Decimal32Type>(f as
_, 1f64)
+ .and_then(|x: i32| x.try_into().ok()),
+ Variant::Double(f) => single_float_to_decimal::<Decimal32Type>(f,
1f64)
+ .and_then(|x: i32| x.try_into().ok()),
+ Variant::String(v) =>
parse_string_to_decimal_native::<Decimal32Type>(v, 0usize)
+ .ok()
+ .and_then(|x: i32| x.try_into().ok()),
+ Variant::ShortString(v) => {
+ parse_string_to_decimal_native::<Decimal32Type>(v.as_str(),
0usize)
Review Comment:
Use `v.as_str()` instead of `v` because we use `match *self`, if we change
to `match self` then we need to derefer self in other match arms, seems there
is litter benefit gained, so stick to the current `match *self` and use
`v.as_str()` here.
##########
parquet-variant/src/variant.rs:
##########
@@ -1177,6 +1264,18 @@ impl<'m, 'v> Variant<'m, 'v> {
Variant::Int8(_) | Variant::Int16(_) | Variant::Int32(_) |
Variant::Int64(_) => {
self.as_num::<i64>().and_then(|x| x.try_into().ok())
}
Review Comment:
Will add some examples/tests for the newly changes in variant.
--
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]