Skip to content

Conversation

@kevingurney
Copy link
Member

@kevingurney kevingurney commented Sep 5, 2023

Rationale for this change

In support of adding arrow.array.Date64Array, this pull request adds a new arrow.type.Date64Type class and associated arrow.date64 construction function to the MATLAB interface.

What changes are included in this PR?

  1. New arrow.type.Date64Type class.
  2. New arrow.date64 construction function that returns an arrow.type.Date64Type instance.
  3. New arrow.type.ID.Date64 type enumeration value.

Example

>> type = arrow.date64()

type = 

  Date64Type with properties:

          ID: Date64
    DateUnit: Millisecond

Are these changes tested?

Yes.

  1. Added a new tDate64Type test class.
  2. Updated the tID test class to include arrow.type.ID.Date64.

Are there any user-facing changes?

Yes.

  1. There is a new public arrow.type.Date64Type class.
  2. There is a new public arrow.date64 construction function.
  3. There is a new arrow.type.ID.Date64 type enumeration value.

Future Directions

  1. [MATLAB] Add arrow.array.Date64Array class #37572
  2. [MATLAB] Create a superclass for DateType-related MATLAB tests #37577

@kevingurney kevingurney requested a review from kou as a code owner September 5, 2023 17:48
@github-actions github-actions bot added the awaiting committer review Awaiting committer review label Sep 5, 2023
Copy link
Member

@sgilmore10 sgilmore10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Had two minor comments.

@github-actions github-actions bot added Component: MATLAB awaiting changes Awaiting changes and removed awaiting committer review Awaiting committer review labels Sep 5, 2023
@kevingurney
Copy link
Member Author

+1

@kevingurney kevingurney merged commit 756a5d7 into apache:main Sep 5, 2023
@kevingurney kevingurney deleted the GH-37230 branch September 5, 2023 18:21
@kevingurney kevingurney removed the awaiting changes Awaiting changes label Sep 5, 2023
kevingurney added a commit that referenced this pull request Sep 6, 2023
### Rationale for this change

