Repository navigation
GH-37096: [MATLAB] Add utility which makes valid MATLAB table variable names from an arbitrary list of strings - #37098
Merged
Merged
Conversation
kevingurney
reviewed
Aug 9, 2023
kevingurney
requested changes
Aug 9, 2023
kevingurney
left a comment
Member
There was a problem hiding this comment.
Thanks for working on this @sgilmore10! I just had a few minor comments.
kevingurney
approved these changes
Aug 10, 2023
Member
|
+1 |
|
After merging your PR, Conbench analyzed the 5 benchmarking runs that have been run so far on merge-commit 8ab6484. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. |
kevingurney
added a commit
that referenced
this pull request
Aug 14, 2023
…onNames` in implementation of `table` method for `RecordBatch` (#37152) ### Rationale for this change #37098 added utilities for making valid MATLAB `table` `VariableNames` (`makeValidVariableNames`) and `DimensionNames` (`makeValidDimensionNames`) from an arbitrary list of strings. This pull request uses these utilities to ensure that `RecordBatch` field names are converted to valid MATLAB `table` `VariableNames`/`DimensionNames` when calling the `table`/`toMATLAB` methods. ### What changes are included in this PR? 1. Used `makeValidVariableNames` and `makeValidDimensionNames` utilities in the implementation of the `table` method for the `RecordBatch` class to ensure that column names are converted to valid MATLAB `table` `VariableNames`/`DimensionNames`. ### Are these changes tested? Yes. 1. The existing tests in `arrow/matlab/test/arrow/tabular/tMakeValidVariableNames.m` and `arrow/matlab/test/arrow/tabular/tMakeValidDimensionNames.m` already test that an arbitrary list of column names are converted into valid MATLAB `table` `VariableNames`/`DimensionNames`. 2. There is currently no straightforward way to create a `RecordBatch` with field names that are invalid MATLAB `VariableNames`/`DimensionNames` using the MATLAB interface. When we have a way to do this in the MATLAB interface, we can add more "integration" tests which verify that a `RecordBatch` with field names that are invalid MATLAB `table` `VariableNames`/`DimensionNames` are converted into valid `VariableNames`/`DimensionNames` when the `table`/`toMATLAB` methods are called. ### Are there any user-facing changes? Yes. A `RecordBatch` with field names that are invalid MATLAB `table` `VariableNames`/`DimensionNames` will now be converted into a MATLAB `table` with valid `VariableNames`/`DimensionNames` when calling the `table`/`toMATLAB` methods. ### Future Directions 1. #37046 (this change to the `table` method of the `RecordBatch` class should help preserve the behavior of storing original `RecordBatch` field names in the `VariableDescriptions` property of the output MATLAB `table` returned by `featherread`). * Closes: #37151 Authored-by: Kevin Gurney <kgurney@mathworks.com> Signed-off-by: Kevin Gurney <kgurney@mathworks.com>
loicalleyne
pushed a commit
to loicalleyne/arrow
that referenced
this pull request
Nov 13, 2023
…ariable names from an arbitrary list of strings (apache#37098) ### Rationale for this change To make it possible to safely convert Arrow Schema field names to corresponding MATLAB `table` variable names, it would be helpful to add a utility which can take an arbitrary list of strings and return a set of valid MATLAB `table` variable names, which are (1) unique, (2) non-empty, and (3) do not conflict with the "reserved" variable names "Properties", "VariableNames", "RowNames", and ":". An additional restriction is that variable names must have 63 or less characters. ### What changes are included in this PR? 1. Added a new function called `arrow.tabular.internal.makeValidVariableNames` that accepts an arbitrary list of strings and returns valid MATLAB `table` variable names. ```matlab >> originalVarNames = ["", "Properties", ":", "ValidVar", "ValidVar"]; >> validVarNames = arrow.tabular.internal.makeValidVariableNames(originalVarNames) validVarNames = 1×5 string array "Var1" "Properties_1" ":_1" "ValidVar" "ValidVar_1" ``` 3. Added a new function called `arrow.tabular.internal.makeValidDimensionNames` that returns valid table dimension names with respect to a list of valid variable names. In MATLAB the default `table` dimension names are `"Row"` and `"Variables"`, but they must not conflict with any variables names. In other words, they must be unique with respect to the variable names. ```matlab >> validVarNames = ["Row" "Test" "Variables"]; >> validDimNames = arrow.tabular.internal.makeValidDimensionNames(validVarNames) validDimNames = 1×2 string array "Row_1" "Variables_1" ``` To summarize, MATLAB `table`s cannot have arbitrary variable names. For example, `"Properties"`, `"RowNames"`, `"VariableNames"`, and `":"` are all disallowed. Variable names must also be unique and must be between 1 and 63 characters in length. They also must be unique with respect to each other. ### Are these changes tested? Yes. Added the following new test classes: 1. `tMakeValidVariableNames.m` 2. `tMakeValidDimensionNames.m` ### Are there any user-facing changes? No. ### Future Directions 1. In a follow-up PR, we will integrate `makeValidVariableNames` and `makeValidDimensionNames` into the `table()` and `toMATLAB()` methods of `arrow.tabular.RecordBatch`. ### Notes Thanks to @ kevingurney for help writing the test cases! * Closes: apache#37096 Lead-authored-by: Sarah Gilmore <sgilmore@mathworks.com> Co-authored-by: Kevin Gurney <kgurney@mathworks.com> Signed-off-by: Kevin Gurney <kgurney@mathworks.com>
loicalleyne
pushed a commit
to loicalleyne/arrow
that referenced
this pull request
Nov 13, 2023
…imensionNames` in implementation of `table` method for `RecordBatch` (apache#37152) ### Rationale for this change apache#37098 added utilities for making valid MATLAB `table` `VariableNames` (`makeValidVariableNames`) and `DimensionNames` (`makeValidDimensionNames`) from an arbitrary list of strings. This pull request uses these utilities to ensure that `RecordBatch` field names are converted to valid MATLAB `table` `VariableNames`/`DimensionNames` when calling the `table`/`toMATLAB` methods. ### What changes are included in this PR? 1. Used `makeValidVariableNames` and `makeValidDimensionNames` utilities in the implementation of the `table` method for the `RecordBatch` class to ensure that column names are converted to valid MATLAB `table` `VariableNames`/`DimensionNames`. ### Are these changes tested? Yes. 1. The existing tests in `arrow/matlab/test/arrow/tabular/tMakeValidVariableNames.m` and `arrow/matlab/test/arrow/tabular/tMakeValidDimensionNames.m` already test that an arbitrary list of column names are converted into valid MATLAB `table` `VariableNames`/`DimensionNames`. 2. There is currently no straightforward way to create a `RecordBatch` with field names that are invalid MATLAB `VariableNames`/`DimensionNames` using the MATLAB interface. When we have a way to do this in the MATLAB interface, we can add more "integration" tests which verify that a `RecordBatch` with field names that are invalid MATLAB `table` `VariableNames`/`DimensionNames` are converted into valid `VariableNames`/`DimensionNames` when the `table`/`toMATLAB` methods are called. ### Are there any user-facing changes? Yes. A `RecordBatch` with field names that are invalid MATLAB `table` `VariableNames`/`DimensionNames` will now be converted into a MATLAB `table` with valid `VariableNames`/`DimensionNames` when calling the `table`/`toMATLAB` methods. ### Future Directions 1. apache#37046 (this change to the `table` method of the `RecordBatch` class should help preserve the behavior of storing original `RecordBatch` field names in the `VariableDescriptions` property of the output MATLAB `table` returned by `featherread`). * Closes: apache#37151 Authored-by: Kevin Gurney <kgurney@mathworks.com> Signed-off-by: Kevin Gurney <kgurney@mathworks.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
To make it possible to safely convert Arrow Schema field names to corresponding MATLAB
tablevariable names, it would be helpful to add a utility which can take an arbitrary list of strings and return a set of valid MATLABtablevariable names, which are (1) unique, (2) non-empty, and (3) do not conflict with the "reserved" variable names "Properties", "VariableNames", "RowNames", and ":". An additional restriction is that variable names must have 63 or less characters.What changes are included in this PR?
arrow.tabular.internal.makeValidVariableNamesthat accepts an arbitrary list of strings and returns valid MATLABtablevariable names.arrow.tabular.internal.makeValidDimensionNamesthat returns valid table dimension names with respect to a list of valid variable names. In MATLAB the defaulttabledimension names are"Row"and"Variables", but they must not conflict with any variables names. In other words, they must be unique with respect to the variable names.To summarize, MATLAB
tables cannot have arbitrary variable names. For example,"Properties","RowNames","VariableNames", and":"are all disallowed. Variable names must also be unique and must be between 1 and 63 characters in length. They also must be unique with respect to each other.Are these changes tested?
Yes. Added the following new test classes:
tMakeValidVariableNames.mtMakeValidDimensionNames.mAre there any user-facing changes?
No.
Future Directions
makeValidVariableNamesandmakeValidDimensionNamesinto thetable()andtoMATLAB()methods ofarrow.tabular.RecordBatch.Notes
Thanks to @kevingurney for help writing the test cases!
tablevariable names from an arbitrary list of strings #37096