|
10 | 10 | import static org.opensearch.sql.util.MatcherUtils.schema; |
11 | 11 | import static org.opensearch.sql.util.MatcherUtils.verifyDataRows; |
12 | 12 | import static org.opensearch.sql.util.MatcherUtils.verifyErrorMessageContains; |
| 13 | +import static org.opensearch.sql.util.MatcherUtils.verifyNumOfRows; |
13 | 14 | import static org.opensearch.sql.util.MatcherUtils.verifySchema; |
14 | 15 |
|
15 | 16 | import java.io.IOException; |
@@ -464,17 +465,17 @@ public void testBetweenWithMixedTypes() throws IOException { |
464 | 465 | } |
465 | 466 |
|
466 | 467 | @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); |
478 | 479 | } |
479 | 480 |
|
480 | 481 | @Test |
|
0 commit comments