Skip to content

Commit 3c44b4b

Browse files
committed
Fix flaky test
Signed-off-by: Lantao Jin <ltjin@amazon.com>
1 parent 290e25d commit 3c44b4b

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

integ-test/src/test/java/org/opensearch/sql/calcite/tpch/CalcitePPLTpchIT.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void testQ1() throws IOException {
5454
schema("count_order", "bigint"));
5555
verifyDataRows(
5656
actual,
57-
rows(
57+
closeTo(
5858
"A",
5959
"F",
6060
37474,
@@ -65,7 +65,7 @@ public void testQ1() throws IOException {
6565
isPushdownEnabled() ? 25419.231826792962 : 25419.231826792948,
6666
isPushdownEnabled() ? 0.0508660351826793 : 0.050866035182679493,
6767
1478),
68-
rows(
68+
closeTo(
6969
"N",
7070
"F",
7171
1041,
@@ -76,7 +76,7 @@ public void testQ1() throws IOException {
7676
27402.659736842103,
7777
isPushdownEnabled() ? 0.04289473684210526 : 0.042894736842105284,
7878
38),
79-
rows(
79+
closeTo(
8080
"N",
8181
"O",
8282
75168,
@@ -87,7 +87,7 @@ public void testQ1() throws IOException {
8787
isPushdownEnabled() ? 25632.42277116627 : 25632.422771166166,
8888
isPushdownEnabled() ? 0.049697381842910573 : 0.04969738184291069,
8989
2941),
90-
rows(
90+
closeTo(
9191
"R",
9292
"F",
9393
36511,

integ-test/src/test/java/org/opensearch/sql/util/MatcherUtils.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,16 +292,21 @@ protected boolean matchesSafely(JSONArray array) {
292292
};
293293
}
294294

295-
public static TypeSafeMatcher<JSONArray> closeTo(Number... values) {
295+
public static TypeSafeMatcher<JSONArray> closeTo(Object... values) {
296296
final double error = 1e-10;
297297
return new TypeSafeMatcher<JSONArray>() {
298298
@Override
299299
protected boolean matchesSafely(JSONArray item) {
300-
List<Number> expectedValues = new ArrayList<>(Arrays.asList(values));
301-
List<Number> actualValues = new ArrayList<>();
302-
item.iterator().forEachRemaining(v -> actualValues.add((Number) v));
300+
List<Object> expectedValues = new ArrayList<>(Arrays.asList(values));
301+
List<Object> actualValues = new ArrayList<>();
302+
item.iterator().forEachRemaining(v -> actualValues.add((Object) v));
303303
return actualValues.stream()
304-
.allMatch(v -> valuesAreClose(v, expectedValues.get(actualValues.indexOf(v))));
304+
.allMatch(
305+
v ->
306+
v instanceof Number
307+
? valuesAreClose(
308+
(Number) v, (Number) expectedValues.get(actualValues.indexOf(v)))
309+
: v.equals(expectedValues.get(actualValues.indexOf(v))));
305310
}
306311

307312
@Override

0 commit comments

Comments
 (0)