tustvold commented on code in PR #4920:
URL: https://github.com/apache/arrow-rs/pull/4920#discussion_r1355107483
##########
arrow-schema/src/datatype.rs:
##########
@@ -310,6 +311,38 @@ impl fmt::Display for DataType {
}
}
+impl PartialOrd for DataType {
+ fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
+ Some(self.cmp(other))
+ }
+}
+
+impl Ord for DataType {
+ fn cmp(&self, other: &Self) -> Ordering {
+ match (self, other) {
+ (DataType::Null, DataType::Null) => Ordering::Equal,
+ (DataType::Null, _) => Ordering::Less,
+ (_, DataType::Null) => Ordering::Greater,
+ (DataType::Boolean, DataType::Boolean) => Ordering::Equal,
+ (DataType::Boolean, _) => Ordering::Less,
+ (_, DataType::Boolean) => Ordering::Greater,
+ (a, b) => {
+ if a.is_primitive() && b.is_primitive() {
+ self.primitive_width()
+ .unwrap_or(0)
+ .cmp(&other.primitive_width().unwrap_or(0))
Review Comment:
This is inconsistent with the implementation of Eq and is therefore
ill-formed
--
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]