File tree 4 files changed +10
-12
lines changed
main/java/org/opensearch/sql/opensearch/response/agg
test/java/org/opensearch/sql/opensearch/response
4 files changed +10
-12
lines changed Original file line number Diff line number Diff line change 13
13
14
14
package org .opensearch .sql .opensearch .response .agg ;
15
15
16
- import static org .opensearch .sql .opensearch .response .agg .Utils .handleNanInfValue ;
16
+ import static org .opensearch .sql .opensearch .response .agg .Utils .handleNanValue ;
17
17
18
18
import java .util .Collections ;
19
19
import java .util .Map ;
@@ -34,6 +34,6 @@ public class SingleValueParser implements MetricParser {
34
34
public Map <String , Object > parse (Aggregation agg ) {
35
35
return Collections .singletonMap (
36
36
agg .getName (),
37
- handleNanInfValue (((NumericMetricsAggregation .SingleValue ) agg ).value ()));
37
+ handleNanValue (((NumericMetricsAggregation .SingleValue ) agg ).value ()));
38
38
}
39
39
}
Original file line number Diff line number Diff line change 13
13
14
14
package org .opensearch .sql .opensearch .response .agg ;
15
15
16
- import static org .opensearch .sql .opensearch .response .agg .Utils .handleNanInfValue ;
16
+ import static org .opensearch .sql .opensearch .response .agg .Utils .handleNanValue ;
17
17
18
18
import java .util .Collections ;
19
19
import java .util .Map ;
@@ -36,6 +36,6 @@ public class StatsParser implements MetricParser {
36
36
@ Override
37
37
public Map <String , Object > parse (Aggregation agg ) {
38
38
return Collections .singletonMap (
39
- agg .getName (), handleNanInfValue (valueExtractor .apply ((ExtendedStats ) agg )));
39
+ agg .getName (), handleNanValue (valueExtractor .apply ((ExtendedStats ) agg )));
40
40
}
41
41
}
Original file line number Diff line number Diff line change 18
18
@ UtilityClass
19
19
public class Utils {
20
20
/**
21
- * Utils to handle Nan/Infinite Value.
22
- * @return null if is Nan or is +-Infinity .
21
+ * Utils to handle Nan Value.
22
+ * @return null if is Nan.
23
23
*/
24
- public static Object handleNanInfValue (double value ) {
25
- return Double .isNaN (value ) || Double . isInfinite ( value ) ? null : value ;
24
+ public static Object handleNanValue (double value ) {
25
+ return Double .isNaN (value ) ? null : value ;
26
26
}
27
27
}
Original file line number Diff line number Diff line change 13
13
import static org .junit .jupiter .api .Assertions .assertNull ;
14
14
import static org .junit .jupiter .api .Assertions .assertThrows ;
15
15
import static org .opensearch .sql .opensearch .response .AggregationResponseUtils .fromJson ;
16
- import static org .opensearch .sql .opensearch .response .agg .Utils .handleNanInfValue ;
16
+ import static org .opensearch .sql .opensearch .response .agg .Utils .handleNanValue ;
17
17
18
18
import com .google .common .collect .ImmutableMap ;
19
19
import java .util .List ;
@@ -161,9 +161,7 @@ void unsupported_aggregation_should_fail() {
161
161
162
162
@ Test
163
163
void nan_value_should_return_null () {
164
- assertNull (handleNanInfValue (Double .NaN ));
165
- assertNull (handleNanInfValue (Double .NEGATIVE_INFINITY ));
166
- assertNull (handleNanInfValue (Double .POSITIVE_INFINITY ));
164
+ assertNull (handleNanValue (Double .NaN ));
167
165
}
168
166
169
167
@ Test
You can’t perform that action at this time.
0 commit comments