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 2022/11/24 02:52:48 UTC

[GitHub] [arrow-datafusion] mingmwang commented on a diff in pull request #4347: Do not error in optimizer if resulting schema has different metadata

mingmwang commented on code in PR #4347:
URL: https://github.com/apache/arrow-datafusion/pull/4347#discussion_r1031012003


##########
datafusion/common/src/dfschema.rs:
##########
@@ -338,6 +338,24 @@ impl DFSchema {
             })
     }
 
+    /// Returns true if the two schemas have the same qualified named
+    /// fields with the same data types. Returns false otherwise.
+    ///
+    /// This is a specialized version of Eq that ignores differences
+    /// in nullability and metadata.
+    pub fn equivalent_names_and_types(&self, other: &Self) -> bool {
+        if self.fields().len() != other.fields().len() {
+            return false;
+        }
+        let self_fields = self.fields().iter();
+        let other_fields = other.fields().iter();
+        self_fields.zip(other_fields).all(|(f1, f2)| {
+            f1.qualifier() == f2.qualifier()
+                && f1.data_type() == f2.data_type()
+                && f1.name() == f2.name()
+        })
+    }
+

Review Comment:
   Some complex arrow types are nested types and can include other Fields.
   ````
       /// A list of some logical data type with variable length.
       List(Box<Field>),
       /// A list of some logical data type with fixed length.
       FixedSizeList(Box<Field>, i32),
       /// A list of some logical data type with variable length and 64-bit offsets.
       LargeList(Box<Field>),
       /// A nested datatype that contains a number of sub-fields.
       Struct(Vec<Field>),
   ````
   https://github.com/apache/arrow-rs/blob/cea5146b69b3413a1d5caa946e0774ec8d834e95/arrow-schema/src/datatype.rs#L163-L187



-- 
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: github-unsubscribe@arrow.apache.org

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