Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MATLAB] Add arrow.type.StructType MATLAB class #37724

Closed
sgilmore10 opened this issue Sep 14, 2023 · 1 comment · Fixed by #37749
Closed

[MATLAB] Add arrow.type.StructType MATLAB class #37724

sgilmore10 opened this issue Sep 14, 2023 · 1 comment · Fixed by #37749

Comments

@sgilmore10
Copy link
Member

Describe the enhancement requested

Before we add the arrow.array.StructArray class (#37653), we first need to add arrow.type.StructType as a class.

Component(s)

MATLAB

kevingurney pushed a commit that referenced this issue Sep 15, 2023
…class (#37725)

### Rationale for this change

In order to implement `arrow.array.StructType`, we need to add a property called `Fields` to `arrow.type.Type`. This property will be a N-by-1 `arrow.type.Field` array. Adding `Fields` will let users inspect the `Type`s contained by a `StructType` object.

### What changes are included in this PR?

1. Added `Fields` as a property to `arrow.type.Type`. `Fields` is a 1xN `arrow.type.Field` array, where `N` is the number of fields.

2. Added method `field(idx)` to `arrow.type.Type`. This method accepts a numeric index and returns the `arrow.type.Field` stored at the specified index.

### Are these changes tested?

1. Yes, updated `hFixedWidthType.m` and `tStringType.m` to verify the behavior of the new property and method.
2. Currently, all of the concrete `arrow.type.Type`s do not have any fields. This means the `Fields` property is always a 0x0 `arrow.type.Field` array. Once we implement `StructType`, we will be able to test having a nonempty `Fields` property.

### Are there any user-facing changes?

Yes, users can now extract fields from an `arrow.type.Type` object.

### Future Directions

1. #37724
2. #37653
* Closes: #37654

Authored-by: Sarah Gilmore <sgilmore@mathworks.com>
Signed-off-by: Kevin Gurney <kgurney@mathworks.com>
@sgilmore10
Copy link
Member Author

take

kevingurney pushed a commit that referenced this issue Sep 18, 2023
### Rationale for this change

In order to add a `arrow.array.StructArray` MATLAB class (#37653), we first need to implement the `arrow.type.StructType` MATLAB class.

### What changes are included in this PR?

1. Added a new MATLAB class `arrow.type.StructType`
2. Added convenience constructor function `arrow.struct()`
3. Added `Struct` as a enumeration value to `arrow.type.ID`
4. Added `arrow.type.traits.StructTraits` MATLAB class. Some of its properties, such as `ArrayConstructor` and `ArrayProxyClassName`, are set to `missing` because they require `arrow.array.StructArray` (#37653). When that class is added, we can initialize these properties to correct values.

**Example Usage**
```matlab
>> fieldA = arrow.field("A", arrow.int32());
>> fieldB = arrow.field("B", arrow.timestamp(TimeZone="America/New_York"));
>> fieldC = arrow.field("C", arrow.string());
>> structType = arrow.struct(fieldA, fieldB, fieldC)

structType = 

  StructType with properties:

        ID: Struct
    Fields: [1×3 arrow.type.Field]

>> fieldBFromStruct = structType.field(2)

fieldBFromStruct = 

B: timestamp[us, tz=America/New_York]
```

### Are these changes tested?

Yes.

1. Added a new test class called `tStructType.m`
2. Added a new test case to `tTypeDisplay.m`
3. Updated test case in `tID.m`

### Are there any user-facing changes?

Yes. Users can now create an `arrow.type.StructType` object using the new `arrow.struct()` funciton.

### Future Directions

1. #37653
* Closes: #37724

Authored-by: Sarah Gilmore <sgilmore@mathworks.com>
Signed-off-by: Kevin Gurney <kgurney@mathworks.com>
@kevingurney kevingurney added this to the 14.0.0 milestone Sep 18, 2023
loicalleyne pushed a commit to loicalleyne/arrow that referenced this issue Nov 13, 2023
…ATLAB class (apache#37725)

### Rationale for this change

In order to implement `arrow.array.StructType`, we need to add a property called `Fields` to `arrow.type.Type`. This property will be a N-by-1 `arrow.type.Field` array. Adding `Fields` will let users inspect the `Type`s contained by a `StructType` object.

### What changes are included in this PR?

1. Added `Fields` as a property to `arrow.type.Type`. `Fields` is a 1xN `arrow.type.Field` array, where `N` is the number of fields.

2. Added method `field(idx)` to `arrow.type.Type`. This method accepts a numeric index and returns the `arrow.type.Field` stored at the specified index.

### Are these changes tested?

1. Yes, updated `hFixedWidthType.m` and `tStringType.m` to verify the behavior of the new property and method.
2. Currently, all of the concrete `arrow.type.Type`s do not have any fields. This means the `Fields` property is always a 0x0 `arrow.type.Field` array. Once we implement `StructType`, we will be able to test having a nonempty `Fields` property.

### Are there any user-facing changes?

Yes, users can now extract fields from an `arrow.type.Type` object.

### Future Directions

1. apache#37724
2. apache#37653
* Closes: apache#37654

Authored-by: Sarah Gilmore <sgilmore@mathworks.com>
Signed-off-by: Kevin Gurney <kgurney@mathworks.com>
loicalleyne pushed a commit to loicalleyne/arrow that referenced this issue Nov 13, 2023
…ache#37749)

### Rationale for this change

In order to add a `arrow.array.StructArray` MATLAB class (apache#37653), we first need to implement the `arrow.type.StructType` MATLAB class.

### What changes are included in this PR?

1. Added a new MATLAB class `arrow.type.StructType`
2. Added convenience constructor function `arrow.struct()`
3. Added `Struct` as a enumeration value to `arrow.type.ID`
4. Added `arrow.type.traits.StructTraits` MATLAB class. Some of its properties, such as `ArrayConstructor` and `ArrayProxyClassName`, are set to `missing` because they require `arrow.array.StructArray` (apache#37653). When that class is added, we can initialize these properties to correct values.

**Example Usage**
```matlab
>> fieldA = arrow.field("A", arrow.int32());
>> fieldB = arrow.field("B", arrow.timestamp(TimeZone="America/New_York"));
>> fieldC = arrow.field("C", arrow.string());
>> structType = arrow.struct(fieldA, fieldB, fieldC)

structType = 

  StructType with properties:

        ID: Struct
    Fields: [1×3 arrow.type.Field]

>> fieldBFromStruct = structType.field(2)

fieldBFromStruct = 

B: timestamp[us, tz=America/New_York]
```

### Are these changes tested?

Yes.

1. Added a new test class called `tStructType.m`
2. Added a new test case to `tTypeDisplay.m`
3. Updated test case in `tID.m`

### Are there any user-facing changes?

Yes. Users can now create an `arrow.type.StructType` object using the new `arrow.struct()` funciton.

### Future Directions

1. apache#37653
* Closes: apache#37724

Authored-by: Sarah Gilmore <sgilmore@mathworks.com>
Signed-off-by: Kevin Gurney <kgurney@mathworks.com>
dgreiss pushed a commit to dgreiss/arrow that referenced this issue Feb 19, 2024
…ATLAB class (apache#37725)

### Rationale for this change

In order to implement `arrow.array.StructType`, we need to add a property called `Fields` to `arrow.type.Type`. This property will be a N-by-1 `arrow.type.Field` array. Adding `Fields` will let users inspect the `Type`s contained by a `StructType` object.

### What changes are included in this PR?

1. Added `Fields` as a property to `arrow.type.Type`. `Fields` is a 1xN `arrow.type.Field` array, where `N` is the number of fields.

2. Added method `field(idx)` to `arrow.type.Type`. This method accepts a numeric index and returns the `arrow.type.Field` stored at the specified index.

### Are these changes tested?

1. Yes, updated `hFixedWidthType.m` and `tStringType.m` to verify the behavior of the new property and method.
2. Currently, all of the concrete `arrow.type.Type`s do not have any fields. This means the `Fields` property is always a 0x0 `arrow.type.Field` array. Once we implement `StructType`, we will be able to test having a nonempty `Fields` property.

### Are there any user-facing changes?

Yes, users can now extract fields from an `arrow.type.Type` object.

### Future Directions

1. apache#37724
2. apache#37653
* Closes: apache#37654

Authored-by: Sarah Gilmore <sgilmore@mathworks.com>
Signed-off-by: Kevin Gurney <kgurney@mathworks.com>
dgreiss pushed a commit to dgreiss/arrow that referenced this issue Feb 19, 2024
…ache#37749)

### Rationale for this change

In order to add a `arrow.array.StructArray` MATLAB class (apache#37653), we first need to implement the `arrow.type.StructType` MATLAB class.

### What changes are included in this PR?

1. Added a new MATLAB class `arrow.type.StructType`
2. Added convenience constructor function `arrow.struct()`
3. Added `Struct` as a enumeration value to `arrow.type.ID`
4. Added `arrow.type.traits.StructTraits` MATLAB class. Some of its properties, such as `ArrayConstructor` and `ArrayProxyClassName`, are set to `missing` because they require `arrow.array.StructArray` (apache#37653). When that class is added, we can initialize these properties to correct values.

**Example Usage**
```matlab
>> fieldA = arrow.field("A", arrow.int32());
>> fieldB = arrow.field("B", arrow.timestamp(TimeZone="America/New_York"));
>> fieldC = arrow.field("C", arrow.string());
>> structType = arrow.struct(fieldA, fieldB, fieldC)

structType = 

  StructType with properties:

        ID: Struct
    Fields: [1×3 arrow.type.Field]

>> fieldBFromStruct = structType.field(2)

fieldBFromStruct = 

B: timestamp[us, tz=America/New_York]
```

### Are these changes tested?

Yes.

1. Added a new test class called `tStructType.m`
2. Added a new test case to `tTypeDisplay.m`
3. Updated test case in `tID.m`

### Are there any user-facing changes?

Yes. Users can now create an `arrow.type.StructType` object using the new `arrow.struct()` funciton.

### Future Directions

1. apache#37653
* Closes: apache#37724

Authored-by: Sarah Gilmore <sgilmore@mathworks.com>
Signed-off-by: Kevin Gurney <kgurney@mathworks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants