xiangfu0 commented on code in PR #17652:
URL: https://github.com/apache/pinot/pull/17652#discussion_r2785473520
##########
pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/TruncateDecimalTransformFunction.java:
##########
@@ -98,7 +98,22 @@ public double[] transformToDoubleValuesSV(ValueBlock
valueBlock) {
}
} else {
for (int i = 0; i < length; i++) {
- _doubleValuesSV[i] = Math.signum(leftValues[i]) *
Math.floor(Math.abs(leftValues[i]));
+ double value = leftValues[i];
+ if (!Double.isFinite(value)) {
+ // Preserve historical behavior for NaN and infinities.
+ _doubleValuesSV[i] = value;
+ continue;
+ }
+ double truncated;
+ if (value > 0.0d) {
+ truncated = Math.floor(value);
+ } else if (value < 0.0d) {
+ truncated = Math.ceil(value);
+ } else {
+ truncated = 0.0d;
+ }
+ // Normalize -0.0 to +0.0 for deterministic output and test stability.
Review Comment:
Will separate
--
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]