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

Julian Hyde resolved CALCITE-2731.
----------------------------------
       Resolution: Fixed
    Fix Version/s: 1.18.0

Fixed in 
[b51dbdb9|http://git-wip-us.apache.org/repos/asf/calcite/commit/b51dbdb9].

[~kgyrtkirk], thanks for the PR! I have also committed the fix to CALCITE-2730, 
and these were our blockers for 1.18 RC2. Can you please run the Hive tests 
against latest Calcite master? If successful, we can go ahead with RC2.

> RexProgramBuilder makes unsafe simplifications to CASE expressions
> ------------------------------------------------------------------
>
>                 Key: CALCITE-2731
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2731
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Zoltan Haindrich
>            Assignee: Zoltan Haindrich
>            Priority: Major
>             Fix For: 1.18.0
>
>
> In CALCITE-1413 we were cautious to not simplify 
> {code}
> CASE a=0 THEN 0 ELSE 1/a END
> {code}
> and it seemed good; however: {{RexProgramBuilder}} is also invokes simplify - 
> but the protection at that point is not able to work, because it sees only 
> references:
> {code}
> CASE $1 THEN $2 ELSE $3 END
> {code}
> testcase for conditions.iq:
> {code}
> with ax(s) as (values (1),(0))
> select case when s=0 then false else 100/s > 0 end from ax;
> !ok
> {code}
> resulting exception:
> {code}
> java.lang.AssertionError: Files differ: 
> /home/kirk/projects/calcite/core/target/test-classes/sql/surefire/sql/conditions.iq
>  /home/kirk/projects/calcite/core/target/test-classes/sql/conditions.iq
> 277a278,326
> > Error while executing command OkCommand [sql: with ax(s) as (values (1),(0))
> > select case when s=0 then false else 100/s > 0 end from ax]
> > java.lang.ArithmeticException: / by zero
> >     at Baz$1$1.current(Unknown Source)
> >     at 
> > org.apache.calcite.linq4j.Linq4j$EnumeratorIterator.next(Linq4j.java:683)
> >     at 
> > org.apache.calcite.avatica.util.IteratorCursor.next(IteratorCursor.java:46)
> {code}



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

Reply via email to