You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ko...@apache.org on 2023/06/28 21:21:28 UTC
[arrow] branch main updated: GH-36359: [MATLAB] Add support for Timestamp arrays to RecordBatch (#36361)
This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new c0dd99f3fb GH-36359: [MATLAB] Add support for Timestamp arrays to RecordBatch (#36361)
c0dd99f3fb is described below
commit c0dd99f3fb43611aad7cfa96031cfd5721092c6e
Author: sgilmore10 <74...@users.noreply.github.com>
AuthorDate: Wed Jun 28 17:21:19 2023 -0400
GH-36359: [MATLAB] Add support for Timestamp arrays to RecordBatch (#36361)
### Rationale for this change
Now that we have a `TimestampArray` class in MATLAB, we should add support for `TimestampArray` columns in `RecordBatch`.
### What changes are included in this PR?
You can now create a `RecordBatch` with a `TimestampArray` column:
```matlab
>> Date = datetime(2023, 6, 28) + days(0:2)';
>> DayNumber = weekday(Date);
>> t = table(Date, DayNumber)
t =
3×2 table
Date DayNumber
___________ _________
28-Jun-2023 4
29-Jun-2023 5
30-Jun-2023 6
>> rb = arrow.tabular.RecordBatch(t)
rb =
Date: [
2023-06-28 00:00:00.000000,
2023-06-29 00:00:00.000000,
2023-06-30 00:00:00.000000
]
DayNumber: [
4,
5,
6
]
```
### Are these changes tested?
Yes, the `SupportedTypes` unit test in `tRecordBatch.m` was updated to verify we support creating record batches with timestamp data.
### Are there any user-facing changes?
1. Users can create record batches with timestamp data now.
* Closes: #36359
Authored-by: Sarah Gilmore <sg...@mathworks.com>
Signed-off-by: Sutou Kouhei <ko...@clear-code.com>
---
matlab/src/matlab/+arrow/+tabular/RecordBatch.m | 2 ++
matlab/test/arrow/tabular/tRecordBatch.m | 3 ++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/matlab/src/matlab/+arrow/+tabular/RecordBatch.m b/matlab/src/matlab/+arrow/+tabular/RecordBatch.m
index e1200d8c12..5e5ab1d1d7 100644
--- a/matlab/src/matlab/+arrow/+tabular/RecordBatch.m
+++ b/matlab/src/matlab/+arrow/+tabular/RecordBatch.m
@@ -121,6 +121,8 @@ classdef RecordBatch < matlab.mixin.CustomDisplay & ...
arrowArray = arrow.array.Int64Array(matlabArray);
case "logical"
arrowArray = arrow.array.BooleanArray(matlabArray);
+ case "datetime"
+ arrowArray = arrow.array.TimestampArray(matlabArray);
otherwise
error("arrow:tabular:recordbatch:UnsupportedMatlabArrayType", ...
"RecordBatch cannot be constructed from a MATLAB array of type '" + class(matlabArray) + "'.");
diff --git a/matlab/test/arrow/tabular/tRecordBatch.m b/matlab/test/arrow/tabular/tRecordBatch.m
index be36e3c975..d0b1df9621 100644
--- a/matlab/test/arrow/tabular/tRecordBatch.m
+++ b/matlab/test/arrow/tabular/tRecordBatch.m
@@ -37,7 +37,8 @@ classdef tRecordBatch < matlab.unittest.TestCase
uint64 ([1, 2, 3]'), ...
logical([1, 0, 1]'), ...
single ([1, 2, 3]'), ...
- double ([1, 2, 3]'));
+ double ([1, 2, 3]'), ...
+ datetime(2023, 6, 28) + days(0:2)');
arrowRecordBatch = arrow.tabular.RecordBatch(TOriginal);
TConverted = arrowRecordBatch.toMATLAB();
tc.verifyEqual(TOriginal, TConverted);