[
https://issues.apache.org/jira/browse/CALCITE-3717?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17011407#comment-17011407
]
Hank Miller commented on CALCITE-3717:
--------------------------------------
{quote} it would helps a lot if you can give a test case(maybe in JdbcTest)
that can reproduce the problem.
{quote}
I have never dive into Calcite. So I'm sorry that it may be diffcult for me to
provide a test in JdbcTest.
But the query below has the same problem. It works well in PostgreSQL, but
fails in Calcite.
{code:java}
select case when a=0 then (b+c+d)*1.0
when b=0 then 1.0/a+(c+d)*1.0
when c=0 then 1.0/a+1.0/b+d*1.0
when d=0 then 1.0/a+1.0/b+1.0/c
else 1.0/a+1.0/b+1.0/c+1.0/d end as v
from (values (0, 2, 4, 8), (1, 0, 4, 8), (1, 2, 0, 8),
(1, 2, 4, 0), (0, 0, 0, 0), (1, 2, 4, 8)) as t(a,b,c,d) {code}
> Query fails with "division by zero" exception
> ---------------------------------------------
>
> Key: CALCITE-3717
> URL: https://issues.apache.org/jira/browse/CALCITE-3717
> Project: Calcite
> Issue Type: Bug
> Reporter: Hank Miller
> Priority: Major
>
> Hi, community. We use Calcite-1.21 to connect and compute data resident in
> PostgreSQL and MySQL. It works pretty well. But we encountered a problem
> yesterday.
> Firstly, we combine data from different datasources.
> Assume the combined table is _T(...., c1, c2, c3)_, in which _c1, c2, c3_ are
> integer columns. Then according to our business logic, we need to perform
> further data processing in Calcite.
> {code:java}
> select case when c1=0 then ..
> when c2=0 then 1.0/c1 + ...
> when c3=0 then 1.0/c1 + 1.0/c2 + ...
> else -99.99 end
> from T{code}
> However, the query throws "java.lang.ArithmeticException: Division by zero".
> Anything goes wrong?
--
This message was sent by Atlassian Jira
(v8.3.4#803005)