[ 
https://issues.apache.org/jira/browse/KYLIN-3967?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16826759#comment-16826759
 ] 

Zhong Yanghong commented on KYLIN-3967:
---------------------------------------

Hi [~gladson.vas],

https://issues.apache.org/jira/browse/KYLIN-3359 is not for the both cases you 
mentioned above.

If your sql contains sub-queries, only the inner-most query will be used to 
request kylin cube data. Then the results will be returned to Kylin server for 
further dealing with Calcite.

For the above two queries:
--------------------------------
select sum(case
               when trans_id_alias in(11, 12, 13) then price_alias
               else 0
           end) as price_case_sum,
       part_dt_alias
from
{color:#f79232}  (select price as price_alias,
          trans_id as trans_id_alias,
          part_dt as part_dt_alias
   from kylin_sales
   where trans_id>10){color}
group by part_dt_alias
order by price_case_sum desc
--------------------------------
select sum(case
               when trans_id_alias in(11, 12, 13) then price_alias
               else 0
           end) as price_case_sum,
       part_dt_alias
from
  (select price_alias,
          trans_id_alias,
          part_dt_alias
   from
    {color:#f79232} (select price as price_alias,
             trans_id as trans_id_alias,
             part_dt as part_dt_alias
      from kylin_sales){color}
   where trans_id_alias>10)
group by part_dt_alias
order by price_case_sum desc
--------------------------------
Only the brown part will use cube data. 

> sum along with case expression does not work in query
> -----------------------------------------------------
>
>                 Key: KYLIN-3967
>                 URL: https://issues.apache.org/jira/browse/KYLIN-3967
>             Project: Kylin
>          Issue Type: Bug
>          Components: Query Engine
>            Reporter: Gladson Vas
>            Priority: Blocker
>         Attachments: notworkingcase.jpg, workingcase.jpg
>
>
> When i try to run a query with a sum case expression combination,
> eg: select sum(case when col1<0 then 0 else col1 end ) from table 
> i get the following error:
> No realization found for OLAPContext, CUBE_UNMATCHED_AGGREGATION[FunctionDesc 
> [expression=SUM, parameter=CASE(<($8, 0), 0, $8), returnType=null]], 
> rel#36838:OLAPTableScan.OLAP.[](table=[DEFAULT, table],ctx=,fields=[0, 1, 2, 
> 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 
> 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 
> 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 
> 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 
> 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 
> 100, 101, 102, 103, 104, 105, 106]) while executing SQL: "select sum (case 
> when col1 <0 then 0 else col1 end ) from table LIMIT 50000"
>  
> is there any way to support this sum case expression in the query engine?
> Also I get the same error when the sum operation is done on a column derived 
> from a case expression in a subquery.
> eg: select sum(a.col1) from (select case when col1<0 then 0 else col1 end as 
> col1 from table) a
> Thanks,
> Gladson
>  



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

Reply via email to