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 method for extracting one row of a arrow.tabular.Table as a string #38418

Closed
kevingurney opened this issue Oct 23, 2023 · 1 comment · Fixed by #38463
Closed

Comments

@kevingurney
Copy link
Member

Describe the enhancement requested

We would like to modify the display of the arrow.tabular.Table class to be more "MATLAB-like". In order to do this, we need to add a method to the arrow.tabular.Table class which returns a single row of the table as a MATLAB string array.

Component(s)

MATLAB

@sgilmore10
Copy link
Member

take

kevingurney added a commit that referenced this issue Oct 26, 2023
…ular.Table` as a string (#38463)

### Rationale for this change

We would like to modify the display of the `arrow.tabular.Table` and `arrow.tabular.RecordBatch` classes to be more "MATLAB-like". In order to do this, we need to add a method to their respective C++ Proxy classes that  returns a single row of the Table/RecordBatch as a MATLAB `string` array.

### What changes are included in this PR?

Added  new function template:
```cpp 
template <typename TabularLike>
arrow::matlab::tabular::print_row(const std::shared_ptr<TabularLike>& tabularObject, const int64_t row_index) 
```
This function template returns a string representation of the specified row in `tabbularObject`. 

Added a new proxy method called `getRowString` to both the `Table` and `RecordBatch` C++ proxy classes. These methods invoke `print_row` to return a string representation of one row in the `Table`/`RecordBatch`.  Neither MATLAB class `arrow.tabular.Table` nor `arrow.tabular.RecordBatch` expose these methods directly because they will only be used internally for display. 

Below is an example Output of `getRowString()`:

```matlab
>> matlabTable = table([1; 2; 3], ["ABC"; "DE"; "FGH"], datetime(2023, 10, 25) + days(0:2)');
>> arrowTable = arrow.table(matlabTable);
>> rowOneAsString = arrowTable.Proxy.getRowString(struct(Index=int64(1)))

rowOneAsString = 

    "1 | "ABC" | 2023-10-25 00:00:00.000000"
```

### Are these changes tested?

Yes, added a new test class called `tTabularInternal.m`. Because `getRowString()` is not a method on the MATLAB classes `arrow.tabular.Table` and `arrow.tabular.RecordBatch`, this test class calls `getRowString()` on their `Proxy` properties, which are public but hidden.

### Are there any user-facing changes?

No.

* Closes: #38418

Lead-authored-by: Sarah Gilmore <sgilmore@mathworks.com>
Co-authored-by: sgilmore10 <74676073+sgilmore10@users.noreply.github.com>
Co-authored-by: Kevin Gurney <kevin.p.gurney@gmail.com>
Signed-off-by: Kevin Gurney <kgurney@mathworks.com>
@kevingurney kevingurney added this to the 15.0.0 milestone Oct 26, 2023
loicalleyne pushed a commit to loicalleyne/arrow that referenced this issue Nov 13, 2023
…ow.tabular.Table` as a string (apache#38463)

### Rationale for this change

We would like to modify the display of the `arrow.tabular.Table` and `arrow.tabular.RecordBatch` classes to be more "MATLAB-like". In order to do this, we need to add a method to their respective C++ Proxy classes that  returns a single row of the Table/RecordBatch as a MATLAB `string` array.

### What changes are included in this PR?

Added  new function template:
```cpp 
template <typename TabularLike>
arrow::matlab::tabular::print_row(const std::shared_ptr<TabularLike>& tabularObject, const int64_t row_index) 
```
This function template returns a string representation of the specified row in `tabbularObject`. 

Added a new proxy method called `getRowString` to both the `Table` and `RecordBatch` C++ proxy classes. These methods invoke `print_row` to return a string representation of one row in the `Table`/`RecordBatch`.  Neither MATLAB class `arrow.tabular.Table` nor `arrow.tabular.RecordBatch` expose these methods directly because they will only be used internally for display. 

Below is an example Output of `getRowString()`:

```matlab
>> matlabTable = table([1; 2; 3], ["ABC"; "DE"; "FGH"], datetime(2023, 10, 25) + days(0:2)');
>> arrowTable = arrow.table(matlabTable);
>> rowOneAsString = arrowTable.Proxy.getRowString(struct(Index=int64(1)))

rowOneAsString = 

    "1 | "ABC" | 2023-10-25 00:00:00.000000"
```

### Are these changes tested?

Yes, added a new test class called `tTabularInternal.m`. Because `getRowString()` is not a method on the MATLAB classes `arrow.tabular.Table` and `arrow.tabular.RecordBatch`, this test class calls `getRowString()` on their `Proxy` properties, which are public but hidden.

### Are there any user-facing changes?

No.

* Closes: apache#38418

Lead-authored-by: Sarah Gilmore <sgilmore@mathworks.com>
Co-authored-by: sgilmore10 <74676073+sgilmore10@users.noreply.github.com>
Co-authored-by: Kevin Gurney <kevin.p.gurney@gmail.com>
Signed-off-by: Kevin Gurney <kgurney@mathworks.com>
dgreiss pushed a commit to dgreiss/arrow that referenced this issue Feb 19, 2024
…ow.tabular.Table` as a string (apache#38463)

### Rationale for this change

We would like to modify the display of the `arrow.tabular.Table` and `arrow.tabular.RecordBatch` classes to be more "MATLAB-like". In order to do this, we need to add a method to their respective C++ Proxy classes that  returns a single row of the Table/RecordBatch as a MATLAB `string` array.

### What changes are included in this PR?

Added  new function template:
```cpp 
template <typename TabularLike>
arrow::matlab::tabular::print_row(const std::shared_ptr<TabularLike>& tabularObject, const int64_t row_index) 
```
This function template returns a string representation of the specified row in `tabbularObject`. 

Added a new proxy method called `getRowString` to both the `Table` and `RecordBatch` C++ proxy classes. These methods invoke `print_row` to return a string representation of one row in the `Table`/`RecordBatch`.  Neither MATLAB class `arrow.tabular.Table` nor `arrow.tabular.RecordBatch` expose these methods directly because they will only be used internally for display. 

Below is an example Output of `getRowString()`:

```matlab
>> matlabTable = table([1; 2; 3], ["ABC"; "DE"; "FGH"], datetime(2023, 10, 25) + days(0:2)');
>> arrowTable = arrow.table(matlabTable);
>> rowOneAsString = arrowTable.Proxy.getRowString(struct(Index=int64(1)))

rowOneAsString = 

    "1 | "ABC" | 2023-10-25 00:00:00.000000"
```

### Are these changes tested?

Yes, added a new test class called `tTabularInternal.m`. Because `getRowString()` is not a method on the MATLAB classes `arrow.tabular.Table` and `arrow.tabular.RecordBatch`, this test class calls `getRowString()` on their `Proxy` properties, which are public but hidden.

### Are there any user-facing changes?

No.

* Closes: apache#38418

Lead-authored-by: Sarah Gilmore <sgilmore@mathworks.com>
Co-authored-by: sgilmore10 <74676073+sgilmore10@users.noreply.github.com>
Co-authored-by: Kevin Gurney <kevin.p.gurney@gmail.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
Archived in project
2 participants