You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Rationale for this change
This change makes it possible to create an `arrow.tabular.Table` instance from a list of `arrow.tabular.RecordBatch` instances whose `Schema`s are consistent.
### What changes are included in this PR?
Added a new static method called `fromRecordBatches` to the MATLAB class `arrow.tabular.Table`. This method should construct an `arrow.tabular.Table` from a variable number of `arrow.tabular.RecordBatch`es.
**Usage Example**
```matlab
>> rb1 = arrow.recordBatch(table([1:5]', [6:10]'));
>> rb2 = arrow.recordBatch(table([11:15]', [16:20]'));
>> table = arrow.tabular.Table.fromRecordBatches(rb1, rb2)
table =
Arrow Table with 10 rows and 2 columns:
Schema:
Var1: Float64 | Var2: Float64
First Row:
1 | 6
```
**Error Message Examples**
```matlab
% Error message when fromRecordBatches is called with zero input arguments
>> arrow.tabular.Table.fromRecordBatches()
Error using arrow.tabular.Table.fromRecordBatches (line 154)
The fromRecordBatches method requires at least one RecordBatch to be supplied.
% Error message when fromRecordBatches is given RecordBatches whose Schemas are inconsistent.
>> rb1 = arrow.recordBatch(table(1, 2, VariableNames=["Num1", "Num2"]));
>> rb2 = arrow.recordBatch(table(1, "A", VariableNames=["Num1", "Letter1"]));
>> arrow.tabular.Table.fromRecordBatches(rb1, rb2)
Error using arrow.tabular.Table.fromRecordBatches (line 167)
All RecordBatches must have the same Schema.
Schema of RecordBatch 2 is
Num1: Float64 | Letter1: String
Expected RecordBatch Schema to be
Num1: Float64 | Num2: Float64
```
### Are these changes tested?
Yes. Added four new test cases to the MATLAB test class `tTable`:
1. `FromRecordBatchesZeroInputsError`
2. `FromRecordBatchesOneInput`
3. `FromRecordBatchesMultipleInputs`
4. `FromRecordBatchesInconsistentSchemaError`
### Are there any user-facing changes?
Yes. Users can now create an `arrow.tabular.Table` instance via the static method `fromRecordBatches`.
* GitHub Issue: apache#46877
Lead-authored-by: Sarah Gilmore <[email protected]>
Co-authored-by: Sarah Gilmore <[email protected]>
Co-authored-by: Kevin Gurney <[email protected]>
Signed-off-by: Sarah Gilmore <[email protected]>
0 commit comments