Skip to content

Commit

Permalink
simplified expr string type timestamp cast, fixed checkstyle failure
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Wells <[email protected]>
  • Loading branch information
matthewryanwells committed Aug 16, 2023
1 parent 32e4ee7 commit f52cc8a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f52cc8a

Please sign in to comment.