Commits


Kevin Gurney authored and GitHub committed 7b1e8348793
GH-36852: [MATLAB] Add `arrow.type.Field` class (#36855) ### Rationale for this change Now that the MATLAB interface supports creating `Type` objects - like `arrow.type.Int64Type`, we can add support for `Field` objects (i.e. name + type). This mirrors the `Field` type in other Arrow interfaces, [like PyArrow](https://arrow.apache.org/docs/python/generated/pyarrow.field.html). ### What changes are included in this PR? Two new user-facing APIs have been added: 1. `arrow.field(name, type)` constructor function 2. `arrow.type.Field` class (returned by the `arrow.field` constructor function). **Example**: ```matlab >> field = arrow.field("Speed", arrow.type.uint64) field = Speed: uint64 >> field.Type ans = UInt64Type with properties: ID: UInt64 >> field.Name ans = "Speed" ``` ### Are these changes tested? Yes. 1. Added new `tField.m` MATLAB test class. ### Are there any user-facing changes? Yes. Two new user-facing APIs have been added: 1. `arrow.field(name, type)` constructor function 2. `arrow.type.Field` class (returned by the `arrow.field` constructor function) ### Future Directions 1. We intentionally placed `arrow.field` in the top-level `arrow` package, rather than under a nested `arrow.type` package (where the corresponding class `arrow.type.Field` is). This is to avoid naming conflicts between `arrow.type.field` and `arrow.type.Field` and also to make it easier to use the recommended public/user-facing APIs with less typing (i.e. without needing to type nested package names). While working on this change, we realized that it would make sense to move the "type constructor functions" (e.g. `arrow.type.boolean`, `arrow.type.uint64`, etc.) into the top-level `arrow` package, as well (i.e. `arrow.boolean`, `arrow.uint64`, etc.). In other words, moving forward, the recommended APIs for the MATLAB interface will be placed directly under the top-level `arrow` package. This should hopefully result in a simplified public interface, as well as make it easier to use multiple language bindings (e.g. MATLAB and PyArrow) together, with less context switching. ### Notes 1. @ sgilmore10 is working on a follow up PR (to address #36853) for simplifying the `switch` statement code in `makeTypeProxy`. Her solution will be more generic, so that we can re-use it elsewhere across the code base of the MATLAB interface. 2. Thank you @ sgilmore10 for your help with this pull request! * Closes: #36852 Lead-authored-by: Kevin Gurney <kgurney@mathworks.com> Co-authored-by: Kevin Gurney <kevin.p.gurney@gmail.com> Co-authored-by: Sarah Gilmore <sgilmore@mathworks.com> Co-authored-by: Sutou Kouhei <kou@cozmixng.org> Signed-off-by: Kevin Gurney <kgurney@mathworks.com>