-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
pgdate: Improve handling of negative years #35602
Conversation
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.
LGTM with nits
@@ -1193,3 +1193,32 @@ query T | |||
SELECT date_trunc('month', "date") AS date_trunc_month_created_at FROM "topics"; | |||
---- | |||
2017-12-01 00:00:00 +0000 UTC | |||
|
|||
|
|||
# Test negative years, ensuring that we don't trigger any of the |
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.
maybe add subtest regression_35255
here
@@ -320,7 +320,7 @@ func (fe *fieldExtract) interpretNumber(chunk numberChunk, textMonth bool) error | |||
case fe.Wants(fieldYear) && fe.Wants(fieldMonth) && fe.Wants(fieldDay): | |||
// Example: All date formats, we're starting from scratch. | |||
switch { | |||
case chunk.magnitude >= 6: | |||
case chunk.magnitude >= 6 && chunk.separator != '-': |
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.
Just curious, why do you exclude the sign here?
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.
LGTM with nits
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @jordanlewis and @knz)
pkg/sql/logictest/testdata/logic_test/datetime, line 1198 at r1 (raw file):
Previously, knz (kena) wrote…
maybe add
subtest regression_35255
here
Done.
pkg/util/timeutil/pgdate/field_extract.go, line 323 at r1 (raw file):
Previously, knz (kena) wrote…
Just curious, why do you exclude the sign here?
Updated with a comment explaining that we don't want large-magnitude, negative years to be incorrectly interpreted.
bors r+ |
35442: roachtest: add nightly multi-AZ tpccbench test r=nvanbenschoten a=nvanbenschoten This test deviates from similar roachtests in a few useful ways: - it tests across three AZs in the same region - it tests a 6-node cluster - it loads 5k tpcc warehouses - it runs on only about half of them (testing the impact of cold data) I've run this a number of times over the past few days and settled upon 2500 warehouses as a good estimate. Release note: None 35602: pgdate: Improve handling of negative years r=bobvawter a=bobvawter The current parsing code doesn't handle negative year values and returns an unhelpful error message. This change allows negative years to be specified, so that negative-year datums can at least be round-tripped through the parser. Supports #28099 Fixes #35255 Release note: None Co-authored-by: Nathan VanBenschoten <nvanbenschoten@gmail.com> Co-authored-by: Bob Vawter <bob@cockroachlabs.com>
Build succeeded |
The current parsing code doesn't handle negative year values and returns an
unhelpful error message. This change allows negative years to be specified, so
that negative-year datums can at least be round-tripped through the parser.
Supports #28099
Fixes #35255
Release note: None