You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by "Chinmay Kulkarni (Jira)" <ji...@apache.org> on 2019/12/21 00:54:08 UTC
[jira] [Closed] (PHOENIX-5411) Incorrect result is returned when
using sum function with case when statement
[ https://issues.apache.org/jira/browse/PHOENIX-5411?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Chinmay Kulkarni closed PHOENIX-5411.
-------------------------------------
Bulk closing Jiras for the 4.15.0 release.
> Incorrect result is returned when using sum function with case when statement
> -----------------------------------------------------------------------------
>
> Key: PHOENIX-5411
> URL: https://issues.apache.org/jira/browse/PHOENIX-5411
> Project: Phoenix
> Issue Type: Bug
> Reporter: Toshihiro Suzuki
> Assignee: Toshihiro Suzuki
> Priority: Major
> Fix For: 4.15.0, 5.1.0
>
> Attachments: PHOENIX-5411.master.v1.patch, PHOENIX-5411.master.v2.patch
>
>
> In the following case, incorrect result is returned:
> {code}
> 0: jdbc:phoenix:> create table tbl (id varchar primary key, col1 varchar, col2 integer);
> No rows affected (0.86 seconds)
> 0: jdbc:phoenix:> upsert into tbl values('id1', 'aaa', 2);
> 1 row affected (0.078 seconds)
> 0: jdbc:phoenix:> upsert into tbl values('id2', null, 1);
> 1 row affected (0.008 seconds)
> 0: jdbc:phoenix:> select sum(case when col1 is not null then col2 else 0 end), sum(case when col1 is null then col2 else 0 end) from tbl;
> +-------------------------------------------------------+-------------------------------------------------------+
> | SUM(CASE WHEN COL1 IS NOT NULL THEN COL2 ELSE 0 END) | SUM(CASE WHEN COL1 IS NOT NULL THEN COL2 ELSE 0 END) |
> +-------------------------------------------------------+-------------------------------------------------------+
> | 2 | 2 |
> +-------------------------------------------------------+-------------------------------------------------------+
> 1 row selected (0.03 seconds)
> {code}
> The correct result is (2, 1), but (2, 2) is returned.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)