Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Invalid
-
None
-
None
-
None
Description
jorgecarleitao offered a great way to improve the Debug/Display implementations for various Array implementations on https://github.com/apache/arrow/pull/9624#issuecomment-790976766
The only reason we are implementing to_isize/to_usize on NativeType is because we have a function to represent an array (for Display) that accepts a generic physical type T, and then tries to convert it to a isize depending on a logical type (DataType::Date). However, there is already a Many to one relationship between logical and physical types.
Thus, a solution for this is to have the `Debug` function branch off depending on the (logical) datatype, implementing the custom string representation depending on it, instead of having a loop of native type T and then branching off according to the DataType inside the loop.
I.e. instead of
for i in ... { match data_type { DataType::Date32 => represent array[i] as date DataType::Int32 => represent array[i] as int } }
imo we should have
match data_type { DataType::Date32 => for i in ... {represent array[i] as date} DataType::Int32 => for i in ... {represent array[i] as int} }
i.e. treat the Display as any other "kernel", where behavior is logical, not physical, type-dependent.