Now that `arrow.type.Date64Type` class has been added to the MATLAB Interface (#37578), we can add the `arrow.array.Date64Array` class.

`Date64Array`s can be created from MATLAB [`datetime`](https://www.mathworks.com/help/matlab/ref/datetime.html) values. 

### What changes are included in this PR?

1. Added a new `arrow.array.Date64Array` class.
2. Added a new `arrow.type.traits.Date64Traits` class.
3. Added `arrow.type.Date64Type` support to `arrow.type.traits.traits` function.
4. Factored out `convertToEpochTime` method on `TimestampArray` into internal helper function `arrow.array.internal.temporal.convertDatetimeToEpochTime`.
5. Updated `arrow.internal.test.tabular.createAllSupportedArrayTypes` to include `Date64Array`.

`Date64Array`s can be created from MATLAB [`datetime`](https://www.mathworks.com/help/matlab/ref/datetime.html) values using the `fromMATLAB` method. `Date64Array`s can be converted to MATLAB `datetime` values using the `toMATLAB` method.

**Example**
```matlab
>> dates = datetime + milliseconds(1:5)'

dates = 

  5×1 datetime array

   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12

% "SSS" displays fractional seconds (i.e. milliseconds)
>> dates.Format = "MMM dd, yyyy HH:mm:ss SSS"

dates = 

  5×1 datetime array

   Sep 05, 2023 16:47:12 933
   Sep 05, 2023 16:47:12 934
   Sep 05, 2023 16:47:12 935
   Sep 05, 2023 16:47:12 936
   Sep 05, 2023 16:47:12 937

>> array = arrow.array.Date64Array.fromMATLAB(dates)

array = 

[
  2023-09-05,
  2023-09-05,
  2023-09-05,
  2023-09-05,
  2023-09-05
]

>> array.toMATLAB

ans = 

  5×1 datetime array

   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12

% Milliseconds are preserved on round-trip
>> ans.Format = "MMM dd, yyyy HH:mm:ss SSS"

ans = 

  5×1 datetime array

   Sep 05, 2023 16:47:12 933
   Sep 05, 2023 16:47:12 934
   Sep 05, 2023 16:47:12 935
   Sep 05, 2023 16:47:12 936
   Sep 05, 2023 16:47:12 937
```

### Are these changes tested?

1. Added a new `tDate64Array` test class.
2. Added `Date64` related test to `ttraits.m`.
3. Added a new `tDate64Traits.m` test class.

### Are there any user-facing changes?

Yes.

1. Users can now create `arrow.array.Date64Array`s  from MATLAB `datetime`s.

### Future Directions

1. Add round-trip precision tests for `TimestampArray` (i.e. similar to the test case `TestInt64MaxMilliseconds`).
2. Add a way to extract the raw `int64` values from an `arrow.array.Date64Array` without converting to a MATLAB `datetime` using `toMATLAB`.

### Notes

1. Thank you @ sgilmore10 for your help with this pull request!
* Closes: #37572

Lead-authored-by: Kevin Gurney <kgurney@mathworks.com>
Co-authored-by: Sarah Gilmore <sgilmore@mathworks.com>
Signed-off-by: Kevin Gurney <kgurney@mathworks.com>
@conbench-apache-arrow
Copy link

After merging your PR, Conbench analyzed the 5 benchmarking runs that have been run so far on merge-commit 756a5d7.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about possible false positives for unstable benchmarks that are known to sometimes produce them.

loicalleyne pushed a commit to loicalleyne/arrow that referenced this pull request Nov 13, 2023
….date64` construction function (apache#37578)

### Rationale for this change

In support of adding `arrow.array.Date64Array`, this pull request adds a new `arrow.type.Date64Type` class and associated `arrow.date64` construction function to the MATLAB interface.

### What changes are included in this PR?

1. New `arrow.type.Date64Type` class.
2. New `arrow.date64` construction function that returns an `arrow.type.Date64Type` instance.
3. New `arrow.type.ID.Date64` type enumeration value.

**Example**
```matlab
>> type = arrow.date64()

type = 

  Date64Type with properties:

          ID: Date64
    DateUnit: Millisecond
```

### Are these changes tested?

Yes.

1. Added a new `tDate64Type` test class.
2. Updated the `tID` test class to include `arrow.type.ID.Date64`. 

### Are there any user-facing changes?

Yes.

1. There is a new public `arrow.type.Date64Type` class.
2. There is a new public `arrow.date64` construction function.
3. There is a new `arrow.type.ID.Date64` type enumeration value.

### Future Directions

1. apache#37572
2. apache#37577
* Closes: apache#37230

Authored-by: Kevin Gurney <kgurney@mathworks.com>
Signed-off-by: Kevin Gurney <kgurney@mathworks.com>
loicalleyne pushed a commit to loicalleyne/arrow that referenced this pull request Nov 13, 2023
…37581)

### Rationale for this change

Now that `arrow.type.Date64Type` class has been added to the MATLAB Interface (apache#37578), we can add the `arrow.array.Date64Array` class.

`Date64Array`s can be created from MATLAB [`datetime`](https://www.mathworks.com/help/matlab/ref/datetime.html) values. 

### What changes are included in this PR?

1. Added a new `arrow.array.Date64Array` class.
2. Added a new `arrow.type.traits.Date64Traits` class.
3. Added `arrow.type.Date64Type` support to `arrow.type.traits.traits` function.
4. Factored out `convertToEpochTime` method on `TimestampArray` into internal helper function `arrow.array.internal.temporal.convertDatetimeToEpochTime`.
5. Updated `arrow.internal.test.tabular.createAllSupportedArrayTypes` to include `Date64Array`.

`Date64Array`s can be created from MATLAB [`datetime`](https://www.mathworks.com/help/matlab/ref/datetime.html) values using the `fromMATLAB` method. `Date64Array`s can be converted to MATLAB `datetime` values using the `toMATLAB` method.

**Example**
```matlab
>> dates = datetime + milliseconds(1:5)'

dates = 

  5×1 datetime array

   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12

% "SSS" displays fractional seconds (i.e. milliseconds)
>> dates.Format = "MMM dd, yyyy HH:mm:ss SSS"

dates = 

  5×1 datetime array

   Sep 05, 2023 16:47:12 933
   Sep 05, 2023 16:47:12 934
   Sep 05, 2023 16:47:12 935
   Sep 05, 2023 16:47:12 936
   Sep 05, 2023 16:47:12 937

>> array = arrow.array.Date64Array.fromMATLAB(dates)

array = 

[
  2023-09-05,
  2023-09-05,
  2023-09-05,
  2023-09-05,
  2023-09-05
]

>> array.toMATLAB

ans = 

  5×1 datetime array

   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12

% Milliseconds are preserved on round-trip
>> ans.Format = "MMM dd, yyyy HH:mm:ss SSS"

ans = 

  5×1 datetime array

   Sep 05, 2023 16:47:12 933
   Sep 05, 2023 16:47:12 934
   Sep 05, 2023 16:47:12 935
   Sep 05, 2023 16:47:12 936
   Sep 05, 2023 16:47:12 937
```

### Are these changes tested?

1. Added a new `tDate64Array` test class.
2. Added `Date64` related test to `ttraits.m`.
3. Added a new `tDate64Traits.m` test class.

### Are there any user-facing changes?

Yes.

1. Users can now create `arrow.array.Date64Array`s  from MATLAB `datetime`s.

### Future Directions

1. Add round-trip precision tests for `TimestampArray` (i.e. similar to the test case `TestInt64MaxMilliseconds`).
2. Add a way to extract the raw `int64` values from an `arrow.array.Date64Array` without converting to a MATLAB `datetime` using `toMATLAB`.

### Notes

1. Thank you @ sgilmore10 for your help with this pull request!
* Closes: apache#37572

Lead-authored-by: Kevin Gurney <kgurney@mathworks.com>
Co-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 pull request Feb 19, 2024
….date64` construction function (apache#37578)

### Rationale for this change

In support of adding `arrow.array.Date64Array`, this pull request adds a new `arrow.type.Date64Type` class and associated `arrow.date64` construction function to the MATLAB interface.

### What changes are included in this PR?

1. New `arrow.type.Date64Type` class.
2. New `arrow.date64` construction function that returns an `arrow.type.Date64Type` instance.
3. New `arrow.type.ID.Date64` type enumeration value.

**Example**
```matlab
>> type = arrow.date64()

type = 

  Date64Type with properties:

          ID: Date64
    DateUnit: Millisecond
```

### Are these changes tested?

Yes.

1. Added a new `tDate64Type` test class.
2. Updated the `tID` test class to include `arrow.type.ID.Date64`. 

### Are there any user-facing changes?

Yes.

1. There is a new public `arrow.type.Date64Type` class.
2. There is a new public `arrow.date64` construction function.
3. There is a new `arrow.type.ID.Date64` type enumeration value.

### Future Directions

1. apache#37572
2. apache#37577
* Closes: apache#37230

Authored-by: Kevin Gurney <kgurney@mathworks.com>
Signed-off-by: Kevin Gurney <kgurney@mathworks.com>
dgreiss pushed a commit to dgreiss/arrow that referenced this pull request Feb 19, 2024
…37581)

### Rationale for this change

Now that `arrow.type.Date64Type` class has been added to the MATLAB Interface (apache#37578), we can add the `arrow.array.Date64Array` class.

`Date64Array`s can be created from MATLAB [`datetime`](https://www.mathworks.com/help/matlab/ref/datetime.html) values. 

### What changes are included in this PR?

1. Added a new `arrow.array.Date64Array` class.
2. Added a new `arrow.type.traits.Date64Traits` class.
3. Added `arrow.type.Date64Type` support to `arrow.type.traits.traits` function.
4. Factored out `convertToEpochTime` method on `TimestampArray` into internal helper function `arrow.array.internal.temporal.convertDatetimeToEpochTime`.
5. Updated `arrow.internal.test.tabular.createAllSupportedArrayTypes` to include `Date64Array`.

`Date64Array`s can be created from MATLAB [`datetime`](https://www.mathworks.com/help/matlab/ref/datetime.html) values using the `fromMATLAB` method. `Date64Array`s can be converted to MATLAB `datetime` values using the `toMATLAB` method.

**Example**
```matlab
>> dates = datetime + milliseconds(1:5)'

dates = 

  5×1 datetime array

   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12

% "SSS" displays fractional seconds (i.e. milliseconds)
>> dates.Format = "MMM dd, yyyy HH:mm:ss SSS"

dates = 

  5×1 datetime array

   Sep 05, 2023 16:47:12 933
   Sep 05, 2023 16:47:12 934
   Sep 05, 2023 16:47:12 935
   Sep 05, 2023 16:47:12 936
   Sep 05, 2023 16:47:12 937

>> array = arrow.array.Date64Array.fromMATLAB(dates)

array = 

[
  2023-09-05,
  2023-09-05,
  2023-09-05,
  2023-09-05,
  2023-09-05
]

>> array.toMATLAB

ans = 

  5×1 datetime array

   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12
   05-Sep-2023 16:47:12

% Milliseconds are preserved on round-trip
>> ans.Format = "MMM dd, yyyy HH:mm:ss SSS"

ans = 

  5×1 datetime array

   Sep 05, 2023 16:47:12 933
   Sep 05, 2023 16:47:12 934
   Sep 05, 2023 16:47:12 935
   Sep 05, 2023 16:47:12 936
   Sep 05, 2023 16:47:12 937
```

### Are these changes tested?

1. Added a new `tDate64Array` test class.
2. Added `Date64` related test to `ttraits.m`.
3. Added a new `tDate64Traits.m` test class.

### Are there any user-facing changes?

Yes.

1. Users can now create `arrow.array.Date64Array`s  from MATLAB `datetime`s.

### Future Directions

1. Add round-trip precision tests for `TimestampArray` (i.e. similar to the test case `TestInt64MaxMilliseconds`).
2. Add a way to extract the raw `int64` values from an `arrow.array.Date64Array` without converting to a MATLAB `datetime` using `toMATLAB`.

### Notes

1. Thank you @ sgilmore10 for your help with this pull request!
* Closes: apache#37572

Lead-authored-by: Kevin Gurney <kgurney@mathworks.com>
Co-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

None yet

Development

Successfully merging this pull request may close these issues.

[MATLAB] Add arrow.type.Date64Type class and arrow.date64 construction function

2 participants