You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "kevingurney (via GitHub)" <gi...@apache.org> on 2023/09/07 20:46:53 UTC

[GitHub] [arrow] kevingurney commented on a diff in pull request #37619: GH-37568: [MATLAB] Implement `isequal` for the `arrow.tabular.Schema` MATLAB class

kevingurney commented on code in PR #37619:
URL: https://github.com/apache/arrow/pull/37619#discussion_r1319104314


##########
matlab/test/arrow/tabular/tSchema.m:
##########
@@ -468,6 +468,63 @@ function ErrorIfFieldNameIsNonScalar(testCase)
             testCase.verifyError(@() schema.field(fieldName), "arrow:badsubscript:NonScalar");
         end
 
+        function TestIsEqualTrue(testCase)
+            % Schema objects are considered equal if:
+            %  1. They have the same number of fields
+            %  2. Their corresponding Fields properties are equal
+
+            schema1 = arrow.schema([...
+                arrow.field("A", arrow.uint8), ...
+                arrow.field("B", arrow.uint16), ...
+                arrow.field("123", arrow.uint32)
+            ]);
+            schema2 = arrow.schema([...
+                arrow.field("A", arrow.uint8), ...
+                arrow.field("B", arrow.uint16), ...
+                arrow.field("123", arrow.uint32)
+            ]);
+            schema3 = arrow.recordBatch(table).Schema;
+            schema4 = arrow.recordBatch(table).Schema;
+            
+            testCase.verifyTrue(isequal(schema1, schema2));
+            testCase.verifyTrue(isequal(schema3, schema4));
+        end
+
+        function TestIsEqualFalse(testCase)
+            % Verify isequal returns false when expected.
+
+            schema1 = arrow.schema([...
+                arrow.field("A", arrow.uint8), ...
+                arrow.field("B", arrow.uint16), ...
+                arrow.field("123", arrow.uint32)
+            ]);
+            schema2 = arrow.schema([...
+                arrow.field("A", arrow.uint8), ...
+                arrow.field("B", arrow.uint16), ...
+            ]);
+            schema3 = arrow.schema([...
+                arrow.field("A", arrow.float32), ...
+                arrow.field("B", arrow.uint16), ...
+            ]);
+            schema4 = arrow.schema([...
+                arrow.field("C", arrow.uint8), ...
+                arrow.field("B", arrow.uint16), ...
+            ]);
+            schema5 = arrow.recordBatch(table).Schema;
+            
+            % Have different number of fields
+            testCase.verifyFalse(isequal(schema1, schema2));
+
+            % Field properties are not equal

Review Comment:
   Field -> Fields



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