alamb commented on a change in pull request #8332:
URL: https://github.com/apache/arrow/pull/8332#discussion_r499137657
##########
File path: rust/arrow/src/util/pretty.rs
##########
@@ -71,24 +71,22 @@ fn create_table(results: &[RecordBatch]) -> Result<Table> {
macro_rules! make_string {
($array_type:ty, $column: ident, $row: ident) => {{
- Ok($column
- .as_any()
- .downcast_ref::<$array_type>()
- .unwrap()
- .value($row)
- .to_string())
+ let array = $column.as_any().downcast_ref::<$array_type>().unwrap();
+
+ let s = if array.is_null($row) {
+ "".to_string()
+ } else {
+ array.value($row).to_string()
+ };
+
+ Ok(s)
}};
}
/// Get the value at the given row in an array as a string
fn array_value_to_string(column: array::ArrayRef, row: usize) ->
Result<String> {
match column.data_type() {
- DataType::Utf8 => Ok(column
Review comment:
There was no reason `Utf8` couldn't use the same `make_string!` macro so
I unified the code paths
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]