laskoviymishka commented on code in PR #3331:
URL: https://github.com/apache/iceberg-rust/pull/3331#discussion_r4473126655


##########
crates/iceberg/src/spec/values/datum.rs:
##########
@@ -1009,6 +1009,7 @@ impl Datum {
     /// assert_eq!(&format!("{t}"), "1.23");
     /// ```
     pub fn decimal(value: Decimal) -> Result<Self> {
+        ensure_data_valid!(value.is_finite(), "Decimal value must be finite: 
{}", value);

Review Comment:
   Should `Datum::decimal` rescale a negative-scale value instead of clamping 
it? As I read it, fastnum parses `"1E+5"` as coefficient 1 at scale -5 
([parse.rs](https://github.com/neogenie/fastnum/blob/v0.7.5/tests/decimal/common/parse.rs#L129-L170)),
 and `decimal_scale` [clamps that to 
0](https://github.com/apache/iceberg-rust/blob/678f995565d7078ee128c52c380c3abf42d8d239/crates/iceberg/src/spec/values/decimal_utils.rs#L143-L146),
 so `Datum::decimal_from_str("1E+5")` gives 1.
   
   `main` [does the 
same](https://github.com/apache/iceberg-rust/blob/3c91b3942ab40ec005dfbb9fdbccea848392cccb/crates/iceberg/src/spec/values/decimal_utils.rs#L104-L139)
 and the JSON-default path rescales first, so a follow-up issue is enough here.



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