[ https://issues.apache.org/jira/browse/KYLIN-3967?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16826803#comment-16826803 ] hejian edited comment on KYLIN-3967 at 4/26/19 9:33 AM: -------------------------------------------------------- {code:java} sum(case when derived_col='1' then measure_col else 0 end){code} *derived_col*  is from lookup table and *measure_col* is a predefine measure. I think this case should be supported, because case expression is base on further aggregations, and the way that derived column works as well? was (Author: hejian999): {code:java} sum(case when derived_col='1' then measure_col else 0 end){code} *derived_col*  is from lookup table and *measure_col* is ** a ** predefine ** measure. I think this case should be supported, because case expression is base on further aggregations, and the way that derived column works as well? > 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)