Skip to content

Commit 3edd1cf

Browse files
committed
This commit:
1. For round function for decimal values, if value is infinity or NaN, assign as such with no rouding operation 2. If null bit map for column contains docid and it's a Double, set value to negative infinity
1 parent c5514f6 commit 3edd1cf

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

pinot-core/src/main/java/org/apache/pinot/core/operator/query/SelectionOnlyOperator.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ protected SelectionResultsBlock getNextBlock() {
132132
Object[] values = blockValueFetcher.getRow(docId);
133133
for (int colId = 0; colId < numExpressions; colId++) {
134134
if (_nullBitmaps[colId] != null && _nullBitmaps[colId].contains(docId)) {
135-
values[colId] = null;
135+
if (values[colId] instanceof Double) {
136+
values[colId] = Double.NEGATIVE_INFINITY;
137+
} else {
138+
values[colId] = null;
139+
}
136140
}
137141
}
138142
_rows.add(values);

pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/RoundDecimalTransformFunction.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,33 @@ public double[] transformToDoubleValuesSV(ValueBlock valueBlock) {
9090
double[] leftValues = _leftTransformFunction.transformToDoubleValuesSV(valueBlock);
9191
if (_fixedScale) {
9292
for (int i = 0; i < length; i++) {
93-
_doubleValuesSV[i] = BigDecimal.valueOf(leftValues[i])
94-
.setScale(_scale, RoundingMode.HALF_UP).doubleValue();
93+
if (leftValues[i] == Double.NEGATIVE_INFINITY || leftValues[i] == Double.POSITIVE_INFINITY ||
94+
leftValues[i] == Double.NaN) {
95+
_doubleValuesSV[i] = leftValues[i];
96+
} else {
97+
_doubleValuesSV[i] = BigDecimal.valueOf(leftValues[i])
98+
.setScale(_scale, RoundingMode.HALF_UP).doubleValue();
99+
}
95100
}
96101
} else if (_rightTransformFunction != null) {
97102
int[] rightValues = _rightTransformFunction.transformToIntValuesSV(valueBlock);
98103
for (int i = 0; i < length; i++) {
99-
_doubleValuesSV[i] = BigDecimal.valueOf(leftValues[i])
100-
.setScale(rightValues[i], RoundingMode.HALF_UP).doubleValue();
104+
if (leftValues[i] == Double.NEGATIVE_INFINITY || leftValues[i] == Double.POSITIVE_INFINITY ||
105+
leftValues[i] == Double.NaN) {
106+
_doubleValuesSV[i] = leftValues[i];
107+
} else {
108+
_doubleValuesSV[i] = BigDecimal.valueOf(leftValues[i])
109+
.setScale(rightValues[i], RoundingMode.HALF_UP).doubleValue();
110+
}
101111
}
102112
} else {
103113
for (int i = 0; i < length; i++) {
114+
if (leftValues[i] == Double.NEGATIVE_INFINITY || leftValues[i] == Double.POSITIVE_INFINITY ||
115+
leftValues[i] == Double.NaN) {
116+
_doubleValuesSV[i] = leftValues[i];
117+
} else {
104118
_doubleValuesSV[i] = (double) Math.round(leftValues[i]);
119+
}
105120
}
106121
}
107122
return _doubleValuesSV;

0 commit comments

Comments
 (0)