-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix datetime format #4524
fix datetime format #4524
Conversation
I think it's an out of range date, so you could check range and return error. Don't modify parser (and test). |
ac0b822
to
43c988a
Compare
Codecov Report
@@ Coverage Diff @@
## master #4524 +/- ##
==========================================
+ Coverage 84.66% 84.68% +0.02%
==========================================
Files 1357 1357
Lines 135081 135150 +69
==========================================
+ Hits 114360 114456 +96
+ Misses 20721 20694 -27
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
43c988a
to
d2b90e4
Compare
Fixed. year is in [0, 9999] |
src/common/time/TimeUtils.h
Outdated
@@ -44,6 +44,14 @@ class TimeUtils { | |||
if ((p[date.month] - p[date.month - 1]) < date.day) { | |||
return Status::Error("`%s' is not a valid date.", date.toString().c_str()); | |||
} | |||
if (date.year < 0 || date.year > 9999) { |
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.
Check it in parser, greater than 9999
is also valid, our upper bound is int32_t::max()
.
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.
Lower bound 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 talk with @HarrisChu .
He thinks date.year
should be year. Should not be int32_t::max()
.
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's obviously incorrect, we should provide time range as wide as possible for user. You could check Postgres in https://www.postgresql.org/docs/9.1/datatype-datetime.html or other databases.
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.
what's your expected for below queries:
yield datetime(-1)
yield datetime(1000)
yield datetime(123456)
yield datetime("-1")
yield datetime("1000")
yield datetime("123456")
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.
All valid date.
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.
Negative date means B.C.
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 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.
datetime("-1") is unexpected.
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.
fixed. year is in [-32767,32767].
da33162
to
b114ad1
Compare
src/common/time/TimeUtils.cpp
Outdated
@@ -25,7 +25,8 @@ constexpr int64_t kMaxTimestamp = std::numeric_limits<int64_t>::max() / 10000000 | |||
return Status::Error("Invalid value type."); | |||
} | |||
if (kv.first == "year") { | |||
if (kv.second.getInt() < std::numeric_limits<int16_t>::min() || | |||
// year should be in [-32767, 32767] and same as parser | |||
if (kv.second.getInt() <= std::numeric_limits<int16_t>::min() || |
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.
Why less and equal?
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.
The max of year in paser is 32767. The min is -32767.
In order to be same as parser.
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.
Where limit this in parser?
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.
The year, month, day, hour and others are INTEGER.
INTEGER is a [0-9]+
and cannot be a negative int.
Negative year supports by
| NEGATIVE INTEGER NEGATIVE INTEGER NEGATIVE INTEGER {
$$ = new nebula::Date(0-$2, $4, $6);
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 can't catch you.
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.
fixed. year is in [-32768,32767].
9c4d504
to
706b471
Compare
706b471
to
f245c02
Compare
We'd better avoid force-push |
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.
Nice
ent-3.3 checked |
What type of PR is this?
What problem(s) does this PR solve?
Issue(s) number: #4487
Description:
fixed #4487.
It will be
BAD_DATA
if input a bad year or month.How do you solve it?
year is in [-32768,32767].
Special notes for your reviewer, ex. impact of this fix, design document, etc:
Checklist:
Tests:
Affects:
Release notes:
Please confirm whether to be reflected in release notes and how to describe: