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 756a5d76e9 GH-37230: [MATLAB] Add `arrow.type.Date64Type` class and 
`arrow.date64` construction function (#37578)
756a5d76e9 is described below

commit 756a5d76e9b87958b11f14ffa497f507ccb48d6d
Author: Kevin Gurney <[email protected]>
AuthorDate: Tue Sep 5 14:21:52 2023 -0400

    GH-37230: [MATLAB] Add `arrow.type.Date64Type` class and `arrow.date64` 
construction function (#37578)
    
    ### Rationale for this change
    
    In support of adding `arrow.array.Date64Array`, this pull request adds a 
new `arrow.type.Date64Type` class and associated `arrow.date64` construction 
function to the MATLAB interface.
    
    ### What changes are included in this PR?
    
    1. New `arrow.type.Date64Type` class.
    2. New `arrow.date64` construction function that returns an 
`arrow.type.Date64Type` instance.
    3. New `arrow.type.ID.Date64` type enumeration value.
    
    **Example**
    ```matlab
    >> type = arrow.date64()
    
    type =
    
      Date64Type with properties:
    
              ID: Date64
        DateUnit: Millisecond
    ```
    
    ### Are these changes tested?
    
    Yes.
    
    1. Added a new `tDate64Type` test class.
    2. Updated the `tID` test class to include `arrow.type.ID.Date64`.
    
    ### Are there any user-facing changes?
    
    Yes.
    
    1. There is a new public `arrow.type.Date64Type` class.
    2. There is a new public `arrow.date64` construction function.
    3. There is a new `arrow.type.ID.Date64` type enumeration value.
    
    ### Future Directions
    
    1. #37572
    2. #37577
    * Closes: #37230
    
    Authored-by: Kevin Gurney <[email protected]>
    Signed-off-by: Kevin Gurney <[email protected]>
---
 matlab/src/cpp/arrow/matlab/proxy/factory.cc       |  2 +
 .../src/cpp/arrow/matlab/type/proxy/date64_type.cc | 31 +++++++++
 .../src/cpp/arrow/matlab/type/proxy/date64_type.h  | 36 +++++++++++
 .../matlab/+arrow/{date32.m => +type/Date64Type.m} | 21 +++++--
 matlab/src/matlab/+arrow/+type/ID.m                |  2 +-
 matlab/src/matlab/+arrow/date32.m                  |  3 +-
 matlab/src/matlab/+arrow/{date32.m => date64.m}    |  9 +--
 matlab/test/arrow/type/tDate32Type.m               |  3 +-
 .../arrow/type/{tDate32Type.m => tDate64Type.m}    | 73 +++++++++++-----------
 matlab/test/arrow/type/tID.m                       |  1 +
 matlab/tools/cmake/BuildMatlabArrowInterface.cmake |  1 +
 11 files changed, 135 insertions(+), 47 deletions(-)

diff --git a/matlab/src/cpp/arrow/matlab/proxy/factory.cc 
b/matlab/src/cpp/arrow/matlab/proxy/factory.cc
index bc349bcfd5..5a7d284c0b 100644
--- a/matlab/src/cpp/arrow/matlab/proxy/factory.cc
+++ b/matlab/src/cpp/arrow/matlab/proxy/factory.cc
@@ -29,6 +29,7 @@
 #include "arrow/matlab/type/proxy/string_type.h"
 #include "arrow/matlab/type/proxy/timestamp_type.h"
 #include "arrow/matlab/type/proxy/date32_type.h"
+#include "arrow/matlab/type/proxy/date64_type.h"
 #include "arrow/matlab/type/proxy/time32_type.h"
 #include "arrow/matlab/type/proxy/time64_type.h"
 #include "arrow/matlab/type/proxy/field.h"
@@ -76,6 +77,7 @@ libmexclass::proxy::MakeResult Factory::make_proxy(const 
ClassName& class_name,
     REGISTER_PROXY(arrow.type.proxy.Time32Type     , 
arrow::matlab::type::proxy::Time32Type);
     REGISTER_PROXY(arrow.type.proxy.Time64Type     , 
arrow::matlab::type::proxy::Time64Type);
     REGISTER_PROXY(arrow.type.proxy.Date32Type     , 
arrow::matlab::type::proxy::Date32Type);
+    REGISTER_PROXY(arrow.type.proxy.Date64Type     , 
arrow::matlab::type::proxy::Date64Type);
     REGISTER_PROXY(arrow.io.feather.proxy.Writer   , 
arrow::matlab::io::feather::proxy::Writer);
     REGISTER_PROXY(arrow.io.feather.proxy.Reader   , 
arrow::matlab::io::feather::proxy::Reader);
 
diff --git a/matlab/src/cpp/arrow/matlab/type/proxy/date64_type.cc 
b/matlab/src/cpp/arrow/matlab/type/proxy/date64_type.cc
new file mode 100644
index 0000000000..413b73afa6
--- /dev/null
+++ b/matlab/src/cpp/arrow/matlab/type/proxy/date64_type.cc
@@ -0,0 +1,31 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "arrow/matlab/type/proxy/date64_type.h"
+
+namespace arrow::matlab::type::proxy {
+
+    Date64Type::Date64Type(std::shared_ptr<arrow::Date64Type> date64_type) : 
DateType(std::move(date64_type)) {}
+
+    libmexclass::proxy::MakeResult Date64Type::make(const 
libmexclass::proxy::FunctionArguments& constructor_arguments) {
+        using Date64TypeProxy = arrow::matlab::type::proxy::Date64Type;
+
+        const auto type = arrow::date64();
+        const auto date64_type = 
std::static_pointer_cast<arrow::Date64Type>(type);
+        return std::make_shared<Date64TypeProxy>(std::move(date64_type));
+    }
+}
diff --git a/matlab/src/cpp/arrow/matlab/type/proxy/date64_type.h 
b/matlab/src/cpp/arrow/matlab/type/proxy/date64_type.h
new file mode 100644
index 0000000000..f0712c73b8
--- /dev/null
+++ b/matlab/src/cpp/arrow/matlab/type/proxy/date64_type.h
@@ -0,0 +1,36 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include "arrow/matlab/type/proxy/date_type.h"
+
+namespace arrow::matlab::type::proxy {
+
+    class Date64Type : public arrow::matlab::type::proxy::DateType {
+
+        public:
+            Date64Type(std::shared_ptr<arrow::Date64Type> date64_type);
+
+            ~Date64Type() {}
+
+            static libmexclass::proxy::MakeResult make(const 
libmexclass::proxy::FunctionArguments& constructor_arguments);
+
+    };
+
+}
+
diff --git a/matlab/src/matlab/+arrow/date32.m 
b/matlab/src/matlab/+arrow/+type/Date64Type.m
similarity index 66%
copy from matlab/src/matlab/+arrow/date32.m
copy to matlab/src/matlab/+arrow/+type/Date64Type.m
index a64cb7c419..3c5f02c6ef 100644
--- a/matlab/src/matlab/+arrow/date32.m
+++ b/matlab/src/matlab/+arrow/+type/Date64Type.m
@@ -1,3 +1,5 @@
+%DATE64TYPE Type class for date64 data.
+
 % Licensed to the Apache Software Foundation (ASF) under one or more
 % contributor license agreements.  See the NOTICE file distributed with
 % this work for additional information regarding copyright ownership.
@@ -13,8 +15,19 @@
 % implied.  See the License for the specific language governing
 % permissions and limitations under the License.
 
-function type = date32()
-%DATE32 Creates an arrow.type.Date32Type object
-    proxy = arrow.internal.proxy.create("arrow.type.proxy.Date32Type");
-    type = arrow.type.Date32Type(proxy);
+classdef Date64Type < arrow.type.DateType
+
+    methods
+
+        function obj = Date64Type(proxy)
+            arguments
+                proxy(1, 1) libmexclass.proxy.Proxy {validate(proxy, 
"arrow.type.proxy.Date64Type")}
+            end
+            import arrow.internal.proxy.validate
+
+            [email protected](proxy);
+        end
+
+    end
+
 end
diff --git a/matlab/src/matlab/+arrow/+type/ID.m 
b/matlab/src/matlab/+arrow/+type/ID.m
index 66ea3a5c7f..646edb85c6 100644
--- a/matlab/src/matlab/+arrow/+type/ID.m
+++ b/matlab/src/matlab/+arrow/+type/ID.m
@@ -33,7 +33,7 @@ classdef ID < uint64
         % Binary (14)
         % FixedSizeBinary (15)
         Date32 (16)
-        % Date64 (17)
+        Date64 (17)
         Timestamp (18)
         Time32    (19)
         Time64    (20)
diff --git a/matlab/src/matlab/+arrow/date32.m 
b/matlab/src/matlab/+arrow/date32.m
index a64cb7c419..60039a24a5 100644
--- a/matlab/src/matlab/+arrow/date32.m
+++ b/matlab/src/matlab/+arrow/date32.m
@@ -1,3 +1,5 @@
+%DATE32 Creates an arrow.type.Date32Type object
+
 % Licensed to the Apache Software Foundation (ASF) under one or more
 % contributor license agreements.  See the NOTICE file distributed with
 % this work for additional information regarding copyright ownership.
@@ -14,7 +16,6 @@
 % permissions and limitations under the License.
 
 function type = date32()
-%DATE32 Creates an arrow.type.Date32Type object
     proxy = arrow.internal.proxy.create("arrow.type.proxy.Date32Type");
     type = arrow.type.Date32Type(proxy);
 end
diff --git a/matlab/src/matlab/+arrow/date32.m 
b/matlab/src/matlab/+arrow/date64.m
similarity index 81%
copy from matlab/src/matlab/+arrow/date32.m
copy to matlab/src/matlab/+arrow/date64.m
index a64cb7c419..e3968a7b4c 100644
--- a/matlab/src/matlab/+arrow/date32.m
+++ b/matlab/src/matlab/+arrow/date64.m
@@ -1,3 +1,5 @@
+%DATE64 Creates an arrow.type.Date64Type object
+
 % Licensed to the Apache Software Foundation (ASF) under one or more
 % contributor license agreements.  See the NOTICE file distributed with
 % this work for additional information regarding copyright ownership.
@@ -13,8 +15,7 @@
 % implied.  See the License for the specific language governing
 % permissions and limitations under the License.
 
-function type = date32()
-%DATE32 Creates an arrow.type.Date32Type object
-    proxy = arrow.internal.proxy.create("arrow.type.proxy.Date32Type");
-    type = arrow.type.Date32Type(proxy);
+function type = date64()
+    proxy = arrow.internal.proxy.create("arrow.type.proxy.Date64Type");
+    type = arrow.type.Date64Type(proxy);
 end
diff --git a/matlab/test/arrow/type/tDate32Type.m 
b/matlab/test/arrow/type/tDate32Type.m
index 3c99bd1fc9..71a9e5cf48 100644
--- a/matlab/test/arrow/type/tDate32Type.m
+++ b/matlab/test/arrow/type/tDate32Type.m
@@ -1,3 +1,5 @@
+% Test class for arrow.type.Date32Type and arrow.date32
+
 % Licensed to the Apache Software Foundation (ASF) under one or more
 % contributor license agreements.  See the NOTICE file distributed with
 % this work for additional information regarding copyright ownership.
@@ -14,7 +16,6 @@
 % permissions and limitations under the License.
 
 classdef tDate32Type < hFixedWidthType
-% Test class for arrow.type.Date32Type and arrow.date32
 
     properties
         ConstructionFcn = @arrow.date32
diff --git a/matlab/test/arrow/type/tDate32Type.m 
b/matlab/test/arrow/type/tDate64Type.m
similarity index 64%
copy from matlab/test/arrow/type/tDate32Type.m
copy to matlab/test/arrow/type/tDate64Type.m
index 3c99bd1fc9..9345f6dbde 100644
--- a/matlab/test/arrow/type/tDate32Type.m
+++ b/matlab/test/arrow/type/tDate64Type.m
@@ -1,3 +1,5 @@
+% Test class for arrow.type.Date64Type and arrow.date64
+
 % Licensed to the Apache Software Foundation (ASF) under one or more
 % contributor license agreements.  See the NOTICE file distributed with
 % this work for additional information regarding copyright ownership.
@@ -13,15 +15,14 @@
 % implied.  See the License for the specific language governing
 % permissions and limitations under the License.
 
-classdef tDate32Type < hFixedWidthType
-% Test class for arrow.type.Date32Type and arrow.date32
+classdef tDate64Type < hFixedWidthType
 
     properties
-        ConstructionFcn = @arrow.date32
-        ArrowType = arrow.date32
-        TypeID = arrow.type.ID.Date32
-        BitWidth = int32(32)
-        ClassName = "arrow.type.Date32Type"
+        ConstructionFcn = @arrow.date64
+        ArrowType = arrow.date64
+        TypeID = arrow.type.ID.Date64
+        BitWidth = int32(64)
+        ClassName = "arrow.type.Date64Type"
     end
 
     methods(Test)
@@ -32,28 +33,28 @@ classdef tDate32Type < hFixedWidthType
         end
 
         function DefaultDateUnit(testCase)
-            % Verify the default DateUnit is Day.
+            % Verify the default DateUnit is Millisecond.
             type = testCase.ArrowType;
             actualUnit = type.DateUnit;
-            expectedUnit = arrow.type.DateUnit.Day;
+            expectedUnit = arrow.type.DateUnit.Millisecond;
             testCase.verifyEqual(actualUnit, expectedUnit);
         end
 
         function Display(testCase)
-            % Verify the display of Date32Type objects.
+            % Verify the display of Date64Type objects.
             %
             % Example:
             %
             %  Date32Type with properties:
             %
-            %          ID: Date32
-            %    DateUnit: Day
+            %          ID: Date64
+            %    DateUnit: Millisecond
             %
             type = testCase.ConstructionFcn(); %#ok<NASGU>
-            classnameLink = "<a href=""matlab:helpPopup 
arrow.type.Date32Type"" style=""font-weight:bold"">Date32Type</a>";
+            classnameLink = "<a href=""matlab:helpPopup 
arrow.type.Date64Type"" style=""font-weight:bold"">Date64Type</a>";
             header = "  " + classnameLink + " with properties:" + newline;
             body = strjust(pad(["ID:"; "DateUnit:"]));
-            body = body + " " + ["Date32"; "Day"];
+            body = body + " " + ["Date64"; "Millisecond"];
             body = "    " + body;
             footer = string(newline);
             expectedDisplay = char(strjoin([header body' footer], newline));
@@ -64,52 +65,52 @@ classdef tDate32Type < hFixedWidthType
         function DateUnitNoSetter(testCase)
             % Verify that an error is thrown when trying to set the value
             % of the DateUnit property.
-            type = arrow.date32();
-            testCase.verifyError(@() setfield(type, "DateUnit", 
"Millisecond"), "MATLAB:class:SetProhibited");
+            type = arrow.date64();
+            testCase.verifyError(@() setfield(type, "DateUnit", "Day"), 
"MATLAB:class:SetProhibited");
         end
 
         function InvalidProxy(testCase)
             % Verify that an error is thrown when a Proxy of an unexpected
-            % type is passed to the arrow.type.Date32Type constructor.
+            % type is passed to the arrow.type.Date64Type constructor.
             array = arrow.array([1, 2, 3]);
             proxy = array.Proxy;
-            testCase.verifyError(@() arrow.type.Date32Type(proxy), 
"arrow:proxy:ProxyNameMismatch");
+            testCase.verifyError(@() arrow.type.Date64Type(proxy), 
"arrow:proxy:ProxyNameMismatch");
         end
 
         function IsEqualTrue(testCase)
-            % Verifies isequal method of arrow.type.Date32Type returns true if
+            % Verifies isequal method of arrow.type.Date64Type returns true if
             % these conditions are met:
             %
-            % 1. All input arguments have a class type arrow.type.Date32Type
+            % 1. All input arguments have a class type arrow.type.Date64Type
             % 2. All inputs have the same size
 
-            % Scalar Date32Type arrays
-            date32Type1 = arrow.date32();
-            date32Type2 = arrow.date32();
-            testCase.verifyTrue(isequal(date32Type1, date32Type2));
+            % Scalar Date64Type arrays
+            date64Type1 = arrow.date64();
+            date64Type2 = arrow.date64();
+            testCase.verifyTrue(isequal(date64Type1, date64Type2));
 
-            % Non-scalar Date32Type arrays
-            typeArray1 = [date32Type1 date32Type1];
-            typeArray2 = [date32Type2 date32Type2];
+            % Non-scalar Date64Type arrays
+            typeArray1 = [date64Type1 date64Type1];
+            typeArray2 = [date64Type2 date64Type2];
             testCase.verifyTrue(isequal(typeArray1, typeArray2));
         end
 
         function IsEqualFalse(testCase)
-            % Verifies the isequal method of arrow.type.Date32Type returns
+            % Verifies the isequal method of arrow.type.Date64Type returns
             % false when expected.
-            
+
             % Pass a different arrow.type.Type subclass to isequal
-            date32Type = arrow.date32();
+            date64Type = arrow.date64();
             int32Type = arrow.int32();
-            testCase.verifyFalse(isequal(date32Type, int32Type));
-            testCase.verifyFalse(isequal([date32Type date32Type], [int32Type 
int32Type]));
+            testCase.verifyFalse(isequal(date64Type, int32Type));
+            testCase.verifyFalse(isequal([date64Type date64Type], [int32Type 
int32Type]));
 
-            % Date32Type arrays have different sizes
-            typeArray1 = [date32Type date32Type];
-            typeArray2 = [date32Type date32Type]';
+            % Date64Type arrays have different sizes
+            typeArray1 = [date64Type date64Type];
+            typeArray2 = [date64Type date64Type]';
             testCase.verifyFalse(isequal(typeArray1, typeArray2));
         end
-    
+
     end
 
 end
diff --git a/matlab/test/arrow/type/tID.m b/matlab/test/arrow/type/tID.m
index d83bb4475f..b69cd89842 100644
--- a/matlab/test/arrow/type/tID.m
+++ b/matlab/test/arrow/type/tID.m
@@ -43,6 +43,7 @@ classdef tID < matlab.unittest.TestCase
                 ID.Float64,   12, ...
                 ID.String,    13, ...
                 ID.Date32,    16, ...
+                ID.Date64,    17, ...
                 ID.Timestamp, 18, ...
                 ID.Time32,    19, ...
                 ID.Time64,    20  ...
diff --git a/matlab/tools/cmake/BuildMatlabArrowInterface.cmake 
b/matlab/tools/cmake/BuildMatlabArrowInterface.cmake
index 3cead42cea..2d95682bc2 100644
--- a/matlab/tools/cmake/BuildMatlabArrowInterface.cmake
+++ b/matlab/tools/cmake/BuildMatlabArrowInterface.cmake
@@ -59,6 +59,7 @@ set(MATLAB_ARROW_LIBMEXCLASS_CLIENT_PROXY_SOURCES 
"${CMAKE_SOURCE_DIR}/src/cpp/a
                                                   
"${CMAKE_SOURCE_DIR}/src/cpp/arrow/matlab/type/proxy/string_type.cc"
                                                   
"${CMAKE_SOURCE_DIR}/src/cpp/arrow/matlab/type/proxy/date_type.cc"
                                                   
"${CMAKE_SOURCE_DIR}/src/cpp/arrow/matlab/type/proxy/date32_type.cc"
+                                                  
"${CMAKE_SOURCE_DIR}/src/cpp/arrow/matlab/type/proxy/date64_type.cc"
                                                   
"${CMAKE_SOURCE_DIR}/src/cpp/arrow/matlab/type/proxy/timestamp_type.cc"
                                                   
"${CMAKE_SOURCE_DIR}/src/cpp/arrow/matlab/type/proxy/time_type.cc"
                                                   
"${CMAKE_SOURCE_DIR}/src/cpp/arrow/matlab/type/proxy/time32_type.cc"

Reply via email to