alamb commented on a change in pull request #406:
URL: https://github.com/apache/arrow-rs/pull/406#discussion_r646114701
##########
File path: arrow/src/util/display.rs
##########
@@ -192,18 +194,34 @@ macro_rules! make_string_from_list {
}};
}
-macro_rules! make_string_from_decimal {
- ($array_type: ty, $column: ident, $row: ident, $scale: ident) => {{
- let array = $column.as_any().downcast_ref::<$array_type>().unwrap();
- let decimal_string = array.value($row).to_string();
- let formatted_decimal = if *$scale == 0 {
- decimal_string
- } else {
- let splits = decimal_string.split_at(decimal_string.len() -
*$scale);
- format!("{}.{}", splits.0, splits.1)
- };
- Ok(formatted_decimal)
- }};
+#[inline(always)]
+pub fn make_string_from_decimal_value(
Review comment:
Since `scale` is part of the DataType` you probably don't need to pass
it in here.
Like you could do something like:
```
let scale = array.scale()
```
It might even be worth putting this function on `DecimalArray` itself
(something like `DecimalArray::value_as_stiring(offset)` to mirrow the
`value_as_datetime` et al functions on the `Time*` array types.
Normally I wouldn't be picky about this but since this is a new public
function (aka being added to the API) I felt it was worth some extra thought.
--
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]