From f9f148384279be121213e8551fb008b49af12e9f Mon Sep 17 00:00:00 2001 From: currantw Date: Wed, 11 Dec 2024 10:12:44 -0800 Subject: [PATCH] Fix failing code coverage Signed-off-by: currantw --- .../opensearch/storage/script/filter/lucene/LuceneQuery.java | 5 +---- .../storage/script/filter/lucene/RangeQueryTest.java | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/LuceneQuery.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/LuceneQuery.java index 36ebb92253..26ef56e576 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/LuceneQuery.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/LuceneQuery.java @@ -215,10 +215,7 @@ private ExprValue cast(FunctionExpression castFunction, ReferenceExpression ref) .put( BuiltinFunctionName.CAST_TO_IP.getName(), (expr, ref) -> { - ExprValue value = expr.valueOf(); - return value.type().equals(ExprCoreType.IP) - ? value - : new ExprIpValue(value.stringValue()); + return new ExprIpValue(expr.valueOf().stringValue()); }) .put( BuiltinFunctionName.CAST_TO_DATE.getName(), diff --git a/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/RangeQueryTest.java b/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/RangeQueryTest.java index 2f5482171d..55272d4cd7 100644 --- a/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/RangeQueryTest.java +++ b/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/RangeQueryTest.java @@ -85,8 +85,8 @@ void test_date_has_format() { } @Test - void test_non_date_field_type() { - String dateString = "2021-11-08"; + void test_string_field_type() { + String dateString = "STRING"; OpenSearchDateType dateType = OpenSearchDateType.of(STRING); ExprValue literal = ExprValueUtils.stringValue(dateString); assertNotNull(new RangeQuery(Comparison.LT).doBuild("string_value", dateType, literal));