diff --git a/matlab/test/arrow/io/ipc/tRecordBatchStreamReader.m b/matlab/test/arrow/io/ipc/tRecordBatchStreamReader.m index 584002e586b00..eb66c5fefcba9 100644 --- a/matlab/test/arrow/io/ipc/tRecordBatchStreamReader.m +++ b/matlab/test/arrow/io/ipc/tRecordBatchStreamReader.m @@ -21,6 +21,7 @@ ZeroBatchStreamFile OneBatchStreamFile MultipleBatchStreamFile + RandomAccessFile end properties (TestParameter) @@ -35,6 +36,16 @@ function setupDataFolder(testCase) testCase.DataFolder = string(fixture.Folder); end + function setupRandomAccessFile(testCase) + fieldA = arrow.field("A", arrow.string()); + fieldB = arrow.field("B", arrow.float32()); + schema = arrow.schema([fieldA, fieldB]); + fname = fullfile(testCase.DataFolder, "RandomAccessFile.arrow"); + writer = arrow.io.ipc.RecordBatchFileWriter(fname, schema); + writer.close(); + testCase.RandomAccessFile = fname; + end + function setupZeroBatchStreamFile(testCase) fieldA = arrow.field("A", arrow.string()); fieldB = arrow.field("B", arrow.float32()); @@ -249,7 +260,7 @@ function ReadTableOneBatchStreamFile(testCase) function ReadTableMultipleBatchStreamFile(testCase) % Verify read can successfully read an Arrow IPC Stream file - % containing one batch as an arrow.tabular.Table. + % containing multiple batches as an arrow.tabular.Table. reader = arrow.io.ipc.RecordBatchStreamReader(testCase.MultipleBatchStreamFile); matlabTable = table(["Row1"; "Row2"; "Row3"; "Row4"], single([1; 2; 3; 4]), VariableNames=["A", "B"]); expected = arrow.table(matlabTable); @@ -312,6 +323,14 @@ function ReadTableMultipleCalls(testCase) testCase.verifyTrue(reader.done()); end + function ErrorIfNotIpcStreamFile(testCase) + % Verify RecordBatchStreamReader throws an exception with the + % identifier arrow:io:ipc:FailedToOpenRecordBatchReader if + % the provided file is not an Arrow IPC Stream file. + fcn = @() arrow.io.ipc.RecordBatchStreamReader(testCase.RandomAccessFile); + testCase.verifyError(fcn, "arrow:io:ipc:FailedToOpenRecordBatchReader"); + end + end end \ No newline at end of file