You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/11/19 18:06:15 UTC

[GitHub] [arrow] Dandandan commented on a change in pull request #8715: ARROW-10656: [Rust] Use DataType comparison without values

Dandandan commented on a change in pull request #8715:
URL: https://github.com/apache/arrow/pull/8715#discussion_r527092867



##########
File path: rust/arrow/src/datatypes.rs
##########
@@ -1142,6 +1142,44 @@ impl DataType {
                 | Float64
         )
     }
+
+    /// Compares this data type with another data type only based on the data type
+    /// including nested data types, but not based on other values.
+    pub fn cmp_type(&self, other: &Self) -> bool {
+        match (self, other) {
+            (DataType::List(f1), DataType::List(f2)) => {
+                f1.data_type().cmp_type(f2.data_type())
+            }
+            (DataType::FixedSizeList(f1, _), DataType::FixedSizeList(f2, _)) => {
+                f1.data_type().cmp_type(f2.data_type())
+            }
+            (DataType::LargeList(f1), DataType::LargeList(f2)) => {
+                f1.data_type().cmp_type(f2.data_type())
+            }
+            (DataType::Struct(f1), DataType::Struct(f2)) => {
+                if f1.len() == f2.len() {

Review comment:
       Can all use the form `f1.len() == f2.len() && f1.iter()...` without if else




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org