abhinav-phi commented on code in PR #68733:
URL: https://github.com/apache/doris/pull/68733#discussion_r4297786035
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/FractionalLiteral.java:
##########
@@ -53,7 +53,11 @@ protected Expression uncheckedCastTo(DataType targetType)
throws AnalysisExcepti
if (!isFinite) {
throw new CastException(String.format("%s can't cast to %s in
strict mode.", getValue(), targetType));
}
- BigDecimal decimal = new BigDecimal(value.toString());
+ // BE converts the binary value, not the shortest decimal
representation of
+ // the float/double, so a magnitude such as 1e38 must keep the
double's exact value
+ BigDecimal decimal = value instanceof Double || value instanceof
Float
+ ? new BigDecimal(((Number) value).doubleValue())
Review Comment:
update: i went ahead and fixed this here rather than leave it to the other
branch, 34375dcf79.
`FloatLiteral.uncheckedCastTo` now widens with `(double) value` instead of
`Double.parseDouble(String.valueOf(value))`, so a FLOAT that reaches an
integral type through a DOUBLE keeps the same value as the direct path. The
concrete gap was 1e20f: the binary widening is 100000002004087734272, while
1.0E20 is exactly representable as a double as 100000000000000000000, so the
printed round trip lost 2004087734272 at that step. FloatLiteralTest now
asserts both the widened double and the two step path to LARGEINT.
this does overlap #68730 on that one line, which is why I had left it alone.
whichever of the two lands second will just see the line already in place.
no test_cast.out row moves for this, that file has no FLOAT to DOUBLE case,
so the re-recorded rows from the previous commit are unaffected. as before I
cannot run maven here, so CI is what confirms it.
--
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]