github-actions[bot] commented on code in PR #64577:
URL: https://github.com/apache/doris/pull/64577#discussion_r3427055227


##########
be/src/exprs/function/cast/cast_to_string.h:
##########
@@ -118,8 +118,9 @@ struct CastToString {
                 end = fmt::format_to(buffer, FMT_COMPILE("{:.{}g}"), value,
                                      std::numeric_limits<float>::digits10 + 1);
             } else {
-                end = fmt::format_to(buffer, FMT_COMPILE("{:.{}g}"), value,
-                                     std::numeric_limits<double>::digits10 + 
1);
+                // shortest round-trip, fixed-precision %g would expose 
IEEE-754
+                // residual error e.g. round(23900/293, 2) -> 
"81.56999999999999".
+                end = fmt::format_to(buffer, FMT_COMPILE("{}"), value);

Review Comment:
   This helper is also used by 
`DataTypeNumberSerDe<TYPE_DOUBLE>::to_olap_string` 
(`be/src/core/data_type_serde/data_type_number_serde.cpp` calls 
`CastToString::from_number(field.get<T>())`), so the new double spelling 
reaches the storage/zonemap string path as well as SQL casts. The direct cast 
UT was updated, but `be/test/storage/olap_type_test.cpp` still expects the old 
outputs in `ser_deser_double` and `ser_deser_double_olap_string`, for example 
`12345678901234567.12345 -> 1.234567890123457e+16`, `DBL_MAX -> 
1.797693134862316e+308`, and `denorm_min -> 4.940656458412465e-324`. With this 
formatter those calls now produce the new shortest strings 
(`1.2345678901234568e+16`, `1.7976931348623157e+308`, `5e-324`), and the 
max/lowest comments/status expectations need to change because the new finite 
spellings parse back successfully. Please update that storage serde test path 
too, or keep `to_olap_string` on the old formatting if this PR is intended to 
affect only SQL cast/query output.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to