You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@kylin.apache.org by skyyws <sk...@163.com> on 2017/12/04 07:21:18 UTC

count if/case when SQL

Hello all,
I found that kylin not support count if/cast when sql which mysql supported, like this:
select count(if(A='a1',true,null)) as a1, count(if(A='a2',true,null)) as a2 from table
select count(case when A='a1' then true else null end) a1,  count(case when A='a2' then true else null end) a2 from table
Some of our users use "union" replace this function which lead to a very long sql. So I want to ask, if kylin will support this sql in the near future?

2017-12-04


skyyws 

Re: Re: count if/case when SQL

Posted by JHe <he...@gmail.com>.
according to this JIRA, sum(case when ) is currently not supported by kylin

https://issues.apache.org/jira/browse/KYLIN-2341

On Tue, Dec 5, 2017 at 10:11 AM, skyyws <sk...@163.com> wrote:

>  Hi Silas,
> Thanks for your advice. However, This SQL execute failed on kylin. The
> error tips are "*Can't find any realization. Please confirm with
> providers*.", but other normal SQL can get correct result. Do I need to
> define sum measure for dimension A?
> I use kylin 2.0.0-hbase 0.98.8 version.
>
> 2017-12-05
> ------------------------------
> skyyws
> ------------------------------
>
> *发件人:*Ge Silas <go...@live.cn>
> *发送时间:*2017-12-04 21:11
> *主题:*Re: count if/case when SQL
> *收件人:*"user@kylin.apache.org"<us...@kylin.apache.org>
> *抄送:*
>
> Hi,
>
> This could be an issue… Does below serve what you want?
>
> select sum(case when A=‘a1’ then 1 else 0 end)
>
> Thanks,
> Silas
>
> On 4 Dec 2017, at 3:21 PM, skyyws <sk...@163.com> wrote:
>
> Hello all,
> I found that kylin not support count if/cast when sql which mysql
> supported, like this:
>
> *select count(if(A='a1',true,null)) as a1, count(if(A='a2',true,null)) as
> a2 from table*
>
> *select count(case when A='a1' then true else null end) a1,  count(case
> when A='a2' then true else null end) a2 from table*
>
> Some of our users use *"union" *replace this function which lead to a
> very long sql. So I want to ask, if kylin will support this sql in the
> near future?
>
> 2017-12-04
> ------------------------------
> skyyws
>
>
>


-- 
Jingke He
hejingke@gmail.com
410-336-2228

Re: Re: count if/case when SQL

Posted by skyyws <sk...@163.com>.
 Hi Silas, 
Thanks for your advice. However, This SQL execute failed on kylin. The error tips are "Can't find any realization. Please confirm with providers.", but other normal SQL can get correct result. Do I need to define sum measure for dimension A?
I use kylin 2.0.0-hbase 0.98.8 version.

2017-12-05 

skyyws 



发件人:Ge Silas <go...@live.cn>
发送时间:2017-12-04 21:11
主题:Re: count if/case when SQL
收件人:"user@kylin.apache.org"<us...@kylin.apache.org>
抄送:

Hi, 


This could be an issue… Does below serve what you want?


select sum(case when A=‘a1’ then 1 else 0 end)


Thanks,
Silas



On 4 Dec 2017, at 3:21 PM, skyyws <sk...@163.com> wrote:


Hello all,
I found that kylin not support count if/cast when sql which mysql supported, like this:
select count(if(A='a1',true,null)) as a1, count(if(A='a2',true,null)) as a2 from table
select count(case when A='a1' then true else null end) a1,  count(case when A='a2' then true else null end) a2 from table
Some of our users use "union" replace this function which lead to a very long sql. So I want to ask, if kylin will support this sql in the near future?

2017-12-04


skyyws

Re: count if/case when SQL

Posted by Ge Silas <go...@live.cn>.
Hi,

This could be an issue… Does below serve what you want?

select sum(case when A=‘a1’ then 1 else 0 end)

Thanks,
Silas

On 4 Dec 2017, at 3:21 PM, skyyws <sk...@163.com>> wrote:

Hello all,
I found that kylin not support count if/cast when sql which mysql supported, like this:

select count(if(A='a1',true,null)) as a1, count(if(A='a2',true,null)) as a2 from table

select count(case when A='a1' then true else null end) a1,  count(case when A='a2' then true else null end) a2 from table

Some of our users use "union" replace this function which lead to a very long sql. So I want to ask, if kylin will support this sql in the near future?


2017-12-04
________________________________
skyyws