zhiqiang-hhhh commented on code in PR #34680: URL: https://github.com/apache/doris/pull/34680#discussion_r1600920451
########## be/src/vec/functions/function_string.h: ########## @@ -3058,70 +3121,55 @@ struct MoneyFormatDecimalImpl { size_t input_rows_count) { if (auto* decimalv2_column = check_and_get_column<ColumnDecimal<Decimal128V2>>(*col_ptr)) { for (size_t i = 0; i < input_rows_count; i++) { - DecimalV2Value value = DecimalV2Value(decimalv2_column->get_element(i)); - + const Decimal128V2& dec128 = decimalv2_column->get_element(i); + DecimalV2Value value = DecimalV2Value(dec128.value); DecimalV2Value rounded(0); - value.round(&rounded, 2, HALF_UP); - - StringRef str = MoneyFormat::do_money_format<int64_t, 26>( - context, rounded.int_value(), abs(rounded.frac_value() / 10000000)); + value.round(&rounded, 2, TRUNCATE); + StringRef str = + MoneyFormat::do_money_format<Int128, + MoneyFormat::MAX_FORMAT_LEN_DEC128V2()>( + context, 2, rounded.int_value(), rounded.frac_value() / 10000000, + false /*not do truncate*/); result_column->insert_data(str.data, str.size); } } else if (auto* decimal32_column = check_and_get_column<ColumnDecimal<Decimal32>>(*col_ptr)) { const UInt32 scale = decimal32_column->get_scale(); - // scale is up to 9, so exp10_i32 is enough - const auto multiplier = common::exp10_i32(std::abs(static_cast<int>(scale - 2))); for (size_t i = 0; i < input_rows_count; i++) { - Decimal32 frac_part = decimal32_column->get_fractional_part(i); - if (scale > 2) { - int delta = ((frac_part % multiplier) << 1) > multiplier; - frac_part = frac_part / multiplier + delta; Review Comment: doing round now -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org