|
16 | 16 | import static org.opensearch.sql.util.MatcherUtils.kvString; |
17 | 17 |
|
18 | 18 | import java.io.IOException; |
| 19 | +import java.math.BigDecimal; |
19 | 20 | import java.util.ArrayList; |
20 | 21 | import java.util.function.Function; |
21 | 22 | import org.hamcrest.BaseMatcher; |
@@ -316,7 +317,7 @@ public void aggregationWithoutGroupBy() throws IOException { |
316 | 317 | JSONObject result = executeQuery(sql); |
317 | 318 | JSONObject aggregation = getAggregation(result, "message.dayOfWeek@NESTED"); |
318 | 319 |
|
319 | | - Assert.assertThat((Double) aggregation.query("/avgDay/value"), closeTo(3.166666666, 0.01)); |
| 320 | + Assert.assertThat(((BigDecimal) aggregation.query("/avgDay/value")).doubleValue(), closeTo(3.166666666, 0.01)); |
320 | 321 | } |
321 | 322 |
|
322 | 323 | @Test |
@@ -350,10 +351,10 @@ public void groupByRegularFieldAndSum() throws IOException { |
350 | 351 | Assert.assertNotNull(msgInfoBuckets); |
351 | 352 | Assert.assertThat(msgInfoBuckets.length(), equalTo(2)); |
352 | 353 | Assert.assertThat(msgInfoBuckets.query("/0/key"), equalTo("a")); |
353 | | - Assert.assertThat((Double) msgInfoBuckets.query("/0/message.dayOfWeek@NESTED/sumDay/value"), |
| 354 | + Assert.assertThat(((BigDecimal) msgInfoBuckets.query("/0/message.dayOfWeek@NESTED/sumDay/value")).doubleValue(), |
354 | 355 | closeTo(9.0, 0.01)); |
355 | 356 | Assert.assertThat(msgInfoBuckets.query("/1/key"), equalTo("b")); |
356 | | - Assert.assertThat((Double) msgInfoBuckets.query("/1/message.dayOfWeek@NESTED/sumDay/value"), |
| 357 | + Assert.assertThat(((BigDecimal) msgInfoBuckets.query("/1/message.dayOfWeek@NESTED/sumDay/value")).doubleValue(), |
357 | 358 | closeTo(10.0, 0.01)); |
358 | 359 | } |
359 | 360 |
|
@@ -593,12 +594,12 @@ public void maxAggOnNestedInnerFieldWithoutWhere() throws IOException { |
593 | 594 | Assert.assertThat(bucket.length(), equalTo(2)); |
594 | 595 | Assert.assertThat(bucket.query("/0/key"), equalTo("Bob Smith")); |
595 | 596 | Assert.assertThat( |
596 | | - bucket.query("/0/projects.started_year@NESTED/projects.started_year@FILTER/max/value"), |
597 | | - equalTo(2015.0)); |
| 597 | + ((BigDecimal) bucket.query("/0/projects.started_year@NESTED/projects.started_year@FILTER/max/value")).doubleValue(), |
| 598 | + closeTo(2015.0, 0.01)); |
598 | 599 | Assert.assertThat(bucket.query("/1/key"), equalTo("Jane Smith")); |
599 | 600 | Assert.assertThat( |
600 | | - bucket.query("/1/projects.started_year@NESTED/projects.started_year@FILTER/max/value"), |
601 | | - equalTo(2015.0)); |
| 601 | + ((BigDecimal) bucket.query("/1/projects.started_year@NESTED/projects.started_year@FILTER/max/value")).doubleValue(), |
| 602 | + closeTo(2015.0, 0.01)); |
602 | 603 | } |
603 | 604 |
|
604 | 605 | @Test |
@@ -780,12 +781,12 @@ public void havingMaxAggOnNestedInnerFieldWithoutWhere() throws IOException { |
780 | 781 | Assert.assertThat(bucket.length(), equalTo(2)); |
781 | 782 | Assert.assertThat(bucket.query("/0/key"), equalTo("Bob Smith")); |
782 | 783 | Assert.assertThat( |
783 | | - bucket.query("/0/projects.started_year@NESTED/projects.started_year@FILTER/max_0/value"), |
784 | | - equalTo(2015.0)); |
| 784 | + ((BigDecimal) bucket.query("/0/projects.started_year@NESTED/projects.started_year@FILTER/max_0/value")).doubleValue(), |
| 785 | + closeTo(2015.0, 0.01)); |
785 | 786 | Assert.assertThat(bucket.query("/1/key"), equalTo("Jane Smith")); |
786 | 787 | Assert.assertThat( |
787 | | - bucket.query("/1/projects.started_year@NESTED/projects.started_year@FILTER/max_0/value"), |
788 | | - equalTo(2015.0)); |
| 788 | + ((BigDecimal) bucket.query("/1/projects.started_year@NESTED/projects.started_year@FILTER/max_0/value")).doubleValue(), |
| 789 | + closeTo(2015.0, 0.01)); |
789 | 790 | } |
790 | 791 |
|
791 | 792 | /*********************************************************** |
|
0 commit comments