-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CALCITE-6248] Illegal dates are accepted by casts #238
Conversation
@zstan this builds on top of your previous fix for a similar issue with timestamps. |
045864e
to
657e500
Compare
657e500
to
4a6f39a
Compare
* values for days and months, and accepts spaces around the value. | ||
* @param s A string representing a date. | ||
*/ | ||
private static void validateLenientDate(String s) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no problem using this method to verify, but this implementation only verifies DAY
. Is it possible to use a more general verification method, such as:
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
try {
LocalDate date = LocalDate.parse(dateString, formatter);
return true;
} catch (DateTimeParseException e) {
return false;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does the exact same validation as the existing function validateDate.
So maybe we should improve that function too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a commit to validate month and year values.
Turns out year 0 is not legal in the Gregorian calendar, so I had to delete some tests that were using it.
Signed-off-by: Mihai Budiu <[email protected]>
If CI passes I will merge this PR. |
No description provided.