You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Zhenghua Gao (Jira)" <ji...@apache.org> on 2020/03/27 12:07:00 UTC
[jira] [Created] (CALCITE-3881) SqlFunctions#addMonths yields
incorrect results in some corner case
Zhenghua Gao created CALCITE-3881:
-------------------------------------
Summary: SqlFunctions#addMonths yields incorrect results in some corner case
Key: CALCITE-3881
URL: https://issues.apache.org/jira/browse/CALCITE-3881
Project: Calcite
Issue Type: Bug
Components: avatica
Affects Versions: avatica-1.16.0
Reporter: Zhenghua Gao
SqlFunctions#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.
BTW: I didn't find the reference of the original paper of the algorithm, but an jdn explanation. Please correct me if anyone can find the original paper.
The following case can reproduce the bug:
{code:java}
@Test public void testAddMonths() {
checkAddMonths(2019, 9, 1, 2020, 3, 1, 6);
} {code}
[1] [http://www.cs.utsa.edu/~cs1063/projects/Spring2011/Project1/jdn-explanation.html]
--
This message was sent by Atlassian Jira
(v8.3.4#803005)