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


##########
matlab/test/arrow/tabular/tRecordBatch.m:
##########
@@ -28,11 +28,15 @@ function Basic(tc)
         function SupportedTypes(tc)
             % Create a table all supported MATLAB types.
             import arrow.internal.test.tabular.createTableWithSupportedTypes
+            import arrow.type.traits.traits
 
             TOriginal = createTableWithSupportedTypes();
             arrowRecordBatch = arrow.recordBatch(TOriginal);
             expectedColumnNames = string(TOriginal.Properties.VariableNames);
-            tc.verifyRecordBatch(arrowRecordBatch, expectedColumnNames, 
TOriginal);
+
+            expectedArrayClasses = varfun(@(var) 
traits(string(class(var))).ArrayClassName, ...

Review Comment:
   Could you add a comment like the following here: "For each variable in the 
input MATLAB table, look up the corresponding Arrow Array type using type 
traits." 



##########
matlab/src/matlab/+arrow/+internal/+test/+tabular/createAllSupportedArrayTypes.m:
##########
@@ -0,0 +1,100 @@
+%CREATESUPPORTEDARRAYS Creates a MATLAB cell array containing all the
+%concrete subclasses of arrow.array.Array.
+
+% 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.
+
+function [arrowArrays, matlabData] = createAllSupportedArrayTypes(opts)
+    arguments
+        opts.NumRows(1, 1) {mustBeFinite, mustBeNonnegative} = 3;  
+    end
+
+    import arrow.type.ID
+    import arrow.array.*
+
+    classes = getArrayClassNames();
+    numClasses = numel(classes);
+    arrowArrays = cell(numClasses, 1);
+    matlabData  = cell(numClasses, 1);
+    
+    numericArrayToMatlabTypeDict = getArrowArrayToMatlabTypeDictionary();
+
+    for ii = 1:numel(classes)
+        name = classes(ii);
+        if name == "arrow.array.BooleanArray"
+            matlabData{ii} = randomLogicals(opts.NumRows);
+            arrowArrays{ii} = BooleanArray.fromMATLAB(matlabData{ii});
+        elseif isKey(numericArrayToMatlabTypeDict, name)
+            matlabType = numericArrayToMatlabTypeDict(name);
+            matlabData{ii} = randomNumbers(matlabType, opts.NumRows);
+            cmd = compose("%s.fromMATLAB(matlabData{ii})", name);
+            arrowArrays{ii} = eval(cmd);
+        elseif name == "arrow.array.StringArray"
+            matlabData{ii} = randomStrings(opts.NumRows);
+            arrowArrays{ii} = StringArray.fromMATLAB(matlabData{ii});
+        elseif name == "arrow.array.TimestampArray"
+            matlabData{ii} = randomDatetimes(opts.NumRows);
+            arrowArrays{ii} = TimestampArray.fromMATLAB(matlabData{ii});
+        elseif name == "arrow.array.Time32Array"
+            matlabData{ii} = randomDurations(opts.NumRows);
+            arrowArrays{ii} = Time32Array.fromMATLAB(matlabData{ii});
+        else
+            error("arrow:test:SupportedArrayCase", ...
+                "Missing if-branch for array class " + name); 
+        end
+    end
+end
+
+function classes = getArrayClassNames()
+    metaClass = meta.package.fromName("arrow.array").ClassList;
+    abstract = [metaClass.Abstract];

Review Comment:
   Maybe you could add a comment here explaining that this "removes all 
Abstract classes from the list of all subclasses"



##########
matlab/src/matlab/+arrow/+internal/+test/+tabular/createAllSupportedArrayTypes.m:
##########
@@ -0,0 +1,100 @@
+%CREATESUPPORTEDARRAYS Creates a MATLAB cell array containing all the

Review Comment:
   Maybe the description should include a note about the matlabData output 
argument



##########
matlab/src/matlab/+arrow/+internal/+test/+tabular/createAllSupportedArrayTypes.m:
##########
@@ -0,0 +1,100 @@
+%CREATESUPPORTEDARRAYS Creates a MATLAB cell array containing all the

Review Comment:
   CREATESUPPORTEDARRAYS -> CREATEALLSUPPORTEDARRAYTYPES



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to