kevingurney opened a new pull request, #37981:
URL: https://github.com/apache/arrow/pull/37981

   ### Rationale for this change
   
   In order to make the 
[`arrow::PrettyPrint`](https://github.com/apache/arrow/blob/7667b81bffcb5b361fab6d61c42ce396d98cc6e1/cpp/src/arrow/pretty_print.h#L101)
 functionality for `arrow::Array` more flexible, it would be useful to be to 
specify a custom `Array` element delimiter other than `","`.
   
   For example, the MATLAB interface wraps the Arrow C++ libraries and being 
able to specify a custom `Array` element delimiter, would make it possible to 
make the display of MATLAB `arrow.array.Array` objects more MATLAB-like.
   
   For the MATLAB interface, we would like to enable display that looks 
something like the following (note the ` | ` between individual `Array` 
elements:
   
   ```matlab
   % Make a MATLAB array.
   >> A = 1:5
   
   A =
   
        1     2     3     4     5
   
   % Make an Arrow array from the MATLAB array.
   >> B = arrow.array(A)
   
   B = 
   
       [ 1 | 2 | 3 | 4 | 5 ]
   ```
   
   In order to support custom `Array` element delimiters, this pull request 
adds a new option `array_element_delimiter` with type `std::string` to the 
[`arrow::PrettyPrintOptions`](https://github.com/apache/arrow/blob/7667b81bffcb5b361fab6d61c42ce396d98cc6e1/cpp/src/arrow/pretty_print.h#L35)
 struct.
   
   In a future pull request, we would like to enable more `PrettyPrintOptions` 
like custom closing and opening delimiters for `arrow::Array` (e.g. "<" rather 
than "[" and ">" rather than "]").
   
   ### What changes are included in this PR?
   
   1. Added a new option  `array_element_delimiter` with type `std::string` to 
the 
[`arrow::PrettyPrintOptions`](https://github.com/apache/arrow/blob/7667b81bffcb5b361fab6d61c42ce396d98cc6e1/cpp/src/arrow/pretty_print.h#L35)
 struct. This option allows the user to specify any string value as the 
delimiter to distinguish between individual elements of an `arrow::Array` when 
being printed using 
[`arrow::PrettyPrint`](https://github.com/apache/arrow/blob/7667b81bffcb5b361fab6d61c42ce396d98cc6e1/cpp/src/arrow/pretty_print.h#L101).
   
   ### Are these changes tested?
   
   Yes.
   
   1. Added new tests `PrimitiveTypeCustomArrayElementDelimiter` and 
`ChunkedArrayPrimitiveTypeCustomArrayDelimiter` to `pretty_print_test.cc`.
   2. All existing `PrettyPrint`-related C++ tests pass.
   
   ### Are there any user-facing changes?
   
   Yes.
   
   1. User's can now specify a custom `Array` element delimiter when printing 
`arrow::Array`s using  
[`arrow::PrettyPrint`](https://github.com/apache/arrow/blob/7667b81bffcb5b361fab6d61c42ce396d98cc6e1/cpp/src/arrow/pretty_print.h#L101)
 by specifying a value for the `array_element_delimiter` property of 
[`arrow::PrettyPrintOptions`](https://github.com/apache/arrow/blob/7667b81bffcb5b361fab6d61c42ce396d98cc6e1/cpp/src/arrow/pretty_print.h#L35).
   
   ### Future Directions
   
   1. To keep this pull request small and focused, I intentionally chose not to 
include changes related to specifying custom opening and closing `Array` 
delimiters (e.g. use `<` and `>` instead of `[` and `]`). I've captured the 
idea of supporting custom opening and closing `Array` delimiters in #37979. I 
will follow up with a future PR to address this.
   
   ### Notes
   
   1. This pull request was motivated by our desire to improve the display of 
Arrow related classes in the MATLAB interface, but it is hopefully a generic 
enough change that it may benefit other use cases too.


-- 
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]

Reply via email to