Druid Javascript aggregate Issue?

Hi,

druid 0.9.2

when I using javascript aggregator to implement SQL sum(case when x then x else x end), druid return the wrong results :

the origin table structure looks like:

pshows bid id

1 10 10001

2 15 10001

5 13 10001

4 12 10002

sql :

select sum(case when bid>‘14’ then 0 else pshows end) as _14,

      sum(case when bid>'11' then 0 else pshows end)  as _11,
      id

from table

where id=‘10001’ and bid<=‘100’ and __time>=‘2017-07-25’ and __time<=‘2017-07-27’

``

the equivalent druid query:

{

“queryType”: “groupBy”,

“dataSource”: “table”,

“intervals”: “2017-07-25T00Z/2017-07-27T00Z”,

“granularity”: “none”,

“context”: {

“timeout”: 180000

},

“filter”: {

“type”: “and”,

“fields”: [

{

“type”: “selector”,

“dimension”: “id”,

“value”: “10001”

},

{

“type”: “bound”,

“dimension”: “bid”,

“upper”: “100”

}

]

},

“dimensions”: [

{

“type”: “default”,

“dimension”: “id”,

“outputName”: “id”

}

],

“aggregations”: [

{

“name”: “_14”,

“type”: “javascript”,

“fieldNames”: [

“pshows”,

“bid”

],

“fnAggregate”: “function(current,pshows,bid) { if (parseInt(bid)>14) {return current;} else { return current + pshows;} }”,

“fnCombine”: “function(a,b) { return a+b; }”,

“fnReset”: “function() { return 0; }”

},

{

“name”: “_11”,

“type”: “javascript”,

“fieldNames”: [

“psends”,

“winbid”

],

“fnAggregate”: “function(current,pshows,bid) { if (parseInt(bid)>11) {return current;} else { return current + pshows;} }”,

“fnCombine”: “function(a,b) { return a+b; }”,

“fnReset”: “function() { return 0; }”

}

]

}

``

Did I misunderstand the javascript aggregator ?

hope for your reply~