[ 
https://issues.apache.org/jira/browse/CALCITE-2989?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17636922#comment-17636922
 ] 

Julian Hyde commented on CALCITE-2989:
--------------------------------------

Thanks, [~freastro], that explanation helps a lot. 

Could you add that commentary in the code?
 * Improve the javadoc of methods like {{toLong}}. "mainly intended for" is no 
longer an appropriate description.
 * Consider splitting {{toLong}} into separate methods for java.sql.Date, 
java.sql.Timestamp etc.
 * And add javadoc to the tests. For example, the javadoc of 
{{testSqlDateToUnixDate}} should literally say that it tests converting 
java.sql.Date to a unix date represented as an int, and that the former uses 
ISO dates and so dates in the Gregorian shift don't exist. And similarly for 
the other tests.

Can you list which functions are fixed in this change? For example, it seems 
that {{SqlFunctions.toInt(java.sql.Date)}} is one. But it doesn't have an 
explicit test - it is tested implicitly when {{testSqlDateToUnixDate}} calls 
{{sqlDate}}.

There should be a simple mapping between tests and the public methods in 
{{SqlFunctions}} that are affected by this change. Either a separate test 
method for each public method, or really good javadoc on the tests. 

> The method ymdToJulian in DateTimeUtils returns wrong value
> -----------------------------------------------------------
>
>                 Key: CALCITE-2989
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2989
>             Project: Calcite
>          Issue Type: Bug
>          Components: avatica
>            Reporter: vinoyang
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> If we uses avatica's {{DateTimeUtils}} the dates less than 2299161 will cause 
> an error result in Flink table/sql , test code :
> {code:java}
> testAllApis(
>   "1500-04-30 12:00:00".cast(Types.SQL_TIMESTAMP),
>   "'1500-04-30 12:00:00'.cast(SQL_TIMESTAMP)",
>   "CAST('1500-04-30 12:00:00' AS TIMESTAMP)",
>   "1500-04-30 12:00:00.0")
> {code}
> result :
> {code:java}
> Expected :1500-04-30 12:00:00.0
> Actual :1500-04-20 12:00:00.0
> {code}
> another case is here : 
> https://issues.apache.org/jira/browse/FLINK-11935
> I find a key code snippet has been removed in CALCITE-1884 which caused this 
> issue :
> {code:java}
> if (j < 2299161) {
>    j = day + (153 * m + 2) / 5 + 365 * y + y / 4 - 32083;
> }
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to