sgilmore10 opened a new pull request, #37150:
URL: https://github.com/apache/arrow/pull/37150

   <!--
   Thanks for opening a pull request!
   If this is your first pull request you can find detailed information on how 
   to contribute here:
     * [New Contributor's 
Guide](https://arrow.apache.org/docs/dev/developers/guide/step_by_step/pr_lifecycle.html#reviews-and-merge-of-the-pull-request)
     * [Contributing 
Overview](https://arrow.apache.org/docs/dev/developers/overview.html)
   
   
   If this is not a [minor 
PR](https://github.com/apache/arrow/blob/main/CONTRIBUTING.md#Minor-Fixes). 
Could you open an issue for this pull request on GitHub? 
https://github.com/apache/arrow/issues/new/choose
   
   Opening GitHub issues ahead of time contributes to the 
[Openness](http://theapacheway.com/open/#:~:text=Openness%20allows%20new%20users%20the,must%20happen%20in%20the%20open.)
 of the Apache Arrow project.
   
   Then could you also rename the pull request title in the following format?
   
       GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
   
   or
   
       MINOR: [${COMPONENT}] ${SUMMARY}
   
   In the case of PARQUET issues on JIRA the title also supports:
   
       PARQUET-${JIRA_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
   
   -->
   
   ### Rationale for this change
   
   There are multiple functions/methods within the MATLAB interface which 
accept either numeric or string index values - in particular,  the `field` 
method of `arrow.tabular.Schema` and the `column` method of 
`arrow.tabular.RecordBatch`. Rather than writing the same validation code in 
each method, it would be better if we refactored that code into shared utility 
functions. 
   
   ### What changes are included in this PR?
   
   Added the following three new validation functions:
   
   1. `arrow.internal.validate.index.numeric`
   2. `arrow.internal.validate.index.string`
   3. `arrow.internal.validate.index.numericOrString`
   
   Example Usage:
   
   ```matlab
   >> index = arrow.internal.validate.index.numeric(0, "int32")
   Error using arrow.internal.validate.index.numeric
   Numeric indices must be positive integers.
   
   >> index = arrow.internal.validate.index.numeric(5, "int32")
   
   index =
   
     int32
   
      5
   
   >>  index = arrow.internal.validate.index.string(string(missing))
   Error using arrow.internal.validate.index.string
   String indices must be nonmissing
   
   >>  index = arrow.internal.validate.index.string('A')
   
   index = 
   
       "A"
   ```
   
   
   ### Are these changes tested?
   
   Yes. Added the following three new test classes:
   
   1. `test/arrow/internal/validate/index/tNumeric.m`
   2. `test/arrow/internal/validate/index/tString.m`
   3. `test/arrow/internal/validate/index/tNumericOrString.m` 
   
   
   ### Are there any user-facing changes?
   
   No.
   
   ### Future Directions
   
   1. Once this PR is merged, we will change the the `field` method of 
`arrow.tabular.Schema` and the `column` method of `arrow.tabular.RecordBatch` 
to use these utilities. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to