-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
feat(cubestore): Introduce support for DATE_ADD #3085
Conversation
75c0141
to
0d9ffb1
Compare
0d9ffb1
to
2a9395f
Compare
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.
Thanks! Mostly LG, but let's ensure this covers corner cases
} | ||
|
||
result_date = result_date.with_year(year).unwrap(); | ||
result_date = result_date.with_month(month).unwrap(); |
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.
Don't unwrap, return errors instead.
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.
Option<T>
doesnt support map_err and it's not possible to implement impl From to DFErrror (it requires modern rust with try_trait feature), it's why I wrote a small fn helper
fn datetime_safety_unwrap(opt: Option<DateTime<Utc>>) -> Result<DateTime<Utc>, DataFusionError> {
if opt.is_some() {
return Ok(opt.unwrap());
}
return Err(DataFusionError::Internal(
"Unable to calculate operation between DateTime and Interval".to_string(),
));
}
let r = service | ||
.exec_query( | ||
"SELECT | ||
DATE_ADD(CAST('2021-01-01T00:00:00Z' as TIMESTAMP), INTERVAL '1 second'),\ |
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.
Could you add a few more tests?
At least these corner cases should be covered:
- Add one day to Jun 30
- Add one month to Dec
- Add one day to Feb 28 on a leap year and non-leap year
- add one year to Feb 29 on a leap year
- add one minute to 23:59:00
- add one month to Jan 30
- add one month to Jan 29 on a non-leap year and a leap year
Is there a way to get negative values in the intervals?
If no, please add assertions.
If yes, please add tests.
Hello!
Thanks