ngli-me commented on code in PR #6758:
URL: https://github.com/apache/arrow-rs/pull/6758#discussion_r1892139920
##########
arrow-array/src/record_batch.rs:
##########
@@ -394,6 +396,56 @@ impl RecordBatch {
)
}
+ /// Normalize a semi-structured [`RecordBatch`] into a flat table.
+ ///
+ /// If max_level is 0, normalizes all levels.
+ pub fn normalize(&self, separator: &str, mut max_level: usize) ->
Result<Self, ArrowError> {
+ if max_level == 0 {
+ max_level = usize::MAX;
+ }
+ if self.num_rows() == 0 {
Review Comment:
Yeah, I'm not sure the best case to handle this.
I think the secondary case can be removed, as I missed that even with a
`new_empty` RecordBatch, it will still have an (empty) columns field, good
catch!
For the `usize::MAX` setting, this was because polars/pandas had this , with
a default value of 0. However, since Rust does not have default parameters, I
wasn't sure the best way to adapt this.
A possible idea could be to set up like
```
enum Depth {
Default, // All levels
Value(usize)
}
```
then do some matching? Might be overkill though.
And of course, there's the option of removing it altogether, although then a
value of 0 would mean no change?
--
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]