-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Deny writing unsupported dates in ClickHouse #10672
Deny writing unsupported dates in ClickHouse #10672
Conversation
{ | ||
// Deny unsupported dates eagerly to prevent unexpected results. ClickHouse stores '1970-01-01' when the date is out of supported range. | ||
if (value < MIN_SUPPORTED_DATE_EPOCH || value > MAX_SUPPORTED_DATE_EPOCH) { | ||
throw new TrinoException(INVALID_ARGUMENTS, format("Epoch must be between %s and %s: %s", MIN_SUPPORTED_DATE_EPOCH, MAX_SUPPORTED_DATE_EPOCH, value)); |
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 think it makes more sense to say "Date must be between ...", since the error is referring to the input value, not the range or reference period. Per Wikipedia:
In chronology and periodization, an epoch or reference epoch is an instant in time chosen as the origin of a particular calendar era. The "epoch" serves as a reference point from which time is measured.
try (TestTable table = new TestTable(getQueryRunner()::execute, "test_unsupported_date", "(dt date)")) { | ||
assertQueryFails( | ||
format("INSERT INTO %s VALUES (DATE '1969-12-31')", table.getName()), | ||
"Epoch must be between 0 and 49710: -1"); |
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.
It would be better to format these as dates, since that is what the user interacts with. How Clickhouse stores dates internally shouldn't matter to the Trino user.
Date must be between 1970-01-01 and 2106-02-07: 1969-12-31
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.
Minor comments about the error message, otherwise looks good
97b1025
to
33b82ee
Compare
The TODO was addressed in PR trinodb#10672.
The TODO was addressed in PR #10672.
Fixes #10055