sgilmore10 opened a new pull request, #38400:
URL: https://github.com/apache/arrow/pull/38400
<!--
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
Currently, the display for `arrow.array.Array`s is not very MATLAB-like:
```matlab
>> a = arrow.array([1 2 3 4])
a =
[
1,
2,
3,
]
```
At the very least, the display should include the class header and indent
each line by 4 spaces. Here's one display option:
```matlab
>> a = arrow.array([1 2 3 4])
a =
Float64Array with 4 elements and 0 null values:
1 | 2 | 3 | 4
```
### What changes are included in this PR?
1. Array display now includes a class header, which states the array type
and the number of elements/nulls in the array.
2. Changed the
[`window`](https://github.com/apache/arrow/blob/37935604bf168a3b2d52f3cc5b0edf83b5783309/cpp/src/arrow/pretty_print.h#L79C1-L80C1)
size to 3 from 10.
3. Primitive and string arrays are displayed horizontally, i.e. set
[`skip_new_lines`](https://github.com/apache/arrow/blob/37935604bf168a3b2d52f3cc5b0edf83b5783309/cpp/src/arrow/pretty_print.h#L90)
to `false`. Uses ` | ` as the delimiter between elements with no
opening/closing brackets.
4. All other array types (`struct`, `list`, etc) are displayed vertically
with an `indent` of 4.
**Example String Array Display:**
```matlab
>> a = arrow.array(["Hello", missing, "Bye"])
a =
StringArray with 3 elements and 1 null value:
"Hello" | null | "Bye"
```
**Example Struct Array Display:**
```matlab
>> a1 = arrow.array(["Hello", missing, "Bye"]);
>> a2 = arrow.array([1 2 3]);
>> structArray = arrow.array.StructArray.fromArrays(a1, a2)
structArray =
StructArray with 3 elements and 0 null values:
-- is_valid: all not null
-- child 0 type: string
[
"Hello",
null,
"Bye"
]
-- child 1 type: double
[
1,
2,
3
]
```
### Are these changes tested?
Yes. Added a new test class called `tArrayDisplay.m` with unit tests for
array display.
### Are there any user-facing changes?
Yes. Users will see a different display for arrays now.
### Future Directions
1. #38166
--
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]