Skip to content

Commit 34985c7

Browse files
committed
Update testBetweenWithIncompatibleTypes
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
1 parent 502dbb0 commit 34985c7

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalcitePPLBasicIT.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import static org.opensearch.sql.util.MatcherUtils.schema;
1111
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows;
1212
import static org.opensearch.sql.util.MatcherUtils.verifyErrorMessageContains;
13+
import static org.opensearch.sql.util.MatcherUtils.verifyNumOfRows;
1314
import static org.opensearch.sql.util.MatcherUtils.verifySchema;
1415

1516
import java.io.IOException;
@@ -464,17 +465,17 @@ public void testBetweenWithMixedTypes() throws IOException {
464465
}
465466

466467
@Test
467-
public void testBetweenWithIncompatibleTypes() {
468-
// Plan: CAST(NUMBER_TO_STRING(38.5:DECIMAL(3, 1))):INTEGER)
469-
Throwable e =
470-
assertThrowsWithReplace(
471-
NumberFormatException.class,
472-
() ->
473-
executeQuery(
474-
String.format(
475-
"source=%s | where age between '35' and 38.5 | fields firstname, age",
476-
TEST_INDEX_BANK)));
477-
verifyErrorMessageContains(e, "For input string: \\\"38.5\\\"");
468+
public void testBetweenWithIncompatibleTypes() throws IOException {
469+
// Plan: SAFE_CAST(NUMBER_TO_STRING(38.5:DECIMAL(3, 1))). The least restrictive type between
470+
// int, decimal, and varchar is resolved to varchar. between '35' and '38.5' is then optimized
471+
// to empty rows
472+
JSONObject actual =
473+
executeQuery(
474+
String.format(
475+
"source=%s | where age between '35' and 38.5 | fields firstname, age",
476+
TEST_INDEX_BANK));
477+
verifySchema(actual, schema("firstname", "string"), schema("age", "int"));
478+
verifyNumOfRows(actual, 0);
478479
}
479480

480481
@Test

0 commit comments

Comments
 (0)