Jackie-Jiang commented on code in PR #15377:
URL: https://github.com/apache/pinot/pull/15377#discussion_r2074285164
##########
pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/RoundDecimalTransformFunction.java:
##########
@@ -90,18 +90,31 @@ public double[] transformToDoubleValuesSV(ValueBlock
valueBlock) {
double[] leftValues =
_leftTransformFunction.transformToDoubleValuesSV(valueBlock);
if (_fixedScale) {
for (int i = 0; i < length; i++) {
- _doubleValuesSV[i] = BigDecimal.valueOf(leftValues[i])
- .setScale(_scale, RoundingMode.HALF_UP).doubleValue();
+ try {
+ _doubleValuesSV[i] = BigDecimal.valueOf(leftValues[i])
+ .setScale(_scale, RoundingMode.HALF_UP).doubleValue();
Review Comment:
Please apply [Pinot
Style](https://docs.pinot.apache.org/developers/developers-and-contributors/code-setup#set-up-ide)
and reformat the changes
##########
pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/RoundDecimalTransformFunction.java:
##########
@@ -90,18 +90,31 @@ public double[] transformToDoubleValuesSV(ValueBlock
valueBlock) {
double[] leftValues =
_leftTransformFunction.transformToDoubleValuesSV(valueBlock);
if (_fixedScale) {
for (int i = 0; i < length; i++) {
- _doubleValuesSV[i] = BigDecimal.valueOf(leftValues[i])
- .setScale(_scale, RoundingMode.HALF_UP).doubleValue();
+ try {
+ _doubleValuesSV[i] = BigDecimal.valueOf(leftValues[i])
+ .setScale(_scale, RoundingMode.HALF_UP).doubleValue();
+ } catch(NumberFormatException nfe) {
+ _doubleValuesSV[i] = leftValues[i];
+ }
}
} else if (_rightTransformFunction != null) {
int[] rightValues =
_rightTransformFunction.transformToIntValuesSV(valueBlock);
for (int i = 0; i < length; i++) {
- _doubleValuesSV[i] = BigDecimal.valueOf(leftValues[i])
- .setScale(rightValues[i], RoundingMode.HALF_UP).doubleValue();
+ try {
+ _doubleValuesSV[i] = BigDecimal.valueOf(leftValues[i])
+ .setScale(rightValues[i],
RoundingMode.HALF_UP).doubleValue();
+ } catch(NumberFormatException nfe) {
+ _doubleValuesSV[i] = leftValues[i];
+ }
}
} else {
for (int i = 0; i < length; i++) {
- _doubleValuesSV[i] = (double) Math.round(leftValues[i]);
+ if (leftValues[i] == Double.NEGATIVE_INFINITY || leftValues[i] ==
Double.POSITIVE_INFINITY ||
+ leftValues[i] == Double.NaN) {
Review Comment:
```suggestion
Double.isNaN(leftValues[i])) {
```
--
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]