Skip to content

Commit 4eca507

Browse files
apacheGH-49684: [MATLAB] Introduce deprecation warnings for "legacy" Feather V1 functions featherread and featherwrite (apache#49705)
### Rationale for this change In response to apache#49231 and https://lists.apache.org/thread/1npvnhjb1xwz09zh8vnd079zt2q4o08l, this pull request introduces deprecation warnings for the public MATLAB `featherread` and `featherwrite` APIs that allow reading and writing "legacy" Feather V1 files. The solution of introducing deprecation warnings follows the pyarrow approach proposed in apache#49590. **Examples** `featherread` ```matlab >> featherread("out.feather") Warning: Reading from Feather V1 files is deprecated. Use arrow.io.ipc.RecordBatchFileReader to read from Feather V2 (Arrow IPC) files. > In featherread (line 30) ``` `featherwrite` ```matlab >> featherwrite("out.feather", array2table(1)) Warning: Writing to Feather V1 files is deprecated. Use arrow.io.ipc.RecordBatchFileWriter to write to Feather V2 (Arrow IPC) files. > In featherread (line 31) ``` ### What changes are included in this PR? 1. Introduced a new warning with identifier `arrow:io:feather:v1:FeatherWriteDeprecated` when calling `featherwrite.m`. 2. Introduced a new warning with identifier `arrow:io:feather:v1:FeatherReadDeprecated` when calling `featherread.m`. ### Are these changes tested? Yes. 1. Updated `matlab/test/tfeather.m` to suppress `featherread` and `featherwrite` deprecation warnings. 2. Added two new test cases to `tfeather.m`: `VerifyFeatherReadDeprecationWarning` and `VerifyFeatherWriteDeprecationWarning`. These test cases verify that the expected deprecation warnings are issued as expected. 3. Updated `matlab/test/arrow/io/feather/tRoundTrip.m` to suppress `featherread` deprecation warnings. ### Are there any user-facing changes? Yes. 1. The `featherread` and `featherwrite` functions are user-facing. With these changes, deprecation warnings will be displayed when invoking either of these functions. **Note**: these warnings can be turned off in MATLAB by calling ` warning("off", "arrow:io:feather:v1:FeatherWriteDeprecated")` and `warning("off", "arrow:io:feather:v1:FeatherReadDeprecated")`. ### Future Directions 1. We may want to consider moving `featherread` and `featherwrite` into a package like `arrow.io.feather.v1.*` to mirror the rest of the mlarrow APIs. Alternatively, we could consider removing these functions entirely. ### Notes 1. Thank you @ sgilmore10 for your help with this pull request! * GitHub Issue: apache#49684 Lead-authored-by: Kevin Gurney <[email protected]> Co-authored-by: Sarah Gilmore <[email protected]> Signed-off-by: Kevin Gurney <[email protected]>
1 parent 47053cc commit 4eca507

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

matlab/src/matlab/featherread.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
filename(1, 1) string {mustBeNonmissing, mustBeNonzeroLengthText}
2828
end
2929

30+
warning("arrow:io:feather:v1:FeatherReadDeprecated", ...
31+
"Reading from Feather V1 files is deprecated. Use arrow.io.ipc.RecordBatchFileReader to read from Feather V2 (Arrow IPC) files.");
32+
33+
3034
typesToCast = [arrow.type.ID.UInt8, ...
3135
arrow.type.ID.UInt16, ...
3236
arrow.type.ID.UInt32, ...

matlab/src/matlab/featherwrite.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ function featherwrite(filename, t)
2828
t table
2929
end
3030

31+
warning("arrow:io:feather:v1:FeatherWriteDeprecated", ...
32+
"Writing to Feather V1 files is deprecated. Use arrow.io.ipc.RecordBatchFileWriter to write to Feather V2 (Arrow IPC) files.");
33+
3134
recordBatch = arrow.recordBatch(t);
3235
writer = arrow.internal.io.feather.Writer(filename);
3336
writer.write(recordBatch);

matlab/test/arrow/io/feather/tRoundTrip.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616
% permissions and limitations under the License.
1717
classdef tRoundTrip < matlab.unittest.TestCase
1818

19+
methods(TestMethodSetup)
20+
21+
function suppressFeatherV1Warnings(testCase)
22+
import matlab.unittest.fixtures.SuppressedWarningsFixture
23+
testCase.applyFixture(SuppressedWarningsFixture("arrow:io:feather:v1:FeatherReadDeprecated"));
24+
end
25+
26+
end
27+
1928
methods(Test)
2029
function Basic(testCase)
2130
import matlab.unittest.fixtures.TemporaryFolderFixture

matlab/test/tfeather.m

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ function setupTempWorkingDirectory(testCase)
2222
import matlab.unittest.fixtures.WorkingFolderFixture;
2323
testCase.applyFixture(WorkingFolderFixture);
2424
end
25+
26+
function suppressFeatherV1Warnings(testCase)
27+
import matlab.unittest.fixtures.SuppressedWarningsFixture
28+
testCase.applyFixture(SuppressedWarningsFixture("arrow:io:feather:v1:FeatherReadDeprecated"));
29+
testCase.applyFixture(SuppressedWarningsFixture("arrow:io:feather:v1:FeatherWriteDeprecated"));
30+
end
2531

2632
end
2733

@@ -267,6 +273,29 @@ function UnicodeVariableNames(testCase)
267273
testCase.verifyEqual(actualTable, expectedTable);
268274
end
269275

276+
function VerifyFeatherReadDeprecationWarning(testCase)
277+
filename = fullfile(pwd, 'temp.feather');
278+
279+
t = array2table([1, 2, 3]);
280+
featherwrite(filename, t);
281+
282+
warning("on", "arrow:io:feather:v1:FeatherReadDeprecated");
283+
fcn = @() featherread(filename);
284+
testCase.verifyWarning(fcn, "arrow:io:feather:v1:FeatherReadDeprecated")
285+
warning("off", "arrow:io:feather:v1:FeatherReadDeprecated");
286+
end
287+
288+
function VerifyFeatherWriteDeprecationWarning(testCase)
289+
filename = fullfile(pwd, 'temp.feather');
290+
291+
t = array2table([1, 2, 3]);
292+
293+
warning("on", "arrow:io:feather:v1:FeatherWriteDeprecated");
294+
fcn = @() featherwrite(filename, t);
295+
testCase.verifyWarning(fcn, "arrow:io:feather:v1:FeatherWriteDeprecated")
296+
warning("off", "arrow:io:feather:v1:FeatherReadDeprecated");
297+
end
298+
270299
end
271300
end
272301

0 commit comments

Comments
 (0)