mrhhsg commented on code in PR #68488:
URL: https://github.com/apache/doris/pull/68488#discussion_r4104678627
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/DoubleLiteral.java:
##########
@@ -86,8 +86,10 @@ protected Expression uncheckedCastTo(DataType targetType)
throws AnalysisExcepti
return this;
}
if (targetType.isFloatType()) {
- return new
org.apache.doris.nereids.trees.expressions.literal.FloatLiteral(
- Float.parseFloat(String.valueOf(value)));
+ // narrow with a single rounding and keep the sign of a NaN, like
static_cast<float> on BE
Review Comment:
Not changed in this PR. You are right that the Thrift binary/compact
`writeDouble` (`Double.doubleToLongBits`) turns every NaN into the positive
pattern. That applies to every NaN literal sent in a fragment and is not
specific to this change. At the merge base the result was the same:
`CAST('-nan' AS DOUBLE)` folded to the positive NaN, so `signbit(IF(number=0,
CAST('-nan' AS DOUBLE), 0.0))` already returned false with folding on and true
with `debug_skip_fold_constant`. This PR keeps the sign only where FE evaluates
the whole expression, and does not make any case worse.
For `percentile_reservoir`, the level is now replaced by the FE-validated
literal, and a NaN level is rejected, so this cannot change the executed level.
Keeping the sign across the wire needs either a raw-bit field in
`TFloatLiteral` (protocol and compatibility work on both FE and BE) or keeping
sign-producing constants unfolded in general. Either one is an
optimizer/protocol decision outside this function fix, and I'd rather handle it
in a separate PR.
--
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]