diff --git a/matlab/src/matlab/featherread.m b/matlab/src/matlab/featherread.m index 736fe832888c..b330b8943067 100644 --- a/matlab/src/matlab/featherread.m +++ b/matlab/src/matlab/featherread.m @@ -27,6 +27,10 @@ filename(1, 1) string {mustBeNonmissing, mustBeNonzeroLengthText} end + warning("arrow:io:feather:v1:FeatherReadDeprecated", ... + "Reading from Feather V1 files is deprecated. Use arrow.io.ipc.RecordBatchFileReader to read from Feather V2 (Arrow IPC) files."); + + typesToCast = [arrow.type.ID.UInt8, ... arrow.type.ID.UInt16, ... arrow.type.ID.UInt32, ... diff --git a/matlab/src/matlab/featherwrite.m b/matlab/src/matlab/featherwrite.m index 27fa5dfbb389..337ba789620f 100644 --- a/matlab/src/matlab/featherwrite.m +++ b/matlab/src/matlab/featherwrite.m @@ -28,6 +28,9 @@ function featherwrite(filename, t) t table end + warning("arrow:io:feather:v1:FeatherWriteDeprecated", ... + "Writing to Feather V1 files is deprecated. Use arrow.io.ipc.RecordBatchFileWriter to write to Feather V2 (Arrow IPC) files."); + recordBatch = arrow.recordBatch(t); writer = arrow.internal.io.feather.Writer(filename); writer.write(recordBatch); diff --git a/matlab/test/arrow/io/feather/tRoundTrip.m b/matlab/test/arrow/io/feather/tRoundTrip.m index 6fa88d155d9e..a1e576a03f58 100644 --- a/matlab/test/arrow/io/feather/tRoundTrip.m +++ b/matlab/test/arrow/io/feather/tRoundTrip.m @@ -16,6 +16,15 @@ % permissions and limitations under the License. classdef tRoundTrip < matlab.unittest.TestCase + methods(TestMethodSetup) + + function suppressFeatherV1Warnings(testCase) + import matlab.unittest.fixtures.SuppressedWarningsFixture + testCase.applyFixture(SuppressedWarningsFixture("arrow:io:feather:v1:FeatherReadDeprecated")); + end + + end + methods(Test) function Basic(testCase) import matlab.unittest.fixtures.TemporaryFolderFixture diff --git a/matlab/test/tfeather.m b/matlab/test/tfeather.m index b24b6b4af1de..5d3b9c6f6396 100755 --- a/matlab/test/tfeather.m +++ b/matlab/test/tfeather.m @@ -22,6 +22,12 @@ function setupTempWorkingDirectory(testCase) import matlab.unittest.fixtures.WorkingFolderFixture; testCase.applyFixture(WorkingFolderFixture); end + + function suppressFeatherV1Warnings(testCase) + import matlab.unittest.fixtures.SuppressedWarningsFixture + testCase.applyFixture(SuppressedWarningsFixture("arrow:io:feather:v1:FeatherReadDeprecated")); + testCase.applyFixture(SuppressedWarningsFixture("arrow:io:feather:v1:FeatherWriteDeprecated")); + end end @@ -267,6 +273,29 @@ function UnicodeVariableNames(testCase) testCase.verifyEqual(actualTable, expectedTable); end + function VerifyFeatherReadDeprecationWarning(testCase) + filename = fullfile(pwd, 'temp.feather'); + + t = array2table([1, 2, 3]); + featherwrite(filename, t); + + warning("on", "arrow:io:feather:v1:FeatherReadDeprecated"); + fcn = @() featherread(filename); + testCase.verifyWarning(fcn, "arrow:io:feather:v1:FeatherReadDeprecated") + warning("off", "arrow:io:feather:v1:FeatherReadDeprecated"); + end + + function VerifyFeatherWriteDeprecationWarning(testCase) + filename = fullfile(pwd, 'temp.feather'); + + t = array2table([1, 2, 3]); + + warning("on", "arrow:io:feather:v1:FeatherWriteDeprecated"); + fcn = @() featherwrite(filename, t); + testCase.verifyWarning(fcn, "arrow:io:feather:v1:FeatherWriteDeprecated") + warning("off", "arrow:io:feather:v1:FeatherReadDeprecated"); + end + end end