Skip to content

Commit 02d2131

Browse files
committed
follow the latest parse logic
Signed-off-by: xinyual <xinyual@amazon.com>
1 parent cc07650 commit 02d2131

File tree

2 files changed

+3
-28
lines changed

2 files changed

+3
-28
lines changed

opensearch/src/main/java/org/opensearch/sql/opensearch/data/value/OpenSearchExprValueFactory.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -254,18 +254,9 @@ private static ExprValue parseDateTimeString(String value, OpenSearchDateType da
254254
return new ExprDateValue(
255255
DateFormatters.from(STRICT_YEAR_MONTH_DAY_FORMATTER.parse(value)).toLocalDate());
256256
default:
257-
try {
258-
return new ExprTimestampValue(
259-
DateFormatters.from(DateFieldMapper.getDefaultDateTimeFormatter().parse(value))
260-
.toInstant());
261-
} catch (DateTimeParseException | IllegalArgumentException ignored) {
262-
try {
263-
return new ExprTimestampValue(
264-
DateFormatters.from(DATE_TIME_FORMATTER.parse(value)).toInstant());
265-
} catch (DateTimeParseException | IllegalArgumentException e) {
266-
throw e;
267-
}
268-
}
257+
return new ExprTimestampValue(
258+
DateFormatters.from(DateFieldMapper.getDefaultDateTimeFormatter().parse(value))
259+
.toInstant());
269260
}
270261
} catch (DateTimeParseException | IllegalArgumentException ignored) {
271262
// ignored

opensearch/src/test/java/org/opensearch/sql/opensearch/data/value/OpenSearchExprValueFactoryTest.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -350,18 +350,6 @@ public void constructDatetime() {
350350
assertEquals(
351351
new ExprTimestampValue("1984-05-10 20:30:40"),
352352
tupleValue("{ \"dateTimeCustomV\" : 19840510203040 }").get("dateTimeCustomV")),
353-
() ->
354-
assertEquals(
355-
new ExprTimestampValue("2015-01-01 12:10:30"),
356-
constructFromObject("timestampV", "2015-01-01 12:10:30")),
357-
() ->
358-
assertEquals(
359-
new ExprDatetimeValue("2015-01-01 12:10:30"),
360-
constructFromObject("datetimeV", "2015-01-01 12:10:30")),
361-
() ->
362-
assertEquals(
363-
new ExprDatetimeValue("2015-01-01 12:10:30"),
364-
constructFromObject("datetimeDefaultV", "2015-01-01 12:10:30")),
365353
() ->
366354
assertEquals(
367355
new ExprTimestampValue(Instant.ofEpochMilli(1420070400001L)),
@@ -394,10 +382,6 @@ public void constructDatetime_fromCustomFormat() {
394382
"Construct TIMESTAMP from \"2015-01-01 12-10-30\" failed, " + "unsupported format.",
395383
exception.getMessage());
396384

397-
assertEquals(
398-
new ExprDatetimeValue("2015-01-01 12:10:30"),
399-
constructFromObject("customAndEpochMillisV", "2015-01-01 12:10:30"));
400-
401385
assertEquals(
402386
new ExprTimestampValue("2015-01-01 12:10:30"),
403387
constructFromObject("customAndEpochMillisV", "2015-01-01-12-10-30"));

0 commit comments

Comments
 (0)