phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ankit Singhal (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (PHOENIX-5388) Incorrect current_date()/now() when query involves subquery
Date Wed, 10 Jul 2019 19:52:00 GMT

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

Ankit Singhal updated PHOENIX-5388:
-----------------------------------
    Attachment: PHOENIX-5388.patch

> Incorrect current_date()/now() when query involves subquery
> -----------------------------------------------------------
>
>                 Key: PHOENIX-5388
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-5388
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Ankit Singhal
>            Assignee: Ankit Singhal
>            Priority: Major
>         Attachments: PHOENIX-5388.patch
>
>
> Following query fails in the month of December:-
> {code}
> select  NOW(),  MONTH(NOW()) m, 
> CASE 
>  WHEN MONTH(NOW()) = 12 THEN TO_TIME(YEAR(NOW()) || '-12-31 23:59:59.999') 
>  ELSE TO_TIME(YEAR(NOW()) || '-' || ( MONTH(NOW()) + 1  ) || '-01 23:59:59.999') - 1

> END  AS this_month_end
> {code}
> It is due to an optimization we have during compilation where we evaluate the expression
if they result in to constant so that we don't need to do it for every row. 
> Currently parsing stack evaluates every expression if possible without considering any
condition, resulting in evaluation of all three expression for CASE node, MONTH(NOW()) = 12
, TO_TIME(YEAR(NOW()) || '-12-31 23:59:59.999') ,TO_TIME(YEAR(NOW()) || '-' || ( MONTH(NOW())
+ 1  ) || '-01 23:59:59.999') - 1) but evaluation of 3rd one will fail because of invalid
month. 
> Workaround: For the particular use-case , Following query though help in preventing the
expressions of WHEN CASE to be evaluated to a constant at compile time. 



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

Mime
View raw message