abnobdoss commented on code in PR #2508:
URL: https://github.com/apache/iceberg-rust/pull/2508#discussion_r3406778385


##########
crates/iceberg/src/spec/values/decimal_utils.rs:
##########
@@ -120,6 +120,11 @@ pub fn decimal_mantissa(d: &Decimal) -> i128 {
     }
 }
 
+/// Get the decimal digit precision of a mantissa.
+pub fn decimal_precision(mantissa: i128) -> u32 {
+    mantissa.unsigned_abs().to_string().len() as u32

Review Comment:
   This is more elegant and performant; I've applied this and the doc comment, 
thank you for the correction!



##########
crates/iceberg/src/spec/values/datum.rs:
##########
@@ -1130,6 +1137,21 @@ impl Datum {
                     (PrimitiveLiteral::Int128(val), _, PrimitiveType::Long) => 
{
                         Ok(Datum::i128_to_i64(*val))
                     }
+                    (
+                        PrimitiveLiteral::Int128(val),
+                        PrimitiveType::Decimal {
+                            scale: self_scale, ..
+                        },
+                        PrimitiveType::Decimal {
+                            precision,
+                            scale: target_scale,
+                        },
+                    ) if self_scale == target_scale => 
Datum::decimal_from_mantissa(
+                        *val,
+                        *precision,
+                        *target_scale,
+                        self.to_human_string(),

Review Comment:
   Good call, I've applied this too!



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to