[Bugfix](datetime) fix DateLiteral range check is no longer valid (#11917)
* [Bugfix](datetime) fix DateLiteral range check is no longer valid
This commit is contained in:
@ -432,6 +432,9 @@ public class DateLiteral extends LiteralExpr {
|
||||
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());
|
||||
}
|
||||
|
||||
@ -166,6 +166,13 @@ public class DateLiteralTest {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user