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 null support to all numeric array classes #35984

Closed
sgilmore10 opened this issue Jun 7, 2023 · 1 comment · Fixed by #36039
Closed

[MATLAB] Add null support to all numeric array classes #35984

sgilmore10 opened this issue Jun 7, 2023 · 1 comment · Fixed by #36039

Comments

@sgilmore10
Copy link
Member

Describe the enhancement requested

We've added support for null values to arrow.array.Float64Array via the InferNulls and Valid name-value pairs. We would like to add these name-value pairs to the rest of the numeric array classes:

  1. arrow.array.Float32Array
  2. arrow.array.UInt8Array
  3. arrow.array.UInt16Array
  4. arrow.array.UInt32Array
  5. arrow.array.UInt64Array
  6. arrow.array.Int8Array
  7. arrow.array.Int16Array
  8. arrow.array.Int32Array
  9. arrow.array.Int64Array

Component(s)

MATLAB

@sgilmore10 sgilmore10 changed the title [MATLAB] Add null support to all numeric array classes. [MATLAB] Add null support to all numeric array classes Jun 8, 2023
sgilmore10 added a commit to mathworks/arrow that referenced this issue Jun 8, 2023
@sgilmore10
Copy link
Member Author

take

kou pushed a commit that referenced this issue Jun 13, 2023
)

### Rationale for this change

We initially only enabled null support for `arrow.array.Float64Array` via the `InferNulls` and `Valid` name-value pairs. This pull request adds null-value support to the rest of the numeric array types.

### What changes are included in this PR?

1. All numeric array classes accept the `InferNulls` and `Valid` name-value pairs.
2. `arrow.array.Float32Array` treats `NaN` as `null` by default if `InferNulls=true` and `Valid` is not supplied.
3. To reduce code duplication, we added an abstract class called `arrow.array.NumericArray` that all numeric array classes inherit form.

Here's an example of creating an `Int32Array` with `null` values:

```MATLAB
>> matlabArray = int32([1 2 3 4 5]);
>> arrowArray = arrow.array.Int32Array(matlabArray, Valid=[1 4 5])
arrowArray = 

[
  1,
  null,
  null,
  4,
  5
]

```

### Are these changes tested?

1. Added two unit tests to `hNumericArray.m` called `LogicalValidNVPair` and `NumericValidNVPair` which test the null support integration of all numeric types.
2. Added unit tests to `tFloat32Array.m` to verify `NaN `is treated as a null value by default.

### Are there any user-facing changes?

Yes, users can now create numeric arrays of any type with null values.

### Notes

Thanks to @ kevingurney for all the help!

* Closes: #35984

Authored-by: Sarah Gilmore <sgilmore@mathworks.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
@kou kou added this to the 13.0.0 milestone Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants