[ 
https://issues.apache.org/jira/browse/CALCITE-2324?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Sergey Nuyanzin updated CALCITE-2324:
-------------------------------------
    Summary: Extract seconds, minutes from date works not correct in some cases 
 (was: extract seconds, minutes from date works not correct in some cases)

> Extract seconds, minutes from date works not correct in some cases
> ------------------------------------------------------------------
>
>                 Key: CALCITE-2324
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2324
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Sergey Nuyanzin
>            Assignee: Julian Hyde
>            Priority: Major
>
> While working on tests for CALCITE-2303 faced with the next issue (do not fix 
> within 2303 as the fix does not need avatica update while 2303 does)
> {code:sql}select extract(second from date '2008-02-23');{sql} returns 13
> I guess the issue is known because of the test is present in 
> _org.apache.calcite.sql.test.SqlOperatorBaseTest#testExtractDate_ within 
> _TODO_ block and with the comment {code:java}  if (TODO) {
>       // Looks like there is a bug in current execution code which returns 13
>       // instead of 0
>       tester.checkScalar(
>           "extract(second from date '2008-2-23')",
>           "0",
>           "BIGINT NOT NULL");
>     }{code}
> I deep dive into it and realized that the problem is that in case of DATE 
> extract works with days + in case of seconds, minute, hours there will be 
> used _org.apache.calcite.adapter.enumerable.RexImpTable#getFactor_. And 
> finally the result is 
> {noformat}number_of_days % 60000 / 1000L //for extract seconds{noformat}
> {noformat}number_of_days % 360000 / 1000L //for extract minutes{noformat}
> and yes {code}select extract(minute from date '1700-01-01');{code} returns -1



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to