liurenjie1024 commented on code in PR #406: URL: https://github.com/apache/iceberg-rust/pull/406#discussion_r1643647234
########## crates/iceberg/src/spec/values.rs: ########## @@ -2334,9 +2453,20 @@ mod _serde { }, RawLiteralEnum::Float(v) => match ty { Type::Primitive(PrimitiveType::Float) => Ok(Some(Literal::float(v))), + Type::Primitive(PrimitiveType::Double) => { + Ok(Some(Literal::double(f64::from(v)))) + } _ => Err(invalid_err("float")), }, RawLiteralEnum::Double(v) => match ty { + Type::Primitive(PrimitiveType::Float) => { + let v = v as f32; + // Return error if the value has lost precision + if v as f64 != f64::from(v) { Review Comment: > I think the check here is to deal with the case that serialize f32 to f64 and deserialize back to f32. In this case, there is no precision loss. Floating number's precision is always difficult to deal with, so I'm ok for now we don't allow precision loss. > So I think we need to do the bitwise comparison here rather than compare two f64. These are special values, see https://doc.rust-lang.org/std/primitive.f64.html#associatedconstant.NAN we can check and convert them directly: https://doc.rust-lang.org/std/primitive.f32.html#associatedconstant.NAN -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org