Skip to content

Commit

Permalink
GH-37222: [Docs][MATLAB] Rename arrow.recordbatch (all lowercase) t…
Browse files Browse the repository at this point in the history
…o `arrow.recordBatch` (camelCase) (#37223)

### Rationale for this change

As @ kou suggested in #37215 (comment), it makes sense to rename `arrow.recordbatch` (all lowercase) to `arrow.recordBatch` (camelCase).

`recordBatch` is the first "two-word" function in the top-level `arrow.*` package, so it makes sense to establish a clear camelCase standard for "multi-word" functions in the MATLAB interface at this point.

One part of the rationale motivating this change is that other language bindings follow a similar pattern (e.g. `pyarrow.record_batch` instead of `pyarrow.recordbatch`).

### What changes are included in this PR?

1. Renamed `arrow.recordbatch` (all lowercase) to `arrow.recordBatch` (camelCase).
2. Updated documentation and tests to reflect `arrow.recordbatch` being renamed to `arrow.recordBatch`.

### Are these changes tested?

Yes.

1. All existing MATLAB tests have been updated to use the new name `arrow.recordbatch` and are passing on my Debian 11 machine.

### Are there any user-facing changes?

Yes.

**This PR includes breaking changes to public APIs.**

The public facing API `arrow.recordbatch` has been renamed to `arrow.recordBatch`. Since the MATLAB interface is still "pre 1.0", we don't expect this change to have a significant impact.

### Notes

1. Thank you @ sgilmore10 for your help with this pull request!
* Closes: #37222

Lead-authored-by: Kevin Gurney <[email protected]>
Co-authored-by: Sarah Gilmore <[email protected]>
Signed-off-by: Kevin Gurney <[email protected]>
  • Loading branch information
kevingurney and sgilmore10 authored Aug 17, 2023
1 parent 7d8e4b1 commit e44f5eb
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions matlab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ matlabTable =
"B" 2 false
"C" 3 true
>> arrowRecordBatch = arrow.recordbatch(matlabTable)
>> arrowRecordBatch = arrow.recordBatch(matlabTable)
arrowRecordBatch =
Expand Down Expand Up @@ -557,7 +557,7 @@ matlabTable =
"B" 2
"C" 3
>> arrowRecordBatch = arrow.recordbatch(matlabTable)
>> arrowRecordBatch = arrow.recordBatch(matlabTable)
arrowRecordBatch =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
% 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 rb = recordbatch(T)
function rb = recordBatch(T)
arguments
T table
end
Expand Down
2 changes: 1 addition & 1 deletion matlab/src/matlab/featherwrite.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function featherwrite(filename, t)
t table
end

recordBatch = arrow.recordbatch(t);
recordBatch = arrow.recordBatch(t);
writer = arrow.internal.io.feather.Writer(filename);
writer.write(recordBatch);
end
2 changes: 1 addition & 1 deletion matlab/test/arrow/io/feather/tRoundTrip.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function Basic(testCase)
SingleVar = single([10; 15; 20; 25]);

tableWrite = table(DoubleVar, SingleVar);
recordBatchWrite = arrow.recordbatch(tableWrite);
recordBatchWrite = arrow.recordBatch(tableWrite);

writer = Writer(filename);
writer.write(recordBatchWrite);
Expand Down
30 changes: 15 additions & 15 deletions matlab/test/arrow/tabular/tRecordBatch.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

function Basic(tc)
T = table([1, 2, 3]');
arrowRecordBatch = arrow.recordbatch(T);
arrowRecordBatch = arrow.recordBatch(T);
className = string(class(arrowRecordBatch));
tc.verifyEqual(className, "arrow.tabular.RecordBatch");
end
Expand All @@ -30,29 +30,29 @@ function SupportedTypes(tc)
import arrow.internal.test.tabular.createTableWithSupportedTypes

TOriginal = createTableWithSupportedTypes();
arrowRecordBatch = arrow.recordbatch(TOriginal);
arrowRecordBatch = arrow.recordBatch(TOriginal);
expectedColumnNames = string(TOriginal.Properties.VariableNames);
tc.verifyRecordBatch(arrowRecordBatch, expectedColumnNames, TOriginal);
end

function ToMATLAB(tc)
TOriginal = table([1, 2, 3]');
arrowRecordBatch = arrow.recordbatch(TOriginal);
arrowRecordBatch = arrow.recordBatch(TOriginal);
TConverted = arrowRecordBatch.toMATLAB();
tc.verifyEqual(TOriginal, TConverted);
end

function Table(tc)
TOriginal = table([1, 2, 3]');
arrowRecordBatch = arrow.recordbatch(TOriginal);
arrowRecordBatch = arrow.recordBatch(TOriginal);
TConverted = table(arrowRecordBatch);
tc.verifyEqual(TOriginal, TConverted);
end

function ColumnNames(tc)
columnNames = ["A", "B", "C"];
TOriginal = table(1, 2, 3, VariableNames=columnNames);
arrowRecordBatch = arrow.recordbatch(TOriginal);
arrowRecordBatch = arrow.recordBatch(TOriginal);
tc.verifyEqual(arrowRecordBatch.ColumnNames, columnNames);
end

Expand All @@ -61,7 +61,7 @@ function NumColumns(tc)

for nc = numColumns
T = array2table(ones(1, nc));
arrowRecordBatch = arrow.recordbatch(T);
arrowRecordBatch = arrow.recordBatch(T);
tc.verifyEqual(arrowRecordBatch.NumColumns, nc);
end
end
Expand All @@ -72,50 +72,50 @@ function UnicodeColumnNames(tc)
mango = "🥭";
columnNames = [smiley, tree, mango];
TOriginal = table(1, 2, 3, VariableNames=columnNames);
arrowRecordBatch = arrow.recordbatch(TOriginal);
arrowRecordBatch = arrow.recordBatch(TOriginal);
tc.verifyEqual(arrowRecordBatch.ColumnNames, columnNames);
TConverted = arrowRecordBatch.toMATLAB();
tc.verifyEqual(TOriginal, TConverted);
end

function EmptyTable(tc)
TOriginal = table();
arrowRecordBatch = arrow.recordbatch(TOriginal);
arrowRecordBatch = arrow.recordBatch(TOriginal);
TConverted = arrowRecordBatch.toMATLAB();
tc.verifyEqual(TOriginal, TConverted);
end

function EmptyRecordBatchColumnIndexError(tc)
TOriginal = table();
arrowRecordBatch = arrow.recordbatch(TOriginal);
arrowRecordBatch = arrow.recordBatch(TOriginal);
fcn = @() arrowRecordBatch.column(1);
tc.verifyError(fcn, "arrow:tabular:recordbatch:NumericIndexWithEmptyRecordBatch");
end

function InvalidNumericIndexError(tc)
TOriginal = table(1, 2, 3);
arrowRecordBatch = arrow.recordbatch(TOriginal);
arrowRecordBatch = arrow.recordBatch(TOriginal);
fcn = @() arrowRecordBatch.column(4);
tc.verifyError(fcn, "arrow:tabular:recordbatch:InvalidNumericColumnIndex");
end

function UnsupportedColumnIndexType(tc)
TOriginal = table(1, 2, 3);
arrowRecordBatch = arrow.recordbatch(TOriginal);
arrowRecordBatch = arrow.recordBatch(TOriginal);
fcn = @() arrowRecordBatch.column(datetime(2022, 1, 3));
tc.verifyError(fcn, "arrow:badsubscript:NonNumeric");
end

function ErrorIfIndexIsNonScalar(tc)
TOriginal = table(1, 2, 3);
arrowRecordBatch = arrow.recordbatch(TOriginal);
arrowRecordBatch = arrow.recordBatch(TOriginal);
fcn = @() arrowRecordBatch.column([1 2]);
tc.verifyError(fcn, "MATLAB:expectedScalar");
end

function ErrorIfIndexIsNonPositive(tc)
TOriginal = table(1, 2, 3);
arrowRecordBatch = arrow.recordbatch(TOriginal);
arrowRecordBatch = arrow.recordBatch(TOriginal);
fcn = @() arrowRecordBatch.column(-1);
tc.verifyError(fcn, "arrow:badsubscript:NonPositive");
end
Expand Down Expand Up @@ -203,7 +203,7 @@ function Schema(tc)
[1; 2; 3], ...
[true; false; true], ...
VariableNames=["A", "B", "C"]);
recordBatch = arrow.recordbatch(t);
recordBatch = arrow.recordBatch(t);
schema = recordBatch.Schema;
tc.verifyEqual(schema.NumFields, int32(3));
tc.verifyEqual(schema.field(1).Type.ID, arrow.type.ID.String);
Expand All @@ -218,7 +218,7 @@ function SchemaNoSetter(tc)
% Verify that trying to set the value of the public Schema property
% results in an error of type "MATLAB:class:SetProhibited".
t = table([1; 2; 3]);
recordBatch = arrow.recordbatch(t);
recordBatch = arrow.recordBatch(t);
tc.verifyError(@() setfield(recordBatch, "Schema", "Value"), ...
"MATLAB:class:SetProhibited");
end
Expand Down

0 comments on commit e44f5eb

Please sign in to comment.