Skip to content

Commit

Permalink
Fix failing invalid variable name Feather test.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevingurney committed Aug 14, 2023
1 parent 5e32fb6 commit 0cd8ecd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions matlab/src/matlab/featherread.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions matlab/test/tfeathermex.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0cd8ecd

Please sign in to comment.