Commits


sgilmore10 authored and GitHub committed 2f3db6580ed
GH-37477: [MATLAB] Add `AllowNonScalar` name-value pair to arrow.internal.validate.index.* validation functions (#37482) ### Rationale for this change Per https://github.com/apache/arrow/pull/37475#discussion_r1310732596, we should consider adding a name-value pair like `AllowNonScalar = true | false` to the `arrow.internal.validate.index.*` validation functions since it is relatively common to want to explicitly allow (or disallow) non-scalar inputs to indexing functions (e.g. the `column` method of `RecordBatch` should only support scalar index values). ### What changes are included in this PR? 1. Modified all functions within the `arrow.internal.valdiate.index` package (i.e. `numeric()`, `string()`, and `numericOrString()`) to accept a name-value pair called `AllowNonScalar`. This name-value pair can be set to `logical` scalar, and by default it's set to `true`. 2. Updated the `column()` method in `RecordBatch` to pass `AllowNonScalar=false` to `numericOrString()`. 3. Updated the `field()` method in `RecordBatch` to pass `AllowNonScalar=false` to `numericOrString()`. **NOTE:** While character row vectors (e.g. `'ABC'`) are not scalar, they are equivalent to scalar `string` arrays. Therefore, both `string()` and `numericOrString()` do not error if given a character row vector as the index to validate and `AllowNonScalar=false`. ### Are these changes tested? Yes. Added new test cases to `tNumeric.m`, `tString.m` and `tNumericOrString.m` ### Are there any user-facing changes? No. * Closes: #37477 Authored-by: Sarah Gilmore <sgilmore@mathworks.com> Signed-off-by: Kevin Gurney <kgurney@mathworks.com>