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

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


The following commit(s) were added to refs/heads/main by this push:
     new 602083be4f GH-37472: [MATLAB] Implement the `isequal()` method on 
`arrow.type.Type` (#37474)
602083be4f is described below

commit 602083be4f9630eda3edaf3ac18a660ccce91468
Author: sgilmore10 <[email protected]>
AuthorDate: Wed Aug 30 16:24:42 2023 -0400

    GH-37472: [MATLAB] Implement the `isequal()` method on `arrow.type.Type` 
(#37474)
    
    
    
    ### Rationale for this change
    
    Currently, it's not possible to determine if two `arrow.type.Type` 
instances are equal because the `isequal()` method always returns `false` by 
default:
    
    ```matlab
    
    >> t = arrow.int32()
    
    t =
    
      Int32Type with properties:
    
        ID: Int32
    
    % Compare a with itself
    >> tf = isequal(t, t)
    
    tf =
    
      logical
    
       0
    
    ```
    
    ### What changes are included in this PR?
    
    1. Implemented the `isequal` method on all concrete subclasses of 
`arrow.type.Type`
    2. Added a new method called `isEqual()` on the 
`arrow::matlab::type::proxy::Type` class.
    
    **Example Usage**
    
    ```matlab
    >> t1 = arrow.timestamp(TimeUnit="Second");
    >> t2 = arrow.timestamp(TimeUnit="Microsecond");
    >> t3 = arrow.timestamp(TimeUnit="Second");
    
    % Compare t1 and t2
    >> tf1 = isequal(t1, t2)
    
    tf1 =
    
      logical
    
       0
    
    % Compare t1 and t3
    >> tf2 = isequal(t1, t3)
    
    tf2 =
    
      logical
    
       1
    ```
    
    ### Are these changes tested?
    
    Yes. Added test cases verifying `isequal` behaves as expected for all 
concrete subclasses of `arrow.type.Type`.
    
    ### Are there any user-facing changes?
    
    Yes. Users can now use the `isequal` method to compare `arrow.type.Type` 
instances for equality.
    
    ### Future Directions
    
    1. Implement the `isequal` method for `arrow.type.Field`
    2. Implement the `isequal` method for `arrow.tabular.Schema`
    
    * Closes: #37472
    
    Authored-by: Sarah Gilmore <[email protected]>
    Signed-off-by: Kevin Gurney <[email protected]>
---
 matlab/src/cpp/arrow/matlab/type/proxy/type.cc | 24 +++++++++
 matlab/src/cpp/arrow/matlab/type/proxy/type.h  |  2 +
 matlab/src/matlab/+arrow/+type/Type.m          | 35 ++++++++++++-
 matlab/test/arrow/type/tBooleanType.m          | 36 +++++++++++++
 matlab/test/arrow/type/tDate32Type.m           | 34 +++++++++++++
 matlab/test/arrow/type/tFloat32Type.m          | 36 +++++++++++++
 matlab/test/arrow/type/tFloat64Type.m          | 35 +++++++++++++
 matlab/test/arrow/type/tInt16Type.m            | 36 +++++++++++++
 matlab/test/arrow/type/tInt32Type.m            | 36 +++++++++++++
 matlab/test/arrow/type/tInt64Type.m            | 36 +++++++++++++
 matlab/test/arrow/type/tInt8Type.m             | 36 +++++++++++++
 matlab/test/arrow/type/tStringType.m           | 34 +++++++++++++
 matlab/test/arrow/type/tTime32Type.m           | 47 +++++++++++++++++
 matlab/test/arrow/type/tTime64Type.m           | 46 +++++++++++++++++
 matlab/test/arrow/type/tTimestampType.m        | 70 ++++++++++++++++++++++++++
 matlab/test/arrow/type/tUInt16Type.m           | 36 +++++++++++++
 matlab/test/arrow/type/tUInt32Type.m           | 36 +++++++++++++
 matlab/test/arrow/type/tUInt64Type.m           | 36 +++++++++++++
 matlab/test/arrow/type/tUInt8Type.m            | 36 +++++++++++++
 19 files changed, 686 insertions(+), 1 deletion(-)

diff --git a/matlab/src/cpp/arrow/matlab/type/proxy/type.cc 
b/matlab/src/cpp/arrow/matlab/type/proxy/type.cc
index f6a307ff3f..95ff11c077 100644
--- a/matlab/src/cpp/arrow/matlab/type/proxy/type.cc
+++ b/matlab/src/cpp/arrow/matlab/type/proxy/type.cc
@@ -17,11 +17,14 @@
 
 #include "arrow/matlab/type/proxy/type.h"
 
+#include "libmexclass/proxy/ProxyManager.h"
+
 namespace arrow::matlab::type::proxy {
 
     Type::Type(std::shared_ptr<arrow::DataType> type) : 
data_type{std::move(type)} {
         REGISTER_METHOD(Type, typeID);
         REGISTER_METHOD(Type, numFields);
+        REGISTER_METHOD(Type, isEqual);
     }
 
     std::shared_ptr<arrow::DataType> Type::unwrap() {
@@ -44,5 +47,26 @@ namespace arrow::matlab::type::proxy {
         context.outputs[0] = num_fields_mda;
     }
 
+    void Type::isEqual(libmexclass::proxy::method::Context& context) {
+        namespace mda = ::matlab::data;
+
+        const mda::TypedArray<uint64_t> type_proxy_ids = context.inputs[0];
+
+        bool is_equal = true;
+        const auto check_metadata = false;
+        for (const auto& type_proxy_id : type_proxy_ids) {
+            // Retrieve the Type proxy from the ProxyManager
+            auto proxy = 
libmexclass::proxy::ProxyManager::getProxy(type_proxy_id);
+            auto type_proxy = std::static_pointer_cast<proxy::Type>(proxy);
+            auto type_to_compare = type_proxy->unwrap();
+
+            if (!data_type->Equals(type_to_compare, check_metadata)) {
+                is_equal = false;
+                break;
+            }
+        }
+        mda::ArrayFactory factory;
+        context.outputs[0] = factory.createScalar(is_equal);
+    }
 }
 
diff --git a/matlab/src/cpp/arrow/matlab/type/proxy/type.h 
b/matlab/src/cpp/arrow/matlab/type/proxy/type.h
index e94097aa73..d528d50d87 100644
--- a/matlab/src/cpp/arrow/matlab/type/proxy/type.h
+++ b/matlab/src/cpp/arrow/matlab/type/proxy/type.h
@@ -37,6 +37,8 @@ class Type : public libmexclass::proxy::Proxy {
 
         void numFields(libmexclass::proxy::method::Context& context);
 
+        void isEqual(libmexclass::proxy::method::Context& context);
+
         std::shared_ptr<arrow::DataType> data_type;
 };
 
diff --git a/matlab/src/matlab/+arrow/+type/Type.m 
b/matlab/src/matlab/+arrow/+type/Type.m
index c2ae3dbc58..446649285f 100644
--- a/matlab/src/matlab/+arrow/+type/Type.m
+++ b/matlab/src/matlab/+arrow/+type/Type.m
@@ -48,5 +48,38 @@ classdef (Abstract) Type < matlab.mixin.CustomDisplay
           propgrp = matlab.mixin.util.PropertyGroup(proplist);
         end
     end
-    
+
+    methods
+        function tf = isequal(obj, varargin)
+
+            narginchk(2, inf);
+            tf = false;
+            
+            proxyIDs = zeros([numel(obj) numel(varargin)], "uint64");
+
+            for ii = 1:numel(varargin)
+                type = varargin{ii};
+                if ~isa(type, "arrow.type.Type") || ~isequal(size(obj), 
size(type))
+                    % Return early if type is not an arrow.type.Type or if
+                    % the dimensions of obj and type do not match.
+                    return;
+                end
+
+                % type(:) flattens N-dimensional arrays into a column
+                % vector before collecting the Proxy properties into a
+                % row vector.
+                proxies = [type(:).Proxy];
+                proxyIDs(:, ii) = [proxies.ID];
+            end
+
+            for ii = 1:numel(obj)
+                % Invoke isEqual proxy method on each Type 
+                % in the object array
+                tf = obj(ii).Proxy.isEqual(proxyIDs(ii, :));
+                if ~tf
+                    return;
+                end
+            end
+        end
+    end
 end
diff --git a/matlab/test/arrow/type/tBooleanType.m 
b/matlab/test/arrow/type/tBooleanType.m
index eaa1c280d5..673ac8e44a 100644
--- a/matlab/test/arrow/type/tBooleanType.m
+++ b/matlab/test/arrow/type/tBooleanType.m
@@ -22,4 +22,40 @@ classdef tBooleanType < hFixedWidthType
         BitWidth = int32(1)
         ClassName = "arrow.type.BooleanType"
     end
+
+    methods(Test)
+        function IsEqualTrue(testCase)
+            % Verifies isequal method of arrow.type.BooleanType returns true if
+            % these conditions are met:
+            %
+            % 1. All input arguments have a class type arrow.type.BooleanType
+            % 2. All inputs have the same size
+
+            % Scalar BooleanType arrays
+            boolType1 = arrow.boolean();
+            boolType2 = arrow.boolean();
+            testCase.verifyTrue(isequal(boolType1, boolType2));
+
+            % Non-scalar BooleanType arrays
+            typeArray1 = [boolType1 boolType1];
+            typeArray2 = [boolType2 boolType2];
+            testCase.verifyTrue(isequal(typeArray1, typeArray2));
+        end
+
+        function IsEqualFalse(testCase)
+            % Verifies the isequal method of arrow.type.BooleanType returns
+            % false when expected.
+            
+            % Pass a different arrow.type.Type subclass to isequal
+            boolType = arrow.boolean();
+            int32Type = arrow.int32();
+            testCase.verifyFalse(isequal(boolType, int32Type));
+            testCase.verifyFalse(isequal([boolType boolType], [int32Type 
int32Type]));
+
+            % BooleanType arrays have different sizes
+            typeArray1 = [boolType boolType];
+            typeArray2 = [boolType boolType]';
+            testCase.verifyFalse(isequal(typeArray1, typeArray2));
+        end
+    end
 end
\ No newline at end of file
diff --git a/matlab/test/arrow/type/tDate32Type.m 
b/matlab/test/arrow/type/tDate32Type.m
index 984baa66bb..3c99bd1fc9 100644
--- a/matlab/test/arrow/type/tDate32Type.m
+++ b/matlab/test/arrow/type/tDate32Type.m
@@ -76,6 +76,40 @@ classdef tDate32Type < hFixedWidthType
             testCase.verifyError(@() arrow.type.Date32Type(proxy), 
"arrow:proxy:ProxyNameMismatch");
         end
 
+        function IsEqualTrue(testCase)
+            % Verifies isequal method of arrow.type.Date32Type returns true if
+            % these conditions are met:
+            %
+            % 1. All input arguments have a class type arrow.type.Date32Type
+            % 2. All inputs have the same size
+
+            % Scalar Date32Type arrays
+            date32Type1 = arrow.date32();
+            date32Type2 = arrow.date32();
+            testCase.verifyTrue(isequal(date32Type1, date32Type2));
+
+            % Non-scalar Date32Type arrays
+            typeArray1 = [date32Type1 date32Type1];
+            typeArray2 = [date32Type2 date32Type2];
+            testCase.verifyTrue(isequal(typeArray1, typeArray2));
+        end
+
+        function IsEqualFalse(testCase)
+            % Verifies the isequal method of arrow.type.Date32Type returns
+            % false when expected.
+            
+            % Pass a different arrow.type.Type subclass to isequal
+            date32Type = arrow.date32();
+            int32Type = arrow.int32();
+            testCase.verifyFalse(isequal(date32Type, int32Type));
+            testCase.verifyFalse(isequal([date32Type date32Type], [int32Type 
int32Type]));
+
+            % Date32Type arrays have different sizes
+            typeArray1 = [date32Type date32Type];
+            typeArray2 = [date32Type date32Type]';
+            testCase.verifyFalse(isequal(typeArray1, typeArray2));
+        end
+    
     end
 
 end
diff --git a/matlab/test/arrow/type/tFloat32Type.m 
b/matlab/test/arrow/type/tFloat32Type.m
index 1837c39a72..d912d5bd76 100644
--- a/matlab/test/arrow/type/tFloat32Type.m
+++ b/matlab/test/arrow/type/tFloat32Type.m
@@ -22,4 +22,40 @@ classdef tFloat32Type < hFixedWidthType
         BitWidth = int32(32)
         ClassName = "arrow.type.Float32Type"
     end
+
+    methods(Test)
+        function IsEqualTrue(testCase)
+            % Verifies isequal method of arrow.type.Float32Type returns true if
+            % these conditions are met:
+            %
+            % 1. All input arguments have a class type arrow.type.Float32Type
+            % 2. All inputs have the same size
+
+            % Scalar Float32Type arrays
+            float32Type1 = arrow.float32();
+            float32Type2 = arrow.float32();
+            testCase.verifyTrue(isequal(float32Type1, float32Type2));
+
+            % Non-scalar Float32Type arrays
+            typeArray1 = [float32Type1 float32Type1];
+            typeArray2 = [float32Type2 float32Type2];
+            testCase.verifyTrue(isequal(typeArray1, typeArray2));
+        end
+
+        function IsEqualFalse(testCase)
+            % Verifies the isequal method of arrow.type.Float32Type returns
+            % false when expected.
+            
+            % Pass a different arrow.type.Type subclass to isequal
+            float32Type = arrow.float32();
+            int32Type = arrow.int32();
+            testCase.verifyFalse(isequal(float32Type, int32Type));
+            testCase.verifyFalse(isequal([float32Type float32Type], [int32Type 
int32Type]));
+
+            % Float32Type arrays have different sizes
+            typeArray1 = [float32Type float32Type];
+            typeArray2 = [float32Type float32Type]';
+            testCase.verifyFalse(isequal(typeArray1, typeArray2));
+        end
+    end
 end
\ No newline at end of file
diff --git a/matlab/test/arrow/type/tFloat64Type.m 
b/matlab/test/arrow/type/tFloat64Type.m
index 8387a4bf58..606e12b2f4 100644
--- a/matlab/test/arrow/type/tFloat64Type.m
+++ b/matlab/test/arrow/type/tFloat64Type.m
@@ -21,6 +21,41 @@ classdef tFloat64Type < hFixedWidthType
         TypeID = arrow.type.ID.Float64
         BitWidth = int32(64)
         ClassName = "arrow.type.Float64Type"
+    end
+
+    methods(Test)
+        function IsEqualTrue(testCase)
+            % Verifies isequal method of arrow.type.Float64Type returns true if
+            % these conditions are met:
+            %
+            % 1. All input arguments have a class type arrow.type.Float64Type
+            % 2. All inputs have the same size
+
+            % Scalar Float64Type arrays
+            float64Type1 = arrow.float64();
+            float64Type2 = arrow.float64();
+            testCase.verifyTrue(isequal(float64Type1, float64Type2));
+
+            % Non-scalar Float64Type arrays
+            typeArray1 = [float64Type1 float64Type1];
+            typeArray2 = [float64Type2 float64Type2];
+            testCase.verifyTrue(isequal(typeArray1, typeArray2));
+        end
+
+        function IsEqualFalse(testCase)
+            % Verifies the isequal method of arrow.type.Float64Type returns
+            % false when expected.
+            
+            % Pass a different arrow.type.Type subclass to isequal
+            float64Type = arrow.float64();
+            int32Type = arrow.int32();
+            testCase.verifyFalse(isequal(float64Type, int32Type));
+            testCase.verifyFalse(isequal([float64Type float64Type], [int32Type 
int32Type]));
 
+            % Float64Type arrays have different sizes
+            typeArray1 = [float64Type float64Type];
+            typeArray2 = [float64Type float64Type]';
+            testCase.verifyFalse(isequal(typeArray1, typeArray2));
+        end
     end
 end
\ No newline at end of file
diff --git a/matlab/test/arrow/type/tInt16Type.m 
b/matlab/test/arrow/type/tInt16Type.m
index 9b741a3295..7e955aa865 100644
--- a/matlab/test/arrow/type/tInt16Type.m
+++ b/matlab/test/arrow/type/tInt16Type.m
@@ -22,4 +22,40 @@ classdef tInt16Type < hFixedWidthType
         BitWidth = int32(16)
         ClassName = "arrow.type.Int16Type"
     end
+
+    methods(Test)
+        function IsEqualTrue(testCase)
+            % Verifies isequal method of arrow.type.Int16Type returns true if
+            % these conditions are met:
+            %
+            % 1. All input arguments have a class type arrow.type.Int16Type
+            % 2. All inputs have the same size
+
+            % Scalar Int16Type arrays
+            int16Type1 = arrow.int16();
+            int16Type2 = arrow.int16();
+            testCase.verifyTrue(isequal(int16Type1, int16Type2));
+
+            % Non-scalar Int16Type arrays
+            typeArray1 = [int16Type1 int16Type1];
+            typeArray2 = [int16Type2 int16Type2];
+            testCase.verifyTrue(isequal(typeArray1, typeArray2));
+        end
+
+        function IsEqualFalse(testCase)
+            % Verifies the isequal method of arrow.type.Int16Type returns
+            % false when expected.
+            
+            % Pass a different arrow.type.Type subclass to isequal
+            int16Type = arrow.int16();
+            int32Type = arrow.int32();
+            testCase.verifyFalse(isequal(int16Type, int32Type));
+            testCase.verifyFalse(isequal([int16Type int16Type], [int32Type 
int32Type]));
+
+            % Int16Type arrays have different sizes
+            typeArray1 = [int16Type int16Type];
+            typeArray2 = [int16Type int16Type]';
+            testCase.verifyFalse(isequal(typeArray1, typeArray2));
+        end
+    end
 end
\ No newline at end of file
diff --git a/matlab/test/arrow/type/tInt32Type.m 
b/matlab/test/arrow/type/tInt32Type.m
index 9724f9a4a6..16540ef29d 100644
--- a/matlab/test/arrow/type/tInt32Type.m
+++ b/matlab/test/arrow/type/tInt32Type.m
@@ -22,4 +22,40 @@ classdef tInt32Type < hFixedWidthType
         BitWidth = int32(32)
         ClassName = "arrow.type.Int32Type"
     end
+
+    methods(Test)
+        function IsEqualTrue(testCase)
+            % Verifies isequal method of arrow.type.Int32Type returns true if
+            % these conditions are met:
+            %
+            % 1. All input arguments have a class type arrow.type.Int32Type
+            % 2. All inputs have the same size
+
+            % Scalar Int32Type arrays
+            int32Type1 = arrow.int32();
+            int32Type2 = arrow.int32();
+            testCase.verifyTrue(isequal(int32Type1, int32Type2));
+
+            % Non-scalar Int32Type arrays
+            typeArray1 = [int32Type1 int32Type1];
+            typeArray2 = [int32Type2 int32Type2];
+            testCase.verifyTrue(isequal(typeArray1, typeArray2));
+        end
+
+        function IsEqualFalse(testCase)
+            % Verifies the isequal method of arrow.type.Int32Type returns
+            % false when expected.
+            
+            % Pass a different arrow.type.Type subclass to isequal
+            int32Type = arrow.int32();
+            int64Type = arrow.int64();
+            testCase.verifyFalse(isequal(int32Type, int64Type));
+            testCase.verifyFalse(isequal([int32Type int32Type], [int64Type 
int64Type]));
+
+            % Int32Type arrays have different sizes
+            typeArray1 = [int32Type int32Type];
+            typeArray2 = [int32Type int32Type]';
+            testCase.verifyFalse(isequal(typeArray1, typeArray2));
+        end
+    end
 end
\ No newline at end of file
diff --git a/matlab/test/arrow/type/tInt64Type.m 
b/matlab/test/arrow/type/tInt64Type.m
index 2acb5fd2d3..2ba9b22139 100644
--- a/matlab/test/arrow/type/tInt64Type.m
+++ b/matlab/test/arrow/type/tInt64Type.m
@@ -22,4 +22,40 @@ classdef tInt64Type < hFixedWidthType
         BitWidth = int32(64)
         ClassName = "arrow.type.Int64Type"
     end
+
+    methods(Test)
+        function IsEqualTrue(testCase)
+            % Verifies isequal method of arrow.type.Int64Type returns true if
+            % these conditions are met:
+            %
+            % 1. All input arguments have a class type arrow.type.Int64Type
+            % 2. All inputs have the same size
+
+            % Scalar Int64Type arrays
+            int64Type1 = arrow.int64();
+            int64Type2 = arrow.int64();
+            testCase.verifyTrue(isequal(int64Type1, int64Type2));
+
+            % Non-scalar Int64Type arrays
+            typeArray1 = [int64Type1 int64Type1];
+            typeArray2 = [int64Type2 int64Type2];
+            testCase.verifyTrue(isequal(typeArray1, typeArray2));
+        end
+
+        function IsEqualFalse(testCase)
+            % Verifies the isequal method of arrow.type.Int64Type returns
+            % false when expected.
+            
+            % Pass a different arrow.type.Type subclass to isequal
+            int64Type = arrow.int64();
+            int32Type = arrow.int32();
+            testCase.verifyFalse(isequal(int64Type, int32Type));
+            testCase.verifyFalse(isequal([int64Type int64Type], [int32Type 
int32Type]));
+
+            % Int64Type arrays have different sizes
+            typeArray1 = [int64Type int64Type];
+            typeArray2 = [int64Type int64Type]';
+            testCase.verifyFalse(isequal(typeArray1, typeArray2));
+        end
+    end
 end
\ No newline at end of file
diff --git a/matlab/test/arrow/type/tInt8Type.m 
b/matlab/test/arrow/type/tInt8Type.m
index 15e2629bc4..f37ef8bad1 100644
--- a/matlab/test/arrow/type/tInt8Type.m
+++ b/matlab/test/arrow/type/tInt8Type.m
@@ -22,4 +22,40 @@ classdef tInt8Type < hFixedWidthType
         BitWidth = int32(8)
         ClassName = "arrow.type.Int8Type"
     end
+
+    methods(Test)
+        function IsEqualTrue(testCase)
+            % Verifies isequal method of arrow.type.Int8Type returns true if
+            % these conditions are met:
+            %
+            % 1. All input arguments have a class type arrow.type.Int8Type
+            % 2. All inputs have the same size
+
+            % Scalar Int8Type arrays
+            int8Type1 = arrow.int8();
+            int8Type2 = arrow.int8();
+            testCase.verifyTrue(isequal(int8Type1, int8Type2));
+
+            % Non-scalar Int8Type arrays
+            typeArray1 = [int8Type1 int8Type1];
+            typeArray2 = [int8Type2 int8Type2];
+            testCase.verifyTrue(isequal(typeArray1, typeArray2));
+        end
+
+        function IsEqualFalse(testCase)
+            % Verifies the isequal method of arrow.type.Int8Type returns
+            % false when expected.
+            
+            % Pass a different arrow.type.Type subclass to isequal
+            int8Type = arrow.int8();
+            int32Type = arrow.int32();
+            testCase.verifyFalse(isequal(int8Type, int32Type));
+            testCase.verifyFalse(isequal([int8Type int8Type], [int32Type 
int32Type]));
+
+            % Int8Type arrays have different sizes
+            typeArray1 = [int8Type int8Type];
+            typeArray2 = [int8Type int8Type]';
+            testCase.verifyFalse(isequal(typeArray1, typeArray2));
+        end
+    end
 end
\ No newline at end of file
diff --git a/matlab/test/arrow/type/tStringType.m 
b/matlab/test/arrow/type/tStringType.m
index e52c2cb1cb..e2a16ab133 100644
--- a/matlab/test/arrow/type/tStringType.m
+++ b/matlab/test/arrow/type/tStringType.m
@@ -30,6 +30,40 @@ classdef tStringType < matlab.unittest.TestCase
             tc.verifyEqual(type.NumFields, int32(0));
         end
 
+        function IsEqualTrue(testCase)
+            % Verifies isequal method of arrow.type.StringType returns true if
+            % these conditions are met:
+            %
+            % 1. All input arguments have a class type arrow.type.StringType
+            % 2. All inputs have the same size
+
+            % Scalar StringType arrays
+            stringType1 = arrow.string();
+            stringType2 = arrow.string();
+            testCase.verifyTrue(isequal(stringType1, stringType2));
+
+            % Non-scalar StringType arrays
+            typeArray1 = [stringType1 stringType1];
+            typeArray2 = [stringType2 stringType2];
+            testCase.verifyTrue(isequal(typeArray1, typeArray2));
+        end
+
+        function IsEqualFalse(testCase)
+            % Verifies the isequal method of arrow.type.StringType returns
+            % false when expected.
+            
+            % Pass a different arrow.type.Type subclass to isequal
+            stringType = arrow.string();
+            int32Type = arrow.int32();
+            testCase.verifyFalse(isequal(stringType, int32Type));
+            testCase.verifyFalse(isequal([stringType stringType], [int32Type 
int32Type]));
+
+            % StringType arrays have different sizes
+            typeArray1 = [stringType stringType];
+            typeArray2 = [stringType stringType]';
+            testCase.verifyFalse(isequal(typeArray1, typeArray2));
+        end
+
     end
 
 end
diff --git a/matlab/test/arrow/type/tTime32Type.m 
b/matlab/test/arrow/type/tTime32Type.m
index d778237588..0bb467b1ba 100644
--- a/matlab/test/arrow/type/tTime32Type.m
+++ b/matlab/test/arrow/type/tTime32Type.m
@@ -119,6 +119,53 @@ classdef tTime32Type < hFixedWidthType
             testCase.verifyError(@() arrow.type.Time32Type(proxy), 
"arrow:proxy:ProxyNameMismatch");
         end
 
+        function IsEqualTrue(testCase)
+            % Verifies isequal method of arrow.type.Time32Type returns true if
+            % these conditions are met:
+            %
+            % 1. All input arguments have a class type arrow.type.Time32Type
+            % 2. All inputs have the same size
+            % 3. The TimeUnit values of elements at corresponding positions in 
the arrays are equal
+
+            % Scalar Time32Type arrays
+            time32Type1 = arrow.time32(TimeUnit="Second");
+            time32Type2 = arrow.time32(TimeUnit="Second");
+            time32Type3 = arrow.time32(TimeUnit="Millisecond");
+            time32Type4 = arrow.time32(TimeUnit="Millisecond");
+            testCase.verifyTrue(isequal(time32Type1, time32Type2));
+            testCase.verifyTrue(isequal(time32Type3, time32Type4));
+
+            % Non-scalar Time32Type arrays
+            typeArray1 = [time32Type1 time32Type3];
+            typeArray2 = [time32Type2 time32Type4];
+            testCase.verifyTrue(isequal(typeArray1, typeArray2));
+        end
+
+        function IsEqualFalse(testCase)
+            % Verify isequal returns false when expected.
+            time32Type1 = arrow.time32(TimeUnit="Second");
+            time32Type2 = arrow.time32(TimeUnit="Millisecond");
+            int32Type = arrow.int32();
+            testCase.verifyFalse(isequal(time32Type1, time32Type2));
+            testCase.verifyFalse(isequal(time32Type1, int32Type));
+
+            % Arrays have different dimensions
+            typeArray1 = [time32Type1 time32Type2];
+            typeArray2 = [time32Type1 time32Type2]';
+            testCase.verifyFalse(isequal(typeArray1, typeArray2));
+
+            % Corresponding elements have different TimeUnit values
+            typeArray3 = [time32Type2 time32Type1];
+            typeArray4 = [time32Type1 time32Type2]';
+            testCase.verifyFalse(isequal(typeArray3, typeArray4));
+
+            % Compare a nonscalar Time32Type array with a nonscalar
+            % Int32Type array.
+            typeArray5 = [int32Type int32Type];
+            testCase.verifyFalse(isequal(typeArray3, typeArray5));
+
+        end
+
     end
 
 end
diff --git a/matlab/test/arrow/type/tTime64Type.m 
b/matlab/test/arrow/type/tTime64Type.m
index a231a76c61..01460d9c1b 100644
--- a/matlab/test/arrow/type/tTime64Type.m
+++ b/matlab/test/arrow/type/tTime64Type.m
@@ -120,6 +120,52 @@ classdef tTime64Type < hFixedWidthType
             testCase.verifyError(@() arrow.type.Time64Type(proxy), 
"arrow:proxy:ProxyNameMismatch");
         end
 
+        function IsEqualTrue(testCase)
+            % Verifies isequal method of arrow.type.Time64Type returns true if
+            % these conditions are met:
+            %
+            % 1. All input arguments have a class type arrow.type.Time64Type
+            % 2. All inputs have the same size
+            % 3. The TimeUnit values of elements at corresponding positions in 
the arrays are equal
+
+            % Scalar Time64Type arrays
+            time64Type1 = arrow.time64(TimeUnit="Microsecond");
+            time64Type2 = arrow.time64(TimeUnit="Microsecond");
+            time64Type3 = arrow.time64(TimeUnit="Nanosecond");
+            time64Type4 = arrow.time64(TimeUnit="Nanosecond");
+            testCase.verifyTrue(isequal(time64Type1, time64Type2));
+            testCase.verifyTrue(isequal(time64Type3, time64Type4));
+
+            % Non-scalar Time64Type arrays
+            typeArray1 = [time64Type1 time64Type3];
+            typeArray2 = [time64Type2 time64Type4];
+            testCase.verifyTrue(isequal(typeArray1, typeArray2));
+        end
+
+        function IsEqualFalse(testCase)
+            % Verify isequal returns false when expected.
+            time64Type1 = arrow.time64(TimeUnit="Microsecond");
+            time64Type2 = arrow.time64(TimeUnit="Nanosecond");
+            int32Type = arrow.int32();
+            testCase.verifyFalse(isequal(time64Type1, time64Type2));
+            testCase.verifyFalse(isequal(time64Type1, int32Type));
+
+            % arrays have different dimensions
+            typeArray1 = [time64Type1 time64Type2];
+            typeArray2 = [time64Type1 time64Type2]';
+            testCase.verifyFalse(isequal(typeArray1, typeArray2));
+
+            % Corresponding elements have different TimeUnit values
+            typeArray3 = [time64Type2 time64Type1];
+            typeArray4 = [time64Type1 time64Type2]';
+            testCase.verifyFalse(isequal(typeArray3, typeArray4));
+
+            % Compare a nonscalar Time64Type array with a nonscalar
+            % Int32Type array.
+            typeArray5 = [int32Type int32Type];
+            testCase.verifyFalse(isequal(typeArray3, typeArray5));
+        end
+
     end
 
 end
diff --git a/matlab/test/arrow/type/tTimestampType.m 
b/matlab/test/arrow/type/tTimestampType.m
index 348c4b79da..6a626ebde7 100644
--- a/matlab/test/arrow/type/tTimestampType.m
+++ b/matlab/test/arrow/type/tTimestampType.m
@@ -23,6 +23,12 @@ classdef tTimestampType < hFixedWidthType
         ClassName = "arrow.type.TimestampType"
     end
 
+    properties(TestParameter)
+        % Test against both "Zoned" (i.e. non-empty TimeZone value) 
+        % and "Unzoned" (i.e. empty TimeZone value).
+        TimeZone={'America/Anchorage', ''}
+    end
+
     methods(Test)
         function TestClass(testCase)
         % Verify ArrowType is an object of the expected class type.
@@ -128,5 +134,69 @@ classdef tTimestampType < hFixedWidthType
             actualDisplay = evalc('disp(type)');
             testCase.verifyEqual(actualDisplay, expectedDisplay);
         end
+
+        function IsEqualTrue(testCase, TimeZone)
+            % Verifies isequal method of arrow.type.TimestampType returns 
+            % true if these conditions are met:
+            %
+            % 1. All input arguments have a class type arrow.type.TimestampType
+            % 2. All inputs have the same size
+            % 3. The TimeUnit values of elements at corresponding positions in 
the arrays are equal
+            % 4. The TimeZone values of elements at corresponding positions in 
the arrays are equal
+
+            % Scalar TimestampType arrays
+            timestampType1 = arrow.timestamp(TimeUnit="Second", 
TimeZone=TimeZone);
+            timestampType2 = arrow.timestamp(TimeUnit="Second", 
TimeZone=TimeZone);
+
+            timestampType3 = arrow.timestamp(TimeUnit="Millisecond", 
TimeZone=TimeZone);
+            time64Type4 = arrow.timestamp(TimeUnit="Millisecond", 
TimeZone=TimeZone);
+
+            timestampType5 = arrow.timestamp(TimeUnit="Microsecond", 
TimeZone=TimeZone);
+            timestampType6 = arrow.timestamp(TimeUnit="Microsecond", 
TimeZone=TimeZone);
+
+            timestampType7 = arrow.timestamp(TimeUnit="Nanosecond", 
TimeZone=TimeZone);
+            timestampType8 = arrow.timestamp(TimeUnit="Nanosecond", 
TimeZone=TimeZone);
+
+            % Scalar TimestampType arrays
+            testCase.verifyTrue(isequal(timestampType1, timestampType2));
+            testCase.verifyTrue(isequal(timestampType3, time64Type4));
+            testCase.verifyTrue(isequal(timestampType5, timestampType6));
+            testCase.verifyTrue(isequal(timestampType7, timestampType8));
+
+            % Non-scalar TimestampType arrays
+            typeArray1 = [timestampType1 timestampType3 timestampType5 
timestampType7];
+            typeArray2 = [timestampType2 time64Type4 timestampType6 
timestampType8];
+            testCase.verifyTrue(isequal(typeArray1, typeArray2));
+        end
+
+        function IsEqualFalse(testCase)
+            % Verify isequal returns false when expected.
+
+            timestampType1 = arrow.timestamp(TimeUnit="Second");
+            timestampType2 = arrow.timestamp(TimeUnit="Millisecond");
+            timestampType3 = arrow.timestamp(TimeUnit="Second", 
TimeZone="America/New_York");
+            timestampType4 = arrow.timestamp(TimeUnit="Second", 
TimeZone="Pacific/Fiji");
+            timestampType5 = arrow.timestamp(TimeUnit="Millisecond", 
TimeZone="America/New_York");
+
+            % TimeUnit values differ
+            testCase.verifyFalse(isequal(timestampType1, timestampType2));
+            testCase.verifyFalse(isequal(timestampType4, timestampType5));
+
+            % One TimestampType is zoned, while the other is unzoned.
+            testCase.verifyFalse(isequal(timestampType1, timestampType3));
+
+            % Both TimestampTypes are zoned, but have different values.
+            testCase.verifyFalse(isequal(timestampType3, timestampType4));
+
+            % Different dimensions
+            typeArray1 = [timestampType1 timestampType2 timestampType3];
+            typeArray2 = [timestampType1 timestampType2 timestampType3]';
+            testCase.verifyFalse(isequal(typeArray1, typeArray2));
+
+            % Different TimestampType values at corresponding elements
+            typeArray3 = [timestampType1 timestampType3 timestampType4];
+            typeArray4 = [timestampType1 timestampType2 timestampType4];
+            testCase.verifyFalse(isequal(typeArray3, typeArray4));
+        end
     end
 end
diff --git a/matlab/test/arrow/type/tUInt16Type.m 
b/matlab/test/arrow/type/tUInt16Type.m
index 8a803dc0a7..31e379a72d 100644
--- a/matlab/test/arrow/type/tUInt16Type.m
+++ b/matlab/test/arrow/type/tUInt16Type.m
@@ -22,4 +22,40 @@ classdef tUInt16Type < hFixedWidthType
         BitWidth = int32(16)
         ClassName = "arrow.type.UInt16Type"
     end
+
+    methods(Test)
+        function IsEqualTrue(testCase)
+            % Verifies isequal method of arrow.type.UInt16Type returns true if
+            % these conditions are met:
+            %
+            % 1. All input arguments have a class type arrow.type.UInt16Type
+            % 2. All inputs have the same size
+
+            % Scalar UInt16Type arrays
+            uint16Type1 = arrow.uint16();
+            uint16Type2 = arrow.uint16();
+            testCase.verifyTrue(isequal(uint16Type1, uint16Type2));
+
+            % Non-scalar UInt16Type arrays
+            typeArray1 = [uint16Type1 uint16Type1];
+            typeArray2 = [uint16Type2 uint16Type2];
+            testCase.verifyTrue(isequal(typeArray1, typeArray2));
+        end
+
+        function IsEqualFalse(testCase)
+            % Verifies the isequal method of arrow.type.UInt16Type returns
+            % false when expected.
+            
+            % Pass a different arrow.type.Type subclass to isequal
+            uint16Type = arrow.uint16();
+            int32Type = arrow.int32();
+            testCase.verifyFalse(isequal(uint16Type, int32Type));
+            testCase.verifyFalse(isequal([uint16Type uint16Type], [int32Type 
int32Type]));
+
+            % UInt16Type arrays have different sizes
+            typeArray1 = [uint16Type uint16Type];
+            typeArray2 = [uint16Type uint16Type]';
+            testCase.verifyFalse(isequal(typeArray1, typeArray2));
+        end
+    end
 end
\ No newline at end of file
diff --git a/matlab/test/arrow/type/tUInt32Type.m 
b/matlab/test/arrow/type/tUInt32Type.m
index 019b8ce269..fcadd3e6dc 100644
--- a/matlab/test/arrow/type/tUInt32Type.m
+++ b/matlab/test/arrow/type/tUInt32Type.m
@@ -22,4 +22,40 @@ classdef tUInt32Type < hFixedWidthType
         BitWidth = int32(32)
         ClassName = "arrow.type.UInt32Type"
     end
+
+    methods(Test)
+        function IsEqualTrue(testCase)
+            % Verifies isequal method of arrow.type.UInt32Type returns true if
+            % these conditions are met:
+            %
+            % 1. All input arguments have a class type arrow.type.UInt32Type
+            % 2. All inputs have the same size
+
+            % Scalar UInt32Type arrays
+            uint32Type1 = arrow.uint32();
+            uint32Type2 = arrow.uint32();
+            testCase.verifyTrue(isequal(uint32Type1, uint32Type2));
+
+            % Non-scalar UInt32Type arrays
+            typeArray1 = [uint32Type1 uint32Type1];
+            typeArray2 = [uint32Type2 uint32Type2];
+            testCase.verifyTrue(isequal(typeArray1, typeArray2));
+        end
+
+        function IsEqualFalse(testCase)
+            % Verifies the isequal method of arrow.type.UInt32Type returns
+            % false when expected.
+            
+            % Pass a different arrow.type.Type subclass to isequal
+            uint32Type = arrow.uint32();
+            int32Type = arrow.int32();
+            testCase.verifyFalse(isequal(uint32Type, int32Type));
+            testCase.verifyFalse(isequal([uint32Type uint32Type], [int32Type 
int32Type]));
+
+            % UInt32Type arrays have different sizes
+            typeArray1 = [uint32Type uint32Type];
+            typeArray2 = [uint32Type uint32Type]';
+            testCase.verifyFalse(isequal(typeArray1, typeArray2));
+        end
+    end
 end
\ No newline at end of file
diff --git a/matlab/test/arrow/type/tUInt64Type.m 
b/matlab/test/arrow/type/tUInt64Type.m
index 8287bb40d0..d1c7627d1c 100644
--- a/matlab/test/arrow/type/tUInt64Type.m
+++ b/matlab/test/arrow/type/tUInt64Type.m
@@ -22,4 +22,40 @@ classdef tUInt64Type < hFixedWidthType
         BitWidth = int32(64)
         ClassName = "arrow.type.UInt64Type"
     end
+
+    methods(Test)
+        function IsEqualTrue(testCase)
+            % Verifies isequal method of arrow.type.UInt64Type returns true if
+            % these conditions are met:
+            %
+            % 1. All input arguments have a class type arrow.type.UInt64Type
+            % 2. All inputs have the same size
+
+            % Scalar UInt64Type arrays
+            uint64Type1 = arrow.uint64();
+            uint64Type2 = arrow.uint64();
+            testCase.verifyTrue(isequal(uint64Type1, uint64Type2));
+
+            % Non-scalar UInt64Type arrays
+            typeArray1 = [uint64Type1 uint64Type1];
+            typeArray2 = [uint64Type2 uint64Type2];
+            testCase.verifyTrue(isequal(typeArray1, typeArray2));
+        end
+
+        function IsEqualFalse(testCase)
+            % Verifies the isequal method of arrow.type.UInt64Type returns
+            % false when expected.
+            
+            % Pass a different arrow.type.Type subclass to isequal
+            uint64Type = arrow.uint64();
+            int32Type = arrow.int32();
+            testCase.verifyFalse(isequal(uint64Type, int32Type));
+            testCase.verifyFalse(isequal([uint64Type uint64Type], [int32Type 
int32Type]));
+
+            % UInt64Type arrays have different sizes
+            typeArray1 = [uint64Type uint64Type];
+            typeArray2 = [uint64Type uint64Type]';
+            testCase.verifyFalse(isequal(typeArray1, typeArray2));
+        end
+    end
 end
\ No newline at end of file
diff --git a/matlab/test/arrow/type/tUInt8Type.m 
b/matlab/test/arrow/type/tUInt8Type.m
index 1ff203c862..62a7b95fd0 100644
--- a/matlab/test/arrow/type/tUInt8Type.m
+++ b/matlab/test/arrow/type/tUInt8Type.m
@@ -22,4 +22,40 @@ classdef tUInt8Type < hFixedWidthType
         BitWidth = int32(8)
         ClassName = "arrow.type.UInt8Type"
     end
+
+    methods(Test)
+        function IsEqualTrue(testCase)
+            % Verifies isequal method of arrow.type.UInt8Type returns true if
+            % these conditions are met:
+            %
+            % 1. All input arguments have a class type arrow.type.UInt8Type
+            % 2. All inputs have the same size
+
+            % Scalar UInt8Type arrays
+            uint8Type1 = arrow.uint8();
+            uint8Type2 = arrow.uint8();
+            testCase.verifyTrue(isequal(uint8Type1, uint8Type2));
+
+            % Non-scalar UInt8Type arrays
+            typeArray1 = [uint8Type1 uint8Type1];
+            typeArray2 = [uint8Type2 uint8Type2];
+            testCase.verifyTrue(isequal(typeArray1, typeArray2));
+        end
+
+        function IsEqualFalse(testCase)
+            % Verifies the isequal method of arrow.type.UInt8Type returns
+            % false when expected.
+            
+            % Pass a different arrow.type.Type subclass to isequal
+            uint8Type = arrow.uint8();
+            int32Type = arrow.int32();
+            testCase.verifyFalse(isequal(uint8Type, int32Type));
+            testCase.verifyFalse(isequal([uint8Type uint8Type], [int32Type 
int32Type]));
+
+            % UInt8Type arrays have different sizes
+            typeArray1 = [uint8Type uint8Type];
+            typeArray2 = [uint8Type uint8Type]';
+            testCase.verifyFalse(isequal(typeArray1, typeArray2));
+        end
+    end
 end
\ No newline at end of file


Reply via email to