diff --git a/core/src/main/java/org/opensearch/sql/data/model/ExprStringValue.java b/core/src/main/java/org/opensearch/sql/data/model/ExprStringValue.java index a5f7b1a0a0..f2e63e986d 100644 --- a/core/src/main/java/org/opensearch/sql/data/model/ExprStringValue.java +++ b/core/src/main/java/org/opensearch/sql/data/model/ExprStringValue.java @@ -40,16 +40,9 @@ public Instant timestampValue() { try { return new ExprTimestampValue(value).timestampValue(); } catch (SemanticCheckException e) { - try { - return new ExprTimestampValue( - LocalDateTime.of(new ExprDateValue(value).dateValue(), LocalTime.of(0, 0, 0))) - .timestampValue(); - } catch (SemanticCheckException exception) { - throw new SemanticCheckException( - String.format( - "timestamp:%s in unsupported format, please use 'yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]'", - value)); - } + return new ExprTimestampValue( + LocalDateTime.of(new ExprDateValue(value).dateValue(), LocalTime.of(0, 0, 0))) + .timestampValue(); } } diff --git a/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/filter/FilterQueryBuilderTest.java b/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/filter/FilterQueryBuilderTest.java index 2298ed9e99..da40f07426 100644 --- a/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/filter/FilterQueryBuilderTest.java +++ b/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/filter/FilterQueryBuilderTest.java @@ -1628,8 +1628,9 @@ void cast_to_date_in_filter() { ref("date_value", DATE), DSL.castDate(literal("2021-11-08"))))); assertJsonEquals(json, buildQuery(DSL.equal( ref("date_value", DATE), DSL.castDate(literal(new ExprDateValue("2021-11-08")))))); - assertJsonEquals(json, buildQuery(DSL.equal(ref( - "date_value", DATE), DSL.castDate(literal(new ExprTimestampValue("2021-11-08 17:00:00")))))); + assertJsonEquals(json, buildQuery(DSL.equal( + ref("date_value", DATE), DSL.castDate( + literal(new ExprTimestampValue("2021-11-08 17:00:00")))))); } @Test