Skip to content
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-3881][avatica] DateTimeUtils#addMonths yields incorrect resu… #121

Closed
wants to merge 1 commit into from

Conversation

docete
Copy link
Contributor

@docete docete commented Mar 27, 2020

…lts in some corner case

DateTimeUtils#addMonths use DateTimeUtils#ymdToUnixDate to calculate the JDN(julian day number). But in some corner cases it yields incorrent results. The root cause is: the algorithm of DateTimeUtils#ymdToUnixDate requires reasonable month(1 to 12)[1], but SqlFunctions#addMonths may pass in a month out of the reasonable range. This PR will fix it.

@docete docete changed the title [CALCITE-3881][avatical] SqlFunctions#addMonths yields incorrect resu… [CALCITE-3881][avatica] DateTimeUtils#addMonths yields incorrect resu… Mar 30, 2020
if (month < 1 || month > 12) {
throw new IllegalArgumentException(
"Month of any date on the Gregorian should between 1 to 12, but " + month);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add some negative tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

negative tests for addMonths?
See checkAddMonths(2019, 9, 1, 2016, 8, 1, -37);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should fix the throws of the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems the throws come from old calcite since apache/calcite#1890 is not merged.

julianhyde pushed a commit to julianhyde/calcite-avatica that referenced this pull request Feb 18, 2021
@asfgit asfgit closed this in f93e72b Feb 18, 2021
@docete docete deleted the CALCITE-3881 branch March 1, 2021 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants