Skip to content

Commit

Permalink
[Bugfix](datetime) fix DateLiteral range check is no longer valid (ap…
Browse files Browse the repository at this point in the history
…ache#11917)

* [Bugfix](datetime) fix DateLiteral range check is no longer valid
  • Loading branch information
yangzhg authored Aug 19, 2022
1 parent be7a38e commit 6ca90af
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,9 @@ private void init(String s, Type type) throws AnalysisException {
second = getOrDefault(dateTime, ChronoField.SECOND_OF_MINUTE, 0);
microsecond = getOrDefault(dateTime, ChronoField.MICRO_OF_SECOND, 0);
this.type = type;
if (checkRange() || checkDate()) {
throw new AnalysisException("Datetime value is out of range");
}
} catch (Exception ex) {
throw new AnalysisException("date literal [" + s + "] is invalid: " + ex.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ public void testCheckDate() {
hasException = true;
}
Assert.assertFalse(hasException);
try {
DateLiteral literal = new DateLiteral("10000-10-07", Type.DATE);
Assert.assertEquals(10000, literal.getYear());
Assert.assertTrue(false);
} catch (AnalysisException e) {
// pass
}
}

@Test
Expand Down

0 comments on commit 6ca90af

Please sign in to comment.