Skip to content

Commit d734103

Browse files
Revert opensearch-project#817 fix, extracted to a separate branch.
Signed-off-by: Yury-Fridlyand <[email protected]>
1 parent f14b66f commit d734103

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

opensearch/src/main/java/org/opensearch/sql/opensearch/response/agg/SingleValueParser.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
package org.opensearch.sql.opensearch.response.agg;
1515

16-
import static org.opensearch.sql.opensearch.response.agg.Utils.handleNanInfValue;
16+
import static org.opensearch.sql.opensearch.response.agg.Utils.handleNanValue;
1717

1818
import java.util.Collections;
1919
import java.util.Map;
@@ -34,6 +34,6 @@ public class SingleValueParser implements MetricParser {
3434
public Map<String, Object> parse(Aggregation agg) {
3535
return Collections.singletonMap(
3636
agg.getName(),
37-
handleNanInfValue(((NumericMetricsAggregation.SingleValue) agg).value()));
37+
handleNanValue(((NumericMetricsAggregation.SingleValue) agg).value()));
3838
}
3939
}

opensearch/src/main/java/org/opensearch/sql/opensearch/response/agg/StatsParser.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
package org.opensearch.sql.opensearch.response.agg;
1515

16-
import static org.opensearch.sql.opensearch.response.agg.Utils.handleNanInfValue;
16+
import static org.opensearch.sql.opensearch.response.agg.Utils.handleNanValue;
1717

1818
import java.util.Collections;
1919
import java.util.Map;
@@ -36,6 +36,6 @@ public class StatsParser implements MetricParser {
3636
@Override
3737
public Map<String, Object> parse(Aggregation agg) {
3838
return Collections.singletonMap(
39-
agg.getName(), handleNanInfValue(valueExtractor.apply((ExtendedStats) agg)));
39+
agg.getName(), handleNanValue(valueExtractor.apply((ExtendedStats) agg)));
4040
}
4141
}

opensearch/src/main/java/org/opensearch/sql/opensearch/response/agg/Utils.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
@UtilityClass
1919
public class Utils {
2020
/**
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.
2323
*/
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;
2626
}
2727
}

opensearch/src/test/java/org/opensearch/sql/opensearch/response/OpenSearchAggregationResponseParserTest.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import static org.junit.jupiter.api.Assertions.assertNull;
1414
import static org.junit.jupiter.api.Assertions.assertThrows;
1515
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;
1717

1818
import com.google.common.collect.ImmutableMap;
1919
import java.util.List;
@@ -161,9 +161,7 @@ void unsupported_aggregation_should_fail() {
161161

162162
@Test
163163
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));
167165
}
168166

169167
@Test

0 commit comments

Comments
 (0)