sgilmore10 opened a new pull request, #38533:
URL: https://github.com/apache/arrow/pull/38533
<!--
Thanks for opening a pull request!
If this is your first pull request you can find detailed information on how
to contribute here:
* [New Contributor's
Guide](https://arrow.apache.org/docs/dev/developers/guide/step_by_step/pr_lifecycle.html#reviews-and-merge-of-the-pull-request)
* [Contributing
Overview](https://arrow.apache.org/docs/dev/developers/overview.html)
If this is not a [minor
PR](https://github.com/apache/arrow/blob/main/CONTRIBUTING.md#Minor-Fixes).
Could you open an issue for this pull request on GitHub?
https://github.com/apache/arrow/issues/new/choose
Opening GitHub issues ahead of time contributes to the
[Openness](http://theapacheway.com/open/#:~:text=Openness%20allows%20new%20users%20the,must%20happen%20in%20the%20open.)
of the Apache Arrow project.
Then could you also rename the pull request title in the following format?
GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
or
MINOR: [${COMPONENT}] ${SUMMARY}
In the case of PARQUET issues on JIRA the title also supports:
PARQUET-${JIRA_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
-->
### Rationale for this change
This is a followup to #38419.
Adding this `DatetimeTypeValidator` class is a step towards implementing the
`arrow.array.ListArray.fromMATLAB()` method for creating `ListArray`s whose
`ValueType`s is a timestamp array from a MATLAB `cell` array.
This validator will ensure the cell array contain only `datetime`s or
unzoned `datetime`s. This is a requirement when creating a `List` of
`Timestamp`s because two MATLAB `datetime`s can only be concatenated together
if they are either both zoned or both unzoned:
```matlab
>> d1 = datetime(2023, 10, 31, TimeZone="America/New_York");
>> d2 =datetime(2023, 11, 1);
>> [d1; d2]
Error using datetime/vertcat
Unable to concatenate a datetime array that has a time zone with one that
does not have a time
zone.
```
### What changes are included in this PR?
Added a new MATLAB class called
`arrow.array.internal.list.DatetimeValidator`, which inherits from
`arrow.array.internal.list.ClassTypeValidator`.
This new class defines one property called `HasTimeZone`, which is a scalar
`logical` indicating if the validator expects all `datetime`s to be zoned or
not.
Additionally, `DatetimeValidator` overrides the `validateElement` method. It
first call's `ClassTypeValidator`'s implementation of `validateElement` to
verify the input element is a `datetime`. If so, it then confirms that the
input `datetime`'s TimeZone property is empty or nonempty, based on the
validator's `HasTimeZone` property value.
### Are these changes tested?
Yes, I added a new test class called `tDatetimeValidator.m`.
### Are there any user-facing changes?
No.
### Future Directions
1. #38417
2. #38354
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]