You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ag...@apache.org on 2019/03/02 14:37:36 UTC

[arrow] branch master updated: ARROW-4727: [Rust] Add equality check for schemas

This is an automated email from the ASF dual-hosted git repository.

agrove pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 1a36fd1  ARROW-4727: [Rust] Add equality check for schemas
1a36fd1 is described below

commit 1a36fd1dc4874167412083b4ffea33e9673cd27c
Author: Neville Dipale <ne...@gmail.com>
AuthorDate: Sat Mar 2 07:37:27 2019 -0700

    ARROW-4727: [Rust] Add equality check for schemas
    
    We need this when we're checking if record batches have the same schema
    
    Author: Neville Dipale <ne...@gmail.com>
    
    Closes #3791 from nevi-me/ARROW-4727 and squashes the following commits:
    
    8f348e7 <Neville Dipale> ARROW-4727:  Add equality check for schemas
---
 rust/arrow/src/datatypes.rs | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/rust/arrow/src/datatypes.rs b/rust/arrow/src/datatypes.rs
index 765eae0..9e1c6db 100644
--- a/rust/arrow/src/datatypes.rs
+++ b/rust/arrow/src/datatypes.rs
@@ -527,7 +527,7 @@ impl fmt::Display for Field {
 ///
 /// Note that this information is only part of the meta-data and not part of the physical
 /// memory layout.
-#[derive(Serialize, Deserialize, Debug, Clone)]
+#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
 pub struct Schema {
     pub(crate) fields: Vec<Field>,
 }
@@ -819,4 +819,32 @@ mod tests {
         assert_eq!(_person.fields()[0].is_nullable(), false);
     }
 
+    #[test]
+    fn schema_equality() {
+        let schema1 = Schema::new(vec![
+            Field::new("c1", DataType::Utf8, false),
+            Field::new("c2", DataType::Float64, true),
+        ]);
+        let schema2 = Schema::new(vec![
+            Field::new("c1", DataType::Utf8, false),
+            Field::new("c2", DataType::Float64, true),
+        ]);
+
+        assert_eq!(schema1, schema2);
+
+        let schema3 = Schema::new(vec![
+            Field::new("c1", DataType::Utf8, false),
+            Field::new("c2", DataType::Float32, true),
+        ]);
+        let schema4 = Schema::new(vec![
+            Field::new("C1", DataType::Utf8, false),
+            Field::new("C2", DataType::Float64, true),
+        ]);
+
+        assert!(schema1 != schema3);
+        assert!(schema1 != schema4);
+        assert!(schema2 != schema3);
+        assert!(schema2 != schema4);
+        assert!(schema3 != schema4);
+    }
 }