zhangfengcdt commented on code in PR #3327:
URL: https://github.com/apache/iceberg-rust/pull/3327#discussion_r4185648594
##########
crates/iceberg/src/spec/values/primitive.rs:
##########
@@ -46,7 +55,60 @@ pub enum PrimitiveLiteral {
BelowMin,
}
+impl PartialEq for PrimitiveLiteral {
+ fn eq(&self, other: &Self) -> bool {
+ self.partial_cmp(other) == Some(Ordering::Equal)
+ }
+}
+
+impl PartialOrd for PrimitiveLiteral {
+ fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
+ match (self, other) {
+ (Self::Boolean(a), Self::Boolean(b)) => a.partial_cmp(b),
+ (Self::Int(a), Self::Int(b)) => a.partial_cmp(b),
+ (Self::Long(a), Self::Long(b)) => a.partial_cmp(b),
+ (Self::Float(a), Self::Float(b)) => Some(float_cmp(a, b)),
+ (Self::Double(a), Self::Double(b)) => Some(float_cmp(a, b)),
+ (Self::String(a), Self::String(b)) => a.partial_cmp(b),
+ (Self::Binary(a), Self::Binary(b)) => a.partial_cmp(b),
+ (Self::Int128(a), Self::Int128(b)) => a.partial_cmp(b),
+ (Self::UInt128(a), Self::UInt128(b)) => a.partial_cmp(b),
+ // Different variants order by declaration, as the derived impl
did.
+ _ => self.variant_index().partial_cmp(&other.variant_index()),
Review Comment:
Yes, so I added explicit arms for AboveMax/BelowMin and the debug_assert_ne!
on the discriminants to make this case not possible to reach. Also the fallback
return None when both sides are the same 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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]