diff --git a/matlab/src/matlab/featherread.m b/matlab/src/matlab/featherread.m index 833cbb4e657c6..3995ba05c71ac 100644 --- a/matlab/src/matlab/featherread.m +++ b/matlab/src/matlab/featherread.m @@ -60,8 +60,10 @@ % Store original Feather table column names in the table.Properties.VariableDescriptions % property if they were modified to be valid MATLAB table variable names. - if ~all(t.Properties.VariableNames == recordBatch.ColumnNames) - t.Properties.VariableDescriptions = recordBatch.ColumnNames; + modifiedColumnNameIndices = t.Properties.VariableNames ~= recordBatch.ColumnNames; + if any(modifiedColumnNameIndices) + originalColumnNames = recordBatch.ColumnNames(modifiedColumnNameIndices); + t.Properties.VariableDescriptions(modifiedColumnNameIndices) = compose("Original variable name: '%s'", originalColumnNames); end end \ No newline at end of file diff --git a/matlab/test/tfeathermex.m b/matlab/test/tfeathermex.m index c0620e9054bf1..8b6b87aab1072 100644 --- a/matlab/test/tfeathermex.m +++ b/matlab/test/tfeathermex.m @@ -50,17 +50,17 @@ function InvalidMATLABTableVariableNames(testCase) filename = fullfile(pwd, 'temp.feather'); % Create a table with an invalid MATLAB table variable name. - invalidVariable = arrow.util.createVariableStruct('double', 1, true, '@'); + invalidVariable = arrow.util.createVariableStruct('double', 1, true, ':'); validVariable = arrow.util.createVariableStruct('double', 1, true, 'Valid'); variables = [invalidVariable, validVariable]; metadata = arrow.util.createMetadataStruct(1, 2); arrow.cpp.call('featherwrite', filename, variables, metadata); t = featherread(filename); - testCase.verifyEqual(t.Properties.VariableNames{1}, 'x_'); + testCase.verifyEqual(t.Properties.VariableNames{1}, ':_1'); testCase.verifyEqual(t.Properties.VariableNames{2}, 'Valid'); - testCase.verifyEqual(t.Properties.VariableDescriptions{1}, 'Original variable name: ''@'''); + testCase.verifyEqual(t.Properties.VariableDescriptions{1}, 'Original variable name: '':'''); testCase.verifyEqual(t.Properties.VariableDescriptions{2}, ''); end